Commit ·
20230c5
1
Parent(s): bb485f7
add files
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt', force_reload=True)
|
| 7 |
+
|
| 8 |
+
def detect(image):
|
| 9 |
+
results = model(image)
|
| 10 |
+
results.render()
|
| 11 |
+
return Image.fromarray(results.imgs[0])
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
| 15 |
+
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
| 16 |
+
|
| 17 |
+
title = "Object detection from Infrared image using YOLOv5n"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
gr.Interface(detect, inputs, outputs, title=title, theme="huggingface").launch(debug=True)
|
| 21 |
+
|