Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from main import read_number_plate, add_text, add_rect
|
| 4 |
+
from detection import resize
|
| 5 |
+
|
| 6 |
+
def predict_fn(im):
|
| 7 |
+
im = resize(im)
|
| 8 |
+
|
| 9 |
+
boxes, texts = read_number_plate(im)
|
| 10 |
+
print(texts)
|
| 11 |
+
for box, text in zip(boxes, texts):
|
| 12 |
+
im = add_rect(im, *box)
|
| 13 |
+
im = add_text(im, text, box)
|
| 14 |
+
return im
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=predict_fn,
|
| 19 |
+
inputs=[gr.inputs.Image(label="Input Image")],
|
| 20 |
+
outputs=[gr.inputs.Image(label="Prediction")],
|
| 21 |
+
title="Emotion Recognition Demo",
|
| 22 |
+
description="Emotion Classification Model trained on FER Dataset",
|
| 23 |
+
examples=[
|
| 24 |
+
["example/car1.jpg"],
|
| 25 |
+
["example/car2.jpg"],
|
| 26 |
+
["example/car3.jpg"]
|
| 27 |
+
],
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
demo.launch()
|