Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ from gym_workout_classification import workout_classification
|
|
7 |
from augmented_waste_classifier import waste_classification
|
8 |
from age_classification import age_classification
|
9 |
from mnist_digits import classify_digit
|
|
|
10 |
|
11 |
# Main classification function that calls the appropriate model based on selection.
|
12 |
def classify(image, model_name):
|
@@ -26,6 +27,8 @@ def classify(image, model_name):
|
|
26 |
return age_classification(image)
|
27 |
elif model_name == "mnist":
|
28 |
return classify_digit(image)
|
|
|
|
|
29 |
else:
|
30 |
return {"Error": "No model selected"}
|
31 |
|
@@ -33,7 +36,7 @@ def classify(image, model_name):
|
|
33 |
def select_model(model_name):
|
34 |
model_variants = {
|
35 |
"gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
|
36 |
-
"gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary"
|
37 |
}
|
38 |
model_variants[model_name] = "primary"
|
39 |
return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
|
@@ -50,14 +53,15 @@ with gr.Blocks() as demo:
|
|
50 |
gym_workout_btn = gr.Button("Gym Workout Classification", variant="secondary")
|
51 |
waste_btn = gr.Button("Waste Classification", variant="secondary")
|
52 |
mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
|
|
|
53 |
|
54 |
selected_model = gr.State("age")
|
55 |
gr.Markdown("### Current Model:")
|
56 |
model_display = gr.Textbox(value="age", interactive=False)
|
57 |
selected_model.change(lambda m: m, selected_model, model_display)
|
58 |
|
59 |
-
buttons = [gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn, age_btn, mnist_btn]
|
60 |
-
model_names = ["gender", "emotion", "dog breed", "deepfake", "gym workout", "waste", "age", "mnist"]
|
61 |
|
62 |
for btn, name in zip(buttons, model_names):
|
63 |
btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)
|
|
|
7 |
from augmented_waste_classifier import waste_classification
|
8 |
from age_classification import age_classification
|
9 |
from mnist_digits import classify_digit
|
10 |
+
from fashion_mnist_cloth import fashion_mnist_classification
|
11 |
|
12 |
# Main classification function that calls the appropriate model based on selection.
|
13 |
def classify(image, model_name):
|
|
|
27 |
return age_classification(image)
|
28 |
elif model_name == "mnist":
|
29 |
return classify_digit(image)
|
30 |
+
elif model_name == "fashion_mnist":
|
31 |
+
return fashion_mnist_classification(image)
|
32 |
else:
|
33 |
return {"Error": "No model selected"}
|
34 |
|
|
|
36 |
def select_model(model_name):
|
37 |
model_variants = {
|
38 |
"gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
|
39 |
+
"gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary", "fashion_mnist": "secondary"
|
40 |
}
|
41 |
model_variants[model_name] = "primary"
|
42 |
return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
|
|
|
53 |
gym_workout_btn = gr.Button("Gym Workout Classification", variant="secondary")
|
54 |
waste_btn = gr.Button("Waste Classification", variant="secondary")
|
55 |
mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
|
56 |
+
fashion_mnist_btn = gr.Button("Fashion MNIST", variant="secondary")
|
57 |
|
58 |
selected_model = gr.State("age")
|
59 |
gr.Markdown("### Current Model:")
|
60 |
model_display = gr.Textbox(value="age", interactive=False)
|
61 |
selected_model.change(lambda m: m, selected_model, model_display)
|
62 |
|
63 |
+
buttons = [gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn, age_btn, mnist_btn, fashion_mnist_btn]
|
64 |
+
model_names = ["gender", "emotion", "dog breed", "deepfake", "gym workout", "waste", "age", "mnist", "fashion_mnist"]
|
65 |
|
66 |
for btn, name in zip(buttons, model_names):
|
67 |
btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)
|