Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ 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():
|
@@ -13,6 +14,9 @@ def select_emotion():
|
|
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":
|
@@ -21,18 +25,21 @@ def classify(image, model_name):
|
|
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
|
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 |
|
@@ -40,6 +47,7 @@ with gr.Blocks() as demo:
|
|
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)
|
@@ -49,7 +57,7 @@ with gr.Blocks() as demo:
|
|
49 |
# Main interface: image input, analyze button, and prediction output.
|
50 |
with gr.Column():
|
51 |
image_input = gr.Image(type="numpy", label="Upload Image")
|
52 |
-
analyze_btn = gr.Button("
|
53 |
output_label = gr.Label(label="Prediction Scores")
|
54 |
|
55 |
# When the "Analyze" button is clicked, use the selected model to classify the image.
|
|
|
2 |
from gender_classification import gender_classification
|
3 |
from emotion_classification import emotion_classification
|
4 |
from dog_breed import dog_breed_classification
|
5 |
+
from deepfake_vs_real import deepfake_classification
|
6 |
|
7 |
# Functions to update the model state when a button is clicked.
|
8 |
def select_gender():
|
|
|
14 |
def select_dog_breed():
|
15 |
return "dog breed"
|
16 |
|
17 |
+
def select_deepfake():
|
18 |
+
return "deepfake"
|
19 |
+
|
20 |
# Main classification function that calls the appropriate model based on selection.
|
21 |
def classify(image, model_name):
|
22 |
if model_name == "gender":
|
|
|
25 |
return emotion_classification(image)
|
26 |
elif model_name == "dog breed":
|
27 |
return dog_breed_classification(image)
|
28 |
+
elif model_name == "deepfake":
|
29 |
+
return deepfake_classification(image)
|
30 |
else:
|
31 |
return {"Error": "No model selected"}
|
32 |
|
33 |
with gr.Blocks() as demo:
|
34 |
# Sidebar with title and model selection buttons.
|
35 |
with gr.Sidebar():
|
36 |
+
gr.Markdown("# SigLIP2 Classification")
|
37 |
with gr.Row():
|
38 |
gender_btn = gr.Button("Gender Classification")
|
39 |
emotion_btn = gr.Button("Emotion Classification")
|
40 |
dog_breed_btn = gr.Button("Dog Breed Classification")
|
41 |
+
deepfake_btn = gr.Button("Deepfake vs Real")
|
42 |
+
|
43 |
# State to hold the current model choice.
|
44 |
selected_model = gr.State("gender")
|
45 |
|
|
|
47 |
gender_btn.click(fn=select_gender, inputs=[], outputs=selected_model)
|
48 |
emotion_btn.click(fn=select_emotion, inputs=[], outputs=selected_model)
|
49 |
dog_breed_btn.click(fn=select_dog_breed, inputs=[], outputs=selected_model)
|
50 |
+
deepfake_btn.click(fn=select_deepfake, inputs=[], outputs=selected_model)
|
51 |
|
52 |
gr.Markdown("### Current Model:")
|
53 |
model_display = gr.Textbox(value="gender", interactive=False)
|
|
|
57 |
# Main interface: image input, analyze button, and prediction output.
|
58 |
with gr.Column():
|
59 |
image_input = gr.Image(type="numpy", label="Upload Image")
|
60 |
+
analyze_btn = gr.Button("Analyze")
|
61 |
output_label = gr.Label(label="Prediction Scores")
|
62 |
|
63 |
# When the "Analyze" button is clicked, use the selected model to classify the image.
|