Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ from age_classification import age_classification
|
|
9 |
from mnist_digits import classify_digit
|
10 |
from fashion_mnist_cloth import fashion_mnist_classification
|
11 |
from indian_western_food_classify import food_classification
|
|
|
12 |
|
13 |
# Main classification function that calls the appropriate model based on selection.
|
14 |
def classify(image, model_name):
|
@@ -32,6 +33,8 @@ def classify(image, model_name):
|
|
32 |
return fashion_mnist_classification(image)
|
33 |
elif model_name == "food":
|
34 |
return food_classification(image)
|
|
|
|
|
35 |
else:
|
36 |
return {"Error": "No model selected"}
|
37 |
|
@@ -40,7 +43,7 @@ def select_model(model_name):
|
|
40 |
model_variants = {
|
41 |
"gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
|
42 |
"gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary",
|
43 |
-
"fashion_mnist": "secondary", "food": "secondary"
|
44 |
}
|
45 |
model_variants[model_name] = "primary"
|
46 |
return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
|
@@ -59,14 +62,15 @@ with gr.Blocks() as demo:
|
|
59 |
mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
|
60 |
fashion_mnist_btn = gr.Button("Fashion MNIST Classification", variant="secondary")
|
61 |
food_btn = gr.Button("Indian/Western Food", variant="secondary")
|
|
|
62 |
|
63 |
selected_model = gr.State("age")
|
64 |
gr.Markdown("### Current Model:")
|
65 |
model_display = gr.Textbox(value="age", interactive=False)
|
66 |
selected_model.change(lambda m: m, selected_model, model_display)
|
67 |
|
68 |
-
buttons = [gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn, age_btn, mnist_btn, fashion_mnist_btn, food_btn]
|
69 |
-
model_names = ["gender", "emotion", "dog breed", "deepfake", "gym workout", "waste", "age", "mnist", "fashion_mnist", "food"]
|
70 |
|
71 |
for btn, name in zip(buttons, model_names):
|
72 |
btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)
|
|
|
9 |
from mnist_digits import classify_digit
|
10 |
from fashion_mnist_cloth import fashion_mnist_classification
|
11 |
from indian_western_food_classify import food_classification
|
12 |
+
from bird_species import bird_classification
|
13 |
|
14 |
# Main classification function that calls the appropriate model based on selection.
|
15 |
def classify(image, model_name):
|
|
|
33 |
return fashion_mnist_classification(image)
|
34 |
elif model_name == "food":
|
35 |
return food_classification(image)
|
36 |
+
elif model_name == "bird":
|
37 |
+
return bird_classification(image)
|
38 |
else:
|
39 |
return {"Error": "No model selected"}
|
40 |
|
|
|
43 |
model_variants = {
|
44 |
"gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
|
45 |
"gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary",
|
46 |
+
"fashion_mnist": "secondary", "food": "secondary", "bird": "secondary"
|
47 |
}
|
48 |
model_variants[model_name] = "primary"
|
49 |
return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
|
|
|
62 |
mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
|
63 |
fashion_mnist_btn = gr.Button("Fashion MNIST Classification", variant="secondary")
|
64 |
food_btn = gr.Button("Indian/Western Food", variant="secondary")
|
65 |
+
bird_btn = gr.Button("Bird Species", variant="secondary")
|
66 |
|
67 |
selected_model = gr.State("age")
|
68 |
gr.Markdown("### Current Model:")
|
69 |
model_display = gr.Textbox(value="age", interactive=False)
|
70 |
selected_model.change(lambda m: m, selected_model, model_display)
|
71 |
|
72 |
+
buttons = [gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn, age_btn, mnist_btn, fashion_mnist_btn, food_btn, bird_btn]
|
73 |
+
model_names = ["gender", "emotion", "dog breed", "deepfake", "gym workout", "waste", "age", "mnist", "fashion_mnist", "food", "bird"]
|
74 |
|
75 |
for btn, name in zip(buttons, model_names):
|
76 |
btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)
|