smoothjazzuser commited on
Commit
27ca97b
1 Parent(s): 1afe6fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -10,7 +10,7 @@ import io
10
  import gradio as gr
11
  import PIL
12
 
13
- model_choice = 2
14
  model_names = ["nvidia/mit-b0",'facebook/convnext-base-224', 'microsoft/resnet-18', 'microsoft/swin-tiny-patch4-window7-224']
15
  model_name = model_names[model_choice]
16
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
@@ -137,7 +137,7 @@ def saliency_graph(img1, steps=25):
137
 
138
  # gradio Interface
139
  def gradio_interface(img):
140
- smoothgrad_mask_grayscale, fig_img = saliency_graph(img, steps=12)
141
  return smoothgrad_mask_grayscale, fig_img
142
 
143
  with gr.Blocks(title='Looking at the pixels models attend to', description="This function finds the most critical pixels in an image for predicting a class. The best models will ideally make predictions by highlighting the expected object. Poorly generalizable models will often rely on environmental cues instead and forego looking at the most important pixels. Highlighting the most important pixels helps explain/build trust about whether a given model uses the correct features to make its prediction.", live=True) as iface:
@@ -147,7 +147,7 @@ with gr.Blocks(title='Looking at the pixels models attend to', description="This
147
  with gr.Column():
148
  test_image = gr.Image(label="Input Image", live=True)
149
  input_btn = gr.Button(label="Classify image")
150
- model_select_dropdown = gr.Radio(model_names, label="Model to test", interactive=True, default=2)
151
  with gr.Column():
152
  output = gr.Image(label="Pixels used for classification")
153
  output2 = gr.Image(label="Top 5 Predictions")
 
10
  import gradio as gr
11
  import PIL
12
 
13
+ model_choice = 3
14
  model_names = ["nvidia/mit-b0",'facebook/convnext-base-224', 'microsoft/resnet-18', 'microsoft/swin-tiny-patch4-window7-224']
15
  model_name = model_names[model_choice]
16
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
 
137
 
138
  # gradio Interface
139
  def gradio_interface(img):
140
+ smoothgrad_mask_grayscale, fig_img = saliency_graph(img, steps=20)
141
  return smoothgrad_mask_grayscale, fig_img
142
 
143
  with gr.Blocks(title='Looking at the pixels models attend to', description="This function finds the most critical pixels in an image for predicting a class. The best models will ideally make predictions by highlighting the expected object. Poorly generalizable models will often rely on environmental cues instead and forego looking at the most important pixels. Highlighting the most important pixels helps explain/build trust about whether a given model uses the correct features to make its prediction.", live=True) as iface:
 
147
  with gr.Column():
148
  test_image = gr.Image(label="Input Image", live=True)
149
  input_btn = gr.Button(label="Classify image")
150
+ model_select_dropdown = gr.Radio(model_names, label="Model to test", interactive=True, default=3)
151
  with gr.Column():
152
  output = gr.Image(label="Pixels used for classification")
153
  output2 = gr.Image(label="Top 5 Predictions")