Spaces:
Sleeping
Sleeping
File size: 1,881 Bytes
b6570ba 25f669d c88766e 6925def b6570ba 34712d2 b6570ba c2c8f22 b6570ba c2c8f22 b78b164 c2c8f22 ecca087 4ae902a |
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 |
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()
|