File size: 1,461 Bytes
a00793d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301bf24
a00793d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import config
import numpy as np
import gradio as gr
from PIL import Image
import torch, torchvision
from torchvision import transforms
from gradio_utils import (
  generate_html, 
  get_examples, 
  upload_image_inference
  )


show_label = True
examples = get_examples()
iou_thresh, thresh = 0.8, 0.8

with gr.Blocks() as gradcam:
    gr.HTML(value=generate_html, show_label=show_label)

    with gr.Row():
        upload_input = [gr.Image(shape=(config.INFERENCE_IMAGE_SIZE, 
                                        config.INFERENCE_IMAGE_SIZE)),
                        gr.Slider(0, 1, label='Transparency', value=0.6)]

    with gr.Row():
        upload_output = [
                          gr.AnnotatedImage(label='BBox Prediction',
                                            height=config.INFERENCE_IMAGE_SIZE,
                                            width=config.INFERENCE_IMAGE_SIZE),
                          gr.Gallery(label="Grad-CAM Output",
                                     show_label=True, min_width=120)]
        

    with gr.Row():
        inference_button = gr.Button("Perform Inference")
        inference_button.click(upload_image_inference,
                               inputs=upload_input,
                               outputs=upload_output)

    with gr.Row():
         gr.Examples(examples=examples, inputs=upload_input, outputs=upload_output, fn=upload_image_inference, cache_examples=True,)



gradcam.launch(debug=True)