Spaces:
Sleeping
Sleeping
import torch | |
import gradio as gr | |
from huggingface_hub import hf_hub_download | |
from PIL import Image | |
yolov7_weights = hf_hub_download(repo_id="LailaMB/visual_pollution_detection", filename="best_640_rpoch56.pt") | |
model = torch.hub.load('WongKinYiu/yolov7:main', 'custom', yolov7_weights, force_reload=True) # local repo | |
def object_detection(im, size=640): | |
results = model(im) # inference | |
#results.print() # print results to screen | |
#results.show() # display results | |
#results.save() # save as results1.jpg, results2.jpg... etc. | |
results.render() # updates results.imgs with boxes and labels | |
return Image.fromarray(results.imgs[0]) | |
image = gr.inputs.Image(shape=(640, 640), image_mode="RGB", source="upload", label="Imagem", optional=False) | |
outputs = gr.outputs.Image(type="pil", label="Output Image") | |
gr.Interface( | |
fn=object_detection, | |
inputs=image, | |
outputs=outputs, | |
title="Visual Pollution Detection", | |
description="Demo for <a href='https://github.com/LailaMB/Smartathon_Visual_Pollution_Detection' style='text-decoration: underline' target='_blank'>Visual Pollution Detection Model</a>. The model which was developed by AICAS_KSU team to solve the Theme1 problem of the <a href='https://smartathon.hackerearth.com' style='text-decoration: underline' target='_blank'>Smartathon</a> .", | |
examples=[],cache_examples=False).launch() | |