Spaces:
Running
Running
Fixed problem that cannot upload custom image
Browse files
app.py
CHANGED
|
@@ -58,16 +58,6 @@ def init_sidebar():
|
|
| 58 |
)
|
| 59 |
st.session_state["params"]["text_score"] = text_score
|
| 60 |
|
| 61 |
-
img_file_buffer = st.sidebar.file_uploader(
|
| 62 |
-
"Upload an image",
|
| 63 |
-
accept_multiple_files=False,
|
| 64 |
-
label_visibility="visible",
|
| 65 |
-
type=["png", "jpg", "jpeg", "bmp"],
|
| 66 |
-
)
|
| 67 |
-
if img_file_buffer:
|
| 68 |
-
image = Image.open(img_file_buffer)
|
| 69 |
-
img = np.array(image)
|
| 70 |
-
|
| 71 |
with st.sidebar.container():
|
| 72 |
img_path = image_select(
|
| 73 |
label="Examples(click to select):",
|
|
@@ -188,16 +178,29 @@ if __name__ == "__main__":
|
|
| 188 |
]
|
| 189 |
select_rec = menu_rec.selectbox("Rec model:", rec_models)
|
| 190 |
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
st.markdown(elapse)
|
| 198 |
-
st.dataframe(out_json, use_container_width=True)
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
)
|
| 59 |
st.session_state["params"]["text_score"] = text_score
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
with st.sidebar.container():
|
| 62 |
img_path = image_select(
|
| 63 |
label="Examples(click to select):",
|
|
|
|
| 178 |
]
|
| 179 |
select_rec = menu_rec.selectbox("Rec model:", rec_models)
|
| 180 |
|
| 181 |
+
img_file_buffer = st.file_uploader(
|
| 182 |
+
"Upload an image",
|
| 183 |
+
accept_multiple_files=False,
|
| 184 |
+
label_visibility="visible",
|
| 185 |
+
type=["png", "jpg", "jpeg", "bmp"],
|
| 186 |
+
)
|
|
|
|
|
|
|
| 187 |
|
| 188 |
+
if img_file_buffer:
|
| 189 |
+
image = Image.open(img_file_buffer)
|
| 190 |
+
img = np.array(image)
|
| 191 |
+
st.session_state["img"] = img
|
| 192 |
+
|
| 193 |
+
if st.session_state["img"] is not None:
|
| 194 |
+
out_img, out_json, elapse, only_txts = inference(select_det, select_rec)
|
| 195 |
+
if all(v is not None for v in [out_img, out_json, elapse]):
|
| 196 |
+
st.markdown("#### Visualize:")
|
| 197 |
+
st.image(out_img)
|
| 198 |
+
|
| 199 |
+
st.markdown("### Rec Result:")
|
| 200 |
+
st.markdown(elapse)
|
| 201 |
+
st.dataframe(out_json, use_container_width=True)
|
| 202 |
+
|
| 203 |
+
st.markdown("### Only Txts")
|
| 204 |
+
st.code(only_txts)
|
| 205 |
+
else:
|
| 206 |
+
tips("识别结果为空", wait_time=5, icon="⚠️")
|