Sadjad Alikhani commited on
Commit
5608218
·
verified ·
1 Parent(s): 9a014ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -7,30 +7,34 @@ Created on Tue Sep 17 15:03:39 2024
7
 
8
  import gradio as gr
9
  import os
 
10
 
11
- # Paths to the images folder (use relative paths)
12
- RAW_PATH = "/images/raw"
13
- EMBEDDINGS_PATH = "/images/embeddings"
14
 
15
- # Function to display images based on user selection
16
  def display_images(percentage, complexity):
17
- # Format the filenames based on user selections
18
- raw_image_path = f"{RAW_PATH}/percentage_{percentage}_complexity_{complexity}.png"
19
- embeddings_image_path = f"{EMBEDDINGS_PATH}/percentage_{percentage}_complexity_{complexity}.png"
20
 
21
- # Return the corresponding images for raw and embeddings
22
- return raw_image_path, embeddings_image_path
 
 
 
 
23
 
24
  # Define the Gradio interface
25
- # Step 2: Pass arrays of values for data percentage and task complexity
26
  data_percentage_options = [10, 30, 50, 70, 100]
27
  task_complexity_options = [16, 32]
28
 
29
  demo = gr.Interface(
30
  fn=display_images,
31
  inputs=[
32
- gr.Dropdown(data_percentage_options, label="Percentage of Data for Training"), # Dropdown for data percentage
33
- gr.Radio(task_complexity_options, label="Task Complexity") # Radio for task complexity
34
  ],
35
  outputs=[
36
  gr.Image(label="Raw Channels"),
@@ -41,4 +45,4 @@ demo = gr.Interface(
41
  )
42
 
43
  if __name__ == "__main__":
44
- demo.launch()
 
7
 
8
  import gradio as gr
9
  import os
10
+ from PIL import Image
11
 
12
+ # Paths to the images folder
13
+ RAW_PATH = os.path.join("images", "raw")
14
+ EMBEDDINGS_PATH = os.path.join("images", "embeddings")
15
 
16
+ # Function to load and display images based on user selection
17
  def display_images(percentage, complexity):
18
+ # Generate the paths to the images
19
+ raw_image_path = os.path.join(RAW_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
20
+ embeddings_image_path = os.path.join(EMBEDDINGS_PATH, f"percentage_{percentage}_complexity_{complexity}.png")
21
 
22
+ # Load images using PIL
23
+ raw_image = Image.open(raw_image_path)
24
+ embeddings_image = Image.open(embeddings_image_path)
25
+
26
+ # Return the loaded images
27
+ return raw_image, embeddings_image
28
 
29
  # Define the Gradio interface
 
30
  data_percentage_options = [10, 30, 50, 70, 100]
31
  task_complexity_options = [16, 32]
32
 
33
  demo = gr.Interface(
34
  fn=display_images,
35
  inputs=[
36
+ gr.Dropdown(data_percentage_options, label="Percentage of Data for Training"),
37
+ gr.Radio(task_complexity_options, label="Task Complexity")
38
  ],
39
  outputs=[
40
  gr.Image(label="Raw Channels"),
 
45
  )
46
 
47
  if __name__ == "__main__":
48
+ demo.launch()