Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image,ImageDraw,ImageFont
|
| 2 |
+
import numpy as np
|
| 3 |
+
from ultralytics import YOLO
|
| 4 |
+
import streamlit as st
|
| 5 |
+
|
| 6 |
+
model = YOLO('NarutoHandSignDetector.pt')
|
| 7 |
+
img = st.file_uploader('Choose an Image')
|
| 8 |
+
|
| 9 |
+
if img is not None:
|
| 10 |
+
img = Image.open(img).resize((640,640)).convert('RGB')
|
| 11 |
+
results = model(img)
|
| 12 |
+
for result in results:
|
| 13 |
+
for i in range(len(result.boxes.cls)):
|
| 14 |
+
cls = result.boxes.cls[i]
|
| 15 |
+
cls = arr[int(cls)]
|
| 16 |
+
lbl = result.boxes.conf[i]
|
| 17 |
+
boxes = result.boxes.xyxy[i]
|
| 18 |
+
draw = ImageDraw.Draw(img)
|
| 19 |
+
draw.rectangle([boxes[0], boxes[1], boxes[2], boxes[3]], outline="black", width=5)
|
| 20 |
+
|
| 21 |
+
st.image(img,'Detected')
|