Akhya commited on
Commit
1b8d5cb
·
1 Parent(s): 48d2973

YOLO acne model deployment

Browse files
Files changed (3) hide show
  1. app.py +31 -0
  2. best.pt +3 -0
  3. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from PIL import Image
4
+
5
+ # Load YOLOv5 custom model
6
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
7
+
8
+ def predict(image):
9
+ results = model(image)
10
+
11
+ detections = results.pandas().xyxy[0]
12
+
13
+ output = []
14
+
15
+ for _, row in detections.iterrows():
16
+ output.append({
17
+ "class": row["name"],
18
+ "confidence": float(row["confidence"])
19
+ })
20
+
21
+ return output
22
+
23
+ # Gradio UI (also becomes API)
24
+ interface = gr.Interface(
25
+ fn=predict,
26
+ inputs=gr.Image(type="pil"),
27
+ outputs="json",
28
+ title="Acne YOLO Detection API"
29
+ )
30
+
31
+ interface.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ff676000024b38ed87de6f22e9d7c0a3a099558bd8dd23fc1a537accfb6090b
3
+ size 14416559
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio==4.44.1
2
+ torch
3
+ torchvision
4
+ opencv-python
5
+ numpy
6
+ Pillow
7
+ ultralytics