prithivMLmods commited on
Commit
d443926
·
verified ·
1 Parent(s): ad5c6b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -2,9 +2,12 @@ import gradio as gr
2
  from gender_classification import gender_classification
3
  from emotion_classification import emotion_classification
4
 
5
- # Function to update the selected model state when a button is clicked.
6
- def select_model(model_name):
7
- return model_name
 
 
 
8
 
9
  # Main classification function that calls the appropriate model based on selection.
10
  def classify(image, model_name):
@@ -16,20 +19,20 @@ def classify(image, model_name):
16
  return {"Error": "No model selected"}
17
 
18
  with gr.Blocks() as demo:
19
- # Sidebar with title and model selection buttons
20
  with gr.Sidebar():
21
  gr.Markdown("# SigLIP2 Classification")
22
  with gr.Row():
23
  gender_btn = gr.Button("Gender Classification")
24
  emotion_btn = gr.Button("Emotion Classification")
25
- # State to hold the current model choice
26
  selected_model = gr.State("gender")
27
- # Set model state when buttons are clicked
28
- gender_btn.click(fn=select_model, inputs=[], outputs=selected_model, _js="() => 'gender'")
29
- emotion_btn.click(fn=select_model, inputs=[], outputs=selected_model, _js="() => 'emotion'")
30
  gr.Markdown("### Current Model:")
31
  model_display = gr.Textbox(value="gender", interactive=False)
32
- # Update display when state changes
33
  selected_model.change(lambda m: m, selected_model, model_display)
34
 
35
  # Main interface: image input, analyze button, and prediction output.
 
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():
7
+ return "gender"
8
+
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):
 
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 Classification")
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.
36
  selected_model.change(lambda m: m, selected_model, model_display)
37
 
38
  # Main interface: image input, analyze button, and prediction output.