Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,13 +28,12 @@ def get_img_prediction(imgpath):
|
|
| 28 |
return y_pred_pro[0].tolist()
|
| 29 |
|
| 30 |
|
| 31 |
-
def get_text_prediction(
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
text = " ".join(text)
|
| 38 |
t_pred = get_inference(text)[0]
|
| 39 |
t_pred_c = []
|
| 40 |
for c in t_pred:
|
|
@@ -70,7 +69,7 @@ if image_file is not None:
|
|
| 70 |
|
| 71 |
with st.spinner('Predicting Label..'):
|
| 72 |
i_pred = get_img_prediction(temp_file.name)
|
| 73 |
-
t_pred = get_text_prediction(
|
| 74 |
y_pred_both = pred_label_mean(i_pred,t_pred)
|
| 75 |
y_pred = y_pred_both.index(max(y_pred_both))
|
| 76 |
|
|
|
|
| 28 |
return y_pred_pro[0].tolist()
|
| 29 |
|
| 30 |
|
| 31 |
+
def get_text_prediction(imgpath):
|
| 32 |
+
result = reader.readtext(imgpath,paragraph="False")
|
| 33 |
+
text = []
|
| 34 |
+
for i in result:
|
| 35 |
+
text.append(i[1])
|
| 36 |
+
text = " ".join(text)
|
|
|
|
| 37 |
t_pred = get_inference(text)[0]
|
| 38 |
t_pred_c = []
|
| 39 |
for c in t_pred:
|
|
|
|
| 69 |
|
| 70 |
with st.spinner('Predicting Label..'):
|
| 71 |
i_pred = get_img_prediction(temp_file.name)
|
| 72 |
+
t_pred = get_text_prediction(temp_file.name)
|
| 73 |
y_pred_both = pred_label_mean(i_pred,t_pred)
|
| 74 |
y_pred = y_pred_both.index(max(y_pred_both))
|
| 75 |
|