CoolFace
Apppublic

huggingforstone/yrl

sourceHugging Faceopenrailupdated 3y agoView on Hugging Face
0likes
app.py28 linesDownload Raw Back to root
1"""2Source: https://github.com/AK391/yolov5/blob/master/utils/gradio/demo.py3"""4 5import gradio as gr6import torch7from PIL import Image8 9model = torch.hub.load('ultralytics/yolov5', 'custom', 'best.pt')  # force_reload=True to update10 11 12def yolo(im, size=640):13    g = (size / max(im.size))  # gain14    im = im.resize((int(x * g) for x in im.size), Image.LANCZOS)  # resize15    results = model(im)  # inference16    results.render()  # updates results.ims with boxes and labels17    return Image.fromarray(results.ims[0])18 19 20inputs = gr.inputs.Image(type='pil', label="Original Image")21outputs = gr.outputs.Image(type="pil", label="Output Image")22 23title = "YOLOv5"24description = "YOLOv5 demo for fire detection. Upload an image or click an example image to use."25article = "See https://github.com/robmarkcole/fire-detection-from-images"26examples = [['pan-fire.jpg'], ['fire-basket.jpg']]27gr.Interface(yolo, inputs, outputs, title=title, description=description, article=article, examples=examples).launch(28    debug=True)