Spaces:
Runtime error
Runtime error
medasaicharan2
commited on
Commit
•
1362446
1
Parent(s):
472ab9e
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ def pre_process(image, model_name):
|
|
44 |
img = image.convert("L")
|
45 |
|
46 |
# Select model based on the dropdown selection
|
47 |
-
if model_name == "
|
48 |
model = mnist_cnn_model
|
49 |
img = img.resize((28, 28))
|
50 |
img = np.array(img) / 255.0
|
@@ -52,7 +52,7 @@ def pre_process(image, model_name):
|
|
52 |
pred = model.predict(final_img)
|
53 |
result = np.argmax(pred)
|
54 |
return str(result)
|
55 |
-
elif model_name == "
|
56 |
model = mnist_mcdnn_model
|
57 |
img = img.resize((28, 28))
|
58 |
img = np.array(img) / 255.0
|
@@ -60,16 +60,16 @@ def pre_process(image, model_name):
|
|
60 |
pred = model.predict(final_img)
|
61 |
result = np.argmax(pred)
|
62 |
return str(result)
|
63 |
-
elif model_name == "OCR
|
64 |
pred = run(image)
|
65 |
return pred
|
66 |
-
elif model_name == "
|
67 |
return trocr_predict(image)
|
68 |
else:
|
69 |
return "Invalid model selection"
|
70 |
|
71 |
# Defining model options for dropdown
|
72 |
-
model_options = ["
|
73 |
|
74 |
|
75 |
with gr.Blocks() as demo:
|
|
|
44 |
img = image.convert("L")
|
45 |
|
46 |
# Select model based on the dropdown selection
|
47 |
+
if model_name == "Simple CNN":
|
48 |
model = mnist_cnn_model
|
49 |
img = img.resize((28, 28))
|
50 |
img = np.array(img) / 255.0
|
|
|
52 |
pred = model.predict(final_img)
|
53 |
result = np.argmax(pred)
|
54 |
return str(result)
|
55 |
+
elif model_name == "MCDNN":
|
56 |
model = mnist_mcdnn_model
|
57 |
img = img.resize((28, 28))
|
58 |
img = np.array(img) / 255.0
|
|
|
60 |
pred = model.predict(final_img)
|
61 |
result = np.argmax(pred)
|
62 |
return str(result)
|
63 |
+
elif model_name == "OCR":
|
64 |
pred = run(image)
|
65 |
return pred
|
66 |
+
elif model_name == "CNN BI-LSTM":
|
67 |
return trocr_predict(image)
|
68 |
else:
|
69 |
return "Invalid model selection"
|
70 |
|
71 |
# Defining model options for dropdown
|
72 |
+
model_options = ["Simple CNN", "MCDNN", "OCR", "CNN BI-LSTM"]
|
73 |
|
74 |
|
75 |
with gr.Blocks() as demo:
|