Spaces:
Sleeping
Sleeping
Added application
Browse files- main.py +23 -0
- model_1.h5 +3 -0
- requirements.txt +4 -0
main.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
from tensorflow.keras.models import load_model
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import numpy as np
|
| 5 |
+
import cv2
|
| 6 |
+
|
| 7 |
+
model = load_model("model_1.h5")
|
| 8 |
+
|
| 9 |
+
labels = ["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thrteen","fourteen","fifteen","sixteen","seventeen","eightteen","nineteen"]
|
| 10 |
+
|
| 11 |
+
def predict(img):
|
| 12 |
+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 13 |
+
resized = cv2.resize(gray, (64, 64))
|
| 14 |
+
reshaped = resized.reshape(1, 64, 64, 1)
|
| 15 |
+
out = model.predict(reshaped)
|
| 16 |
+
cls = labels[out.argmax()]
|
| 17 |
+
return cls
|
| 18 |
+
|
| 19 |
+
ui = gr.Interface(
|
| 20 |
+
fn=predict,
|
| 21 |
+
inputs=gr.Image(type="numpy"),
|
| 22 |
+
outputs=gr.Textbox()
|
| 23 |
+
)
|
model_1.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cf6ba496976fbc39fc512ec182deef1ee742f16f804c567e60ccb15e6f617976
|
| 3 |
+
size 9354040
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tensorflow
|
| 2 |
+
gradio
|
| 3 |
+
opencv-python
|
| 4 |
+
numpy
|