Beasto commited on
Commit
5752493
·
verified ·
1 Parent(s): 3cd5947

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
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')