Spaces:
Runtime error
Runtime error
| import icevision | |
| from icevision.all import * | |
| import icedata | |
| import PIL | |
| import torch | |
| from torchvision import transforms | |
| import gradio as gr | |
| from icevision.models.checkpoint import * | |
| model_type = models.mmdet.retinanet ## | |
| backbone = model_type.backbones.resnet50_fpn_1x## | |
| model = torch.hub.load('~/Download/Model_M_set11_ret_nov8_map63.6.pth', source = 'local') | |
| def show_preds_gradio(input_image, display_label, display_bbox, detection_threshold): | |
| if detection_threshold==0: detection_threshold=0.5 | |
| img = PIL.Image.fromarray(input_image, 'RGB') | |
| pred_dict = model_type.end2end_detect(img, | |
| valid_tfms, | |
| model_loaded, ## | |
| class_map=class_map, | |
| detection_threshold=detection_threshold, | |
| display_label=display_label, | |
| display_bbox=display_bbox, | |
| return_img=True, | |
| font_size=16, | |
| label_color="#FF59D6") | |
| return pred_dict['img'] | |
| display_chkbox_label = gr.inputs.Checkbox(label="Label", default=True) | |
| display_chkbox_box = gr.inputs.Checkbox(label="Box", default=True) | |
| detection_threshold_slider = gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=0.5, label="Detection Threshold") | |
| outputs = gr.outputs.Image(type="pil") | |
| # Option 1: Get an image from local drive | |
| gr_interface = gr.Interface(fn=show_preds_gradio, inputs=["image", display_chkbox_label, display_chkbox_box, detection_threshold_slider], outputs=outputs, title='IceApp - COCO') | |
| gr_interface.launch(inline=False, share=True, debug=True) | |