Moditha24 commited on
Commit
491fff3
·
verified ·
1 Parent(s): 385c8a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -36,6 +36,9 @@ default_images = {
36
  "Vest": "dress.jpg"
37
  }
38
 
 
 
 
39
  # **Image Preprocessing Function**
40
  def preprocess_image(image):
41
  """Applies necessary transformations to the input image."""
@@ -104,23 +107,31 @@ with gr.Blocks() as interface:
104
  gr.Markdown("# Clothing1M Image Classifier")
105
  gr.Markdown("Upload a clothing image or select from the predefined images below.")
106
 
107
- # Default Image Selection
 
 
 
 
 
 
 
 
108
  default_selector = gr.Radio(
109
  choices=list(default_images.keys()),
110
  label="Select a Default Image",
111
- value="T-Shirt"
112
  )
113
 
114
- # File Upload Option
115
  image_upload = gr.Image(type="numpy", label="Or Upload Your Own Image")
116
 
117
- # Output Text
118
  output_text = gr.Textbox(label="Classification Result")
119
 
120
- # Classify Button
121
  classify_button = gr.Button("Classify Image")
122
 
123
- # Define Action
124
  classify_button.click(
125
  fn=classify_image,
126
  inputs=[default_selector, image_upload],
 
36
  "Vest": "dress.jpg"
37
  }
38
 
39
+ # Convert image paths to a format suitable for Gradio
40
+ default_image_paths = [[img_path] for img_path in default_images.values()]
41
+
42
  # **Image Preprocessing Function**
43
  def preprocess_image(image):
44
  """Applies necessary transformations to the input image."""
 
107
  gr.Markdown("# Clothing1M Image Classifier")
108
  gr.Markdown("Upload a clothing image or select from the predefined images below.")
109
 
110
+ # **Default Image Gallery for Selection**
111
+ gr.Markdown("### Select a Default Image:")
112
+ gallery = gr.Gallery(
113
+ value=default_image_paths,
114
+ label="Available Default Images",
115
+ show_label=True
116
+ )
117
+
118
+ # **Default Image Selection Radio**
119
  default_selector = gr.Radio(
120
  choices=list(default_images.keys()),
121
  label="Select a Default Image",
122
+ value="Shawl"
123
  )
124
 
125
+ # **File Upload Option**
126
  image_upload = gr.Image(type="numpy", label="Or Upload Your Own Image")
127
 
128
+ # **Output Text**
129
  output_text = gr.Textbox(label="Classification Result")
130
 
131
+ # **Classify Button**
132
  classify_button = gr.Button("Classify Image")
133
 
134
+ # **Define Action**
135
  classify_button.click(
136
  fn=classify_image,
137
  inputs=[default_selector, image_upload],