Spaces:
Running
Running
Sadjad Alikhani
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,16 @@ from PIL import Image
|
|
6 |
RAW_PATH = os.path.join("images", "raw")
|
7 |
EMBEDDINGS_PATH = os.path.join("images", "embeddings")
|
8 |
|
|
|
|
|
|
|
|
|
9 |
# Function to load and display images based on user selection
|
10 |
-
def display_images(
|
|
|
|
|
|
|
|
|
11 |
# Generate the paths to the images
|
12 |
raw_image_path = os.path.join(RAW_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
|
13 |
embeddings_image_path = os.path.join(EMBEDDINGS_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
|
@@ -20,27 +28,32 @@ def display_images(percentage, complexity):
|
|
20 |
return raw_image, embeddings_image
|
21 |
|
22 |
# Define the Gradio interface
|
23 |
-
data_percentage_options = [10, 30, 50, 70, 100] # Specific percentage values
|
24 |
-
task_complexity_options = [16, 32] # Specific task complexity values
|
25 |
-
|
26 |
-
# Define the layout and appearance of the UI
|
27 |
with gr.Blocks() as demo:
|
28 |
gr.Markdown("# Raw vs. Embeddings Inference Results")
|
29 |
-
gr.Markdown("
|
30 |
-
|
31 |
-
#
|
32 |
-
with gr.
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
# Outputs (display the images side by side and set a smaller size for the images)
|
37 |
with gr.Row():
|
38 |
raw_img = gr.Image(label="Raw Channels", type="pil", width=300, height=300, interactive=False) # Smaller image size
|
39 |
embeddings_img = gr.Image(label="Embeddings", type="pil", width=300, height=300, interactive=False) # Smaller image size
|
40 |
|
41 |
-
# Trigger image updates when
|
42 |
-
|
43 |
-
|
44 |
|
45 |
# Launch the app
|
46 |
if __name__ == "__main__":
|
|
|
6 |
RAW_PATH = os.path.join("images", "raw")
|
7 |
EMBEDDINGS_PATH = os.path.join("images", "embeddings")
|
8 |
|
9 |
+
# Specific values for percentage and complexity
|
10 |
+
percentage_values = [10, 30, 50, 70, 100]
|
11 |
+
complexity_values = [16, 32]
|
12 |
+
|
13 |
# Function to load and display images based on user selection
|
14 |
+
def display_images(percentage_idx, complexity_idx):
|
15 |
+
# Map the slider index to the actual value
|
16 |
+
percentage = percentage_values[percentage_idx]
|
17 |
+
complexity = complexity_values[complexity_idx]
|
18 |
+
|
19 |
# Generate the paths to the images
|
20 |
raw_image_path = os.path.join(RAW_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
|
21 |
embeddings_image_path = os.path.join(EMBEDDINGS_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
|
|
|
28 |
return raw_image, embeddings_image
|
29 |
|
30 |
# Define the Gradio interface
|
|
|
|
|
|
|
|
|
31 |
with gr.Blocks() as demo:
|
32 |
gr.Markdown("# Raw vs. Embeddings Inference Results")
|
33 |
+
gr.Markdown("Use the sliders to adjust the percentage of data for training and task complexity.")
|
34 |
+
|
35 |
+
# Layout for vertical side-by-side sliders
|
36 |
+
with gr.Row():
|
37 |
+
# Column for percentage slider
|
38 |
+
with gr.Column():
|
39 |
+
percentage_slider = gr.Slider(minimum=0, maximum=4, step=1, value=0,
|
40 |
+
label="Percentage of Data for Training (10, 30, 50, 70, 100)",
|
41 |
+
interactive=True, orientation="vertical")
|
42 |
+
|
43 |
+
# Column for complexity slider
|
44 |
+
with gr.Column():
|
45 |
+
complexity_slider = gr.Slider(minimum=0, maximum=1, step=1, value=0,
|
46 |
+
label="Task Complexity (16, 32)",
|
47 |
+
interactive=True, orientation="vertical")
|
48 |
+
|
49 |
# Outputs (display the images side by side and set a smaller size for the images)
|
50 |
with gr.Row():
|
51 |
raw_img = gr.Image(label="Raw Channels", type="pil", width=300, height=300, interactive=False) # Smaller image size
|
52 |
embeddings_img = gr.Image(label="Embeddings", type="pil", width=300, height=300, interactive=False) # Smaller image size
|
53 |
|
54 |
+
# Trigger image updates when sliders change
|
55 |
+
percentage_slider.change(fn=display_images, inputs=[percentage_slider, complexity_slider], outputs=[raw_img, embeddings_img])
|
56 |
+
complexity_slider.change(fn=display_images, inputs=[percentage_slider, complexity_slider], outputs=[raw_img, embeddings_img])
|
57 |
|
58 |
# Launch the app
|
59 |
if __name__ == "__main__":
|