Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from gender_classification import gender_classification
|
3 |
from emotion_classification import emotion_classification
|
|
|
4 |
|
5 |
# Functions to update the model state when a button is clicked.
|
6 |
def select_gender():
|
@@ -9,27 +10,37 @@ def select_gender():
|
|
9 |
def select_emotion():
|
10 |
return "emotion"
|
11 |
|
|
|
|
|
|
|
12 |
# Main classification function that calls the appropriate model based on selection.
|
13 |
def classify(image, model_name):
|
14 |
if model_name == "gender":
|
15 |
return gender_classification(image)
|
16 |
elif model_name == "emotion":
|
17 |
return emotion_classification(image)
|
|
|
|
|
18 |
else:
|
19 |
return {"Error": "No model selected"}
|
20 |
|
21 |
with gr.Blocks() as demo:
|
22 |
# Sidebar with title and model selection buttons.
|
23 |
with gr.Sidebar():
|
24 |
-
gr.Markdown("# SigLIP2
|
25 |
with gr.Row():
|
26 |
gender_btn = gr.Button("Gender Classification")
|
27 |
emotion_btn = gr.Button("Emotion Classification")
|
|
|
|
|
28 |
# State to hold the current model choice.
|
29 |
selected_model = gr.State("gender")
|
|
|
30 |
# Set model state when buttons are clicked.
|
31 |
gender_btn.click(fn=select_gender, inputs=[], outputs=selected_model)
|
32 |
emotion_btn.click(fn=select_emotion, inputs=[], outputs=selected_model)
|
|
|
|
|
33 |
gr.Markdown("### Current Model:")
|
34 |
model_display = gr.Textbox(value="gender", interactive=False)
|
35 |
# Update display when state changes.
|
|
|
1 |
import gradio as gr
|
2 |
from gender_classification import gender_classification
|
3 |
from emotion_classification import emotion_classification
|
4 |
+
from dog_breed import dog_breed_classification
|
5 |
|
6 |
# Functions to update the model state when a button is clicked.
|
7 |
def select_gender():
|
|
|
10 |
def select_emotion():
|
11 |
return "emotion"
|
12 |
|
13 |
+
def select_dog_breed():
|
14 |
+
return "dog_breed"
|
15 |
+
|
16 |
# Main classification function that calls the appropriate model based on selection.
|
17 |
def classify(image, model_name):
|
18 |
if model_name == "gender":
|
19 |
return gender_classification(image)
|
20 |
elif model_name == "emotion":
|
21 |
return emotion_classification(image)
|
22 |
+
elif model_name == "dog_breed":
|
23 |
+
return dog_breed_classification(image)
|
24 |
else:
|
25 |
return {"Error": "No model selected"}
|
26 |
|
27 |
with gr.Blocks() as demo:
|
28 |
# Sidebar with title and model selection buttons.
|
29 |
with gr.Sidebar():
|
30 |
+
gr.Markdown("# SigLIP2 224")
|
31 |
with gr.Row():
|
32 |
gender_btn = gr.Button("Gender Classification")
|
33 |
emotion_btn = gr.Button("Emotion Classification")
|
34 |
+
dog_breed_btn = gr.Button("Dog Breed Classification")
|
35 |
+
|
36 |
# State to hold the current model choice.
|
37 |
selected_model = gr.State("gender")
|
38 |
+
|
39 |
# Set model state when buttons are clicked.
|
40 |
gender_btn.click(fn=select_gender, inputs=[], outputs=selected_model)
|
41 |
emotion_btn.click(fn=select_emotion, inputs=[], outputs=selected_model)
|
42 |
+
dog_breed_btn.click(fn=select_dog_breed, inputs=[], outputs=selected_model)
|
43 |
+
|
44 |
gr.Markdown("### Current Model:")
|
45 |
model_display = gr.Textbox(value="gender", interactive=False)
|
46 |
# Update display when state changes.
|