Spaces:
Sleeping
Sleeping
ragavsachdeva
commited on
Commit
•
8cbc30d
1
Parent(s):
e3a827c
Update app.py
Browse files
app.py
CHANGED
@@ -83,24 +83,12 @@ input_character_character_matching_threshold = st.sidebar.slider('Character-char
|
|
83 |
input_text_character_matching_threshold = st.sidebar.slider('Text-character matching threshold', 0.0, 1.0, 0.4, step=0.01)
|
84 |
|
85 |
|
86 |
-
if path_to_image is None:
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
if generate_detections_and_associations or generate_transcript:
|
93 |
-
result = predict_detections_and_associations(
|
94 |
-
path_to_image,
|
95 |
-
input_character_detection_threshold,
|
96 |
-
input_panel_detection_threshold,
|
97 |
-
input_text_detection_threshold,
|
98 |
-
input_character_character_matching_threshold,
|
99 |
-
input_text_character_matching_threshold,
|
100 |
-
)
|
101 |
-
|
102 |
-
if generate_transcript:
|
103 |
-
ocr_results = predict_ocr(
|
104 |
path_to_image,
|
105 |
input_character_detection_threshold,
|
106 |
input_panel_detection_threshold,
|
@@ -108,21 +96,31 @@ if generate_transcript:
|
|
108 |
input_character_character_matching_threshold,
|
109 |
input_text_character_matching_threshold,
|
110 |
)
|
111 |
-
|
112 |
-
if
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
|
|
83 |
input_text_character_matching_threshold = st.sidebar.slider('Text-character matching threshold', 0.0, 1.0, 0.4, step=0.01)
|
84 |
|
85 |
|
86 |
+
if path_to_image is not None:
|
87 |
+
image = read_image_as_np_array(path_to_image)
|
88 |
+
|
89 |
+
st.markdown("**Prediction**")
|
90 |
+
if generate_detections_and_associations or generate_transcript:
|
91 |
+
result = predict_detections_and_associations(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
path_to_image,
|
93 |
input_character_detection_threshold,
|
94 |
input_panel_detection_threshold,
|
|
|
96 |
input_character_character_matching_threshold,
|
97 |
input_text_character_matching_threshold,
|
98 |
)
|
99 |
+
|
100 |
+
if generate_transcript:
|
101 |
+
ocr_results = predict_ocr(
|
102 |
+
path_to_image,
|
103 |
+
input_character_detection_threshold,
|
104 |
+
input_panel_detection_threshold,
|
105 |
+
input_text_detection_threshold,
|
106 |
+
input_character_character_matching_threshold,
|
107 |
+
input_text_character_matching_threshold,
|
108 |
+
)
|
109 |
+
|
110 |
+
if generate_detections_and_associations and generate_transcript:
|
111 |
+
col1, col2 = st.columns(2)
|
112 |
+
output = model.visualise_single_image_prediction(image, result)
|
113 |
+
col1.image(output)
|
114 |
+
text_bboxes_for_all_images = [result["texts"]]
|
115 |
+
ocr_results = model.predict_ocr([image], text_bboxes_for_all_images)
|
116 |
+
transcript = model.generate_transcript_for_single_image(result, ocr_results[0])
|
117 |
+
col2.text(transcript)
|
118 |
+
|
119 |
+
elif generate_detections_and_associations:
|
120 |
+
output = model.visualise_single_image_prediction(image, result)
|
121 |
+
st.image(output)
|
122 |
+
|
123 |
+
elif generate_transcript:
|
124 |
+
transcript = model.generate_transcript_for_single_image(result, ocr_results[0])
|
125 |
+
st.text(transcript)
|
126 |
|