Vladimir Zaigrajew commited on
Commit
76c7e15
·
1 Parent(s): 704cd1f

small change

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -188,22 +188,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Matryoshka Sparse Autoencoder (MSA
188
  "Upload an image to see its top activating concepts from a sparse autoencoder. Then, choose a concept (from `clip_disect_20k.txt`) to visualize how manipulating its corresponding concept magnitude affects the image representation."
189
  )
190
 
191
- gr.Examples(
192
- examples=[
193
- ["bird.jpg", 10, "birds", "", 10.0],
194
- ["statue.jpg", 10, "statue", "humans", 10.0],
195
- ],
196
- # NOTE: You might need to create placeholder images 'bird.jpg' and 'statue.jpg'
197
- # in your directory for the examples to load correctly.
198
- inputs=[image_input, top_k_slider, concept_input, neg_concept_input, max_strength_slider],
199
- outputs=[output_image, output_bar_plot, output_line_plot],
200
- fn=predict,
201
- cache_examples=True # Set to True for faster loading on HF Spaces
202
- )
203
-
204
  with gr.Row():
205
  with gr.Column(scale=1):
206
- # Input controls
207
  image_input = gr.Image(label="Input Image", sources=['upload', 'webcam'], type="pil")
208
  gr.Markdown("### Analysis & Manipulation Controls")
209
  top_k_slider = gr.Slider(minimum=3, maximum=20, value=10, step=1, label="Numb of Top K Concepts to visualize")
@@ -213,11 +199,21 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Matryoshka Sparse Autoencoder (MSA
213
  submit_btn = gr.Button("Analyze and Interpret", variant="primary")
214
 
215
  with gr.Column(scale=2):
216
- # Output displays
217
  gr.Markdown("### Results")
218
  output_image = gr.Image(label="Original Image", interactive=False)
219
  output_bar_plot = gr.Plot(label="Top Activating Concepts")
220
  output_line_plot = gr.Plot(label="Concept Manipulation Analysis")
 
 
 
 
 
 
 
 
 
 
 
221
 
222
  # Wire up the button to the function
223
  submit_btn.click(
 
188
  "Upload an image to see its top activating concepts from a sparse autoencoder. Then, choose a concept (from `clip_disect_20k.txt`) to visualize how manipulating its corresponding concept magnitude affects the image representation."
189
  )
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  with gr.Row():
192
  with gr.Column(scale=1):
 
193
  image_input = gr.Image(label="Input Image", sources=['upload', 'webcam'], type="pil")
194
  gr.Markdown("### Analysis & Manipulation Controls")
195
  top_k_slider = gr.Slider(minimum=3, maximum=20, value=10, step=1, label="Numb of Top K Concepts to visualize")
 
199
  submit_btn = gr.Button("Analyze and Interpret", variant="primary")
200
 
201
  with gr.Column(scale=2):
 
202
  gr.Markdown("### Results")
203
  output_image = gr.Image(label="Original Image", interactive=False)
204
  output_bar_plot = gr.Plot(label="Top Activating Concepts")
205
  output_line_plot = gr.Plot(label="Concept Manipulation Analysis")
206
+
207
+ gr.Examples(
208
+ examples=[
209
+ ["bird.jpg", 10, "birds", "", 10.0],
210
+ ["statue.jpg", 10, "statue", "humans", 10.0],
211
+ ],
212
+ inputs=[image_input, top_k_slider, concept_input, neg_concept_input, max_strength_slider],
213
+ outputs=[output_image, output_bar_plot, output_line_plot],
214
+ fn=predict,
215
+ cache_examples=True
216
+ )
217
 
218
  # Wire up the button to the function
219
  submit_btn.click(