Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
from glob import glob
|
5 |
+
from models import Yolov4
|
6 |
+
import gradio as gr
|
7 |
+
model = Yolov4(weight_path="yolov4.weights", class_name_path='coco_classes.txt')
|
8 |
+
def gradio_wrapper(img):
|
9 |
+
global model
|
10 |
+
#print(np.shape(img))
|
11 |
+
results = model.predict(img)
|
12 |
+
return results[0]
|
13 |
+
demo = gr.Interface(
|
14 |
+
gradio_wrapper,
|
15 |
+
#gr.Image(source="webcam", streaming=True, flip=True),
|
16 |
+
gr.Image(source="webcam", streaming=True),
|
17 |
+
"image",
|
18 |
+
live=True
|
19 |
+
)
|
20 |
+
|
21 |
+
demo.launch()
|