Spaces:
Runtime error
Runtime error
File size: 1,506 Bytes
4f6dccc b3ae762 4f6dccc 64d176e 4f6dccc d5727ac 2a6e703 4f6dccc f9eac0b 4f6dccc 2a6e703 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import gradio as gr
import cv2
import requests
from ultralytics import YOLO
model = YOLO('best.pt')
path = [['image.jpg'],]
classes = ['ain', 'al', 'aleff','bb','dal','dha','dhad','fa','gaaf','ghain','ha','haa','jeem','kaaf','khaa','la','laam',
'meem','nun','ra','saad','seen','sheen','ta','taa','thaa','thal','toot','waw','ya','yaa','zay']
TargetMapper = dict(zip(range(32),classes))
def show_preds_image(image_path):
print(image_path)
image = cv2.imread(image_path)
outputs = model.predict(source=image_path)
results = outputs[0]
for i,det in enumerate(results.boxes.xyxy):
cls = TargetMapper[results.boxes.cls.numpy()[i]]
#det = results.boxes.xyxy[0]
cv2.rectangle(
image,
(int(det[0]), int(det[1])),
(int(det[2]), int(det[3])),
color=(0, 0, 255),
thickness=2,
lineType=cv2.LINE_AA
)
cv2.putText(image, cls, (int(det[0]), int(det[1])-10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (36,255,12), 2)
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
#image = cv2.imwrite('output.jpg', show_preds_image(path))
inputs_image = [
gr.components.Image(type="filepath", label="Input Image"),
]
outputs_image = [
gr.components.Image(type="numpy", label="Output Image"),
]
gr.Interface(
fn=show_preds_image,
inputs=inputs_image,
outputs=outputs_image,
title="Arab Sign Language Detection app",
examples=path,
cache_examples=False,
).launch(share=True) |