Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,9 @@ from tensorflow.keras.preprocessing import image
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
from keras.models import load_model
|
5 |
|
6 |
-
def load_image(
|
7 |
-
|
8 |
-
img = image.load_img(img_path, target_size=(224, 224))
|
9 |
img_tensor = image.img_to_array(img)
|
10 |
img_tensor = np.expand_dims(img_tensor, axis=0)
|
11 |
img_tensor /= 255
|
@@ -21,10 +21,10 @@ def run_model(img):
|
|
21 |
model = load_model("res.h5")
|
22 |
|
23 |
#img_path = '/content/Indian/9/1020.jpg'
|
24 |
-
|
25 |
#result = model.predict(new_image)
|
26 |
classes = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
27 |
-
img = img.reshape((-1, 224, 224, 3))
|
28 |
result = model.predict(img)
|
29 |
results = dict(zip(classes, result[0]))
|
30 |
return max(results, key = results.get)
|
@@ -35,4 +35,4 @@ examples = ['5.jpg','9.jpg','A.jpg','L.jpg','P.jpg']
|
|
35 |
|
36 |
|
37 |
import gradio as gr
|
38 |
-
gr.Interface(fn=run_model, inputs=gr.inputs.Image(
|
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
from keras.models import load_model
|
5 |
|
6 |
+
def load_image(img, show=False):
|
7 |
+
img = img.reshape((-1, 224, 224, 3))
|
8 |
+
#img = image.load_img(img_path, target_size=(224, 224))
|
9 |
img_tensor = image.img_to_array(img)
|
10 |
img_tensor = np.expand_dims(img_tensor, axis=0)
|
11 |
img_tensor /= 255
|
|
|
21 |
model = load_model("res.h5")
|
22 |
|
23 |
#img_path = '/content/Indian/9/1020.jpg'
|
24 |
+
new_image = load_image(img)
|
25 |
#result = model.predict(new_image)
|
26 |
classes = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
27 |
+
#img = img.reshape((-1, 224, 224, 3))
|
28 |
result = model.predict(img)
|
29 |
results = dict(zip(classes, result[0]))
|
30 |
return max(results, key = results.get)
|
|
|
35 |
|
36 |
|
37 |
import gradio as gr
|
38 |
+
gr.Interface(fn=run_model, inputs=gr.inputs.Image(), outputs='text', title=title, description=description, examples=examples).launch()
|