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]) | |
title = "Visual Pollution Detection" | |
description = """Esse modelo é uma pequena demonstração baseada em uma análise de cerca de 60 imagens somente. Para resultados mais confiáveis e genéricos, são necessários mais exemplos (imagens). | |
""" | |
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(detect,[gr.Image(type="pil"), gr.Image(type="pil")],description="demo for <a href='https://github.com/WongKinYiu/yolov7' style='text-decoration: underline' target='_blank'>WongKinYiu/yolov7</a> Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors").launch() | |
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'>Smartathon Visual Pollution Detection Model</a>. The model which was developed by AICAS_KSU team to solve the Theme1 problem of the [Smartathon](https://smartathon.hackerearth.com)., | |
examples=[],cache_examples=False).launch() | |