Spaces:
Runtime error
Runtime error
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) |