Sadjad Alikhani
commited on
Create app.py
Browse files- gradio/app.py +37 -0
gradio/app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
# Paths to the images folder (use relative paths)
|
5 |
+
RAW_PATH = ".gradio/images/raw"
|
6 |
+
EMBEDDINGS_PATH = ".gradio/images/embeddings"
|
7 |
+
|
8 |
+
# Function to display images based on user selection
|
9 |
+
def display_images(percentage, complexity):
|
10 |
+
# Format the filenames based on user selections
|
11 |
+
raw_image_path = f"{RAW_PATH}/percentage_{percentage}_complexity_{complexity}.png"
|
12 |
+
embeddings_image_path = f"{EMBEDDINGS_PATH}/percentage_{percentage}_complexity_{complexity}.png"
|
13 |
+
|
14 |
+
# Return the corresponding images for raw and embeddings
|
15 |
+
return raw_image_path, embeddings_image_path
|
16 |
+
|
17 |
+
# Define the Gradio interface
|
18 |
+
# Step 2: Pass arrays of values for data percentage and task complexity
|
19 |
+
data_percentage_options = [10, 30, 50, 70, 100]
|
20 |
+
task_complexity_options = [16, 32]
|
21 |
+
|
22 |
+
demo = gr.Interface(
|
23 |
+
fn=display_images,
|
24 |
+
inputs=[
|
25 |
+
gr.Dropdown(data_percentage_options, label="Percentage of Data for Training"), # Dropdown for data percentage
|
26 |
+
gr.Radio(task_complexity_options, label="Task Complexity") # Radio for task complexity
|
27 |
+
],
|
28 |
+
outputs=[
|
29 |
+
gr.Image(label="Raw Channels"),
|
30 |
+
gr.Image(label="Embeddings")
|
31 |
+
],
|
32 |
+
title="Raw vs. Embeddings Inference Results",
|
33 |
+
description="Select a data percentage and task complexity to view the corresponding inference result for raw channels and embeddings."
|
34 |
+
)
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
demo.launch()
|