sanket03 commited on
Commit
150b753
·
1 Parent(s): 75666b9

added launch code and also updated style warning code

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -34,6 +34,12 @@ def inference(input_img, transparency = 0.5, target_layer_number = -1):
34
  visualization = show_cam_on_image(org_img/255, grayscale_cam, use_rgb=True, image_weight=transparency)
35
  return confidences, visualization
36
 
 
 
 
 
 
 
37
  title = "CIFAR10 trained on ResNet18 Model with GradCAM"
38
  description = "A simple Gradio interface to infer on ResNet model, and get GradCAM results"
39
  examples = [["cat.png", 0.5, -1],["dog.png", 0.5, -1]]
@@ -41,8 +47,10 @@ examples = [["cat.png", 0.5, -1],["dog.png", 0.5, -1]]
41
  demo = gr.Interface(
42
  inference,
43
  inputs = [gr.Image(shape=(32, 32), label="Input Image"), gr.Slider(0, 1, value = 0.5, label="Opacity of GradCAM"), gr.Slider(-2, -1, value = -2, step=1, label="Which Layer?")],
44
- outputs = [gr.Label(num_top_classes=3), gr.Image(shape=(32, 32), label="Output").style(width=128, height=128)],
45
  title = title,
46
  description = description,
47
  examples = examples,
48
  )
 
 
 
34
  visualization = show_cam_on_image(org_img/255, grayscale_cam, use_rgb=True, image_weight=transparency)
35
  return confidences, visualization
36
 
37
+ # Define the style for the output image (width and height)
38
+ output_image_style = gr.Interface.Style(
39
+ width=128, # Set the width of the output image
40
+ height=128 # Set the height of the output image
41
+ )
42
+
43
  title = "CIFAR10 trained on ResNet18 Model with GradCAM"
44
  description = "A simple Gradio interface to infer on ResNet model, and get GradCAM results"
45
  examples = [["cat.png", 0.5, -1],["dog.png", 0.5, -1]]
 
47
  demo = gr.Interface(
48
  inference,
49
  inputs = [gr.Image(shape=(32, 32), label="Input Image"), gr.Slider(0, 1, value = 0.5, label="Opacity of GradCAM"), gr.Slider(-2, -1, value = -2, step=1, label="Which Layer?")],
50
+ outputs = [gr.Label(num_top_classes=3), gr.Image(shape=(32, 32), label="Output", style=output_image_style)],
51
  title = title,
52
  description = description,
53
  examples = examples,
54
  )
55
+
56
+ demo.launch()