Spaces:
Running
Running
deepsh2207
commited on
Commit
•
cdd9cb4
1
Parent(s):
383e64a
Removed heat map
Browse files
app.py
CHANGED
@@ -28,8 +28,8 @@ def main(det_archs, reco_archs):
|
|
28 |
cols = st.columns((1, 1, 1))
|
29 |
cols[0].subheader("Input page")
|
30 |
# cols[1].subheader("Segmentation heatmap")
|
31 |
-
cols[
|
32 |
-
cols[
|
33 |
|
34 |
# Sidebar
|
35 |
# File selection
|
@@ -74,27 +74,27 @@ def main(det_archs, reco_archs):
|
|
74 |
)
|
75 |
|
76 |
with st.spinner("Analyzing..."):
|
77 |
-
# Forward the image to the model
|
78 |
-
seg_map = forward_image(predictor, page, forward_device)
|
79 |
-
seg_map = np.squeeze(seg_map)
|
80 |
-
seg_map = cv2.resize(seg_map, (page.shape[1], page.shape[0]), interpolation=cv2.INTER_LINEAR)
|
81 |
-
|
82 |
-
# Plot the raw heatmap
|
83 |
-
fig, ax = plt.subplots()
|
84 |
-
ax.imshow(seg_map)
|
85 |
-
ax.axis("off")
|
86 |
-
cols[1].pyplot(fig)
|
87 |
|
88 |
# Plot OCR output
|
89 |
out = predictor([page])
|
90 |
fig = visualize_page(out.pages[0].export(), out.pages[0].page, interactive=False, add_labels=False)
|
91 |
-
cols[
|
92 |
|
93 |
# Page reconsitution under input page
|
94 |
page_export = out.pages[0].export()
|
95 |
if assume_straight_pages or (not assume_straight_pages and straighten_pages):
|
96 |
img = out.pages[0].synthesize()
|
97 |
-
cols[
|
98 |
|
99 |
# Display JSON
|
100 |
st.markdown("\nHere are your analysis results in JSON format:")
|
|
|
28 |
cols = st.columns((1, 1, 1))
|
29 |
cols[0].subheader("Input page")
|
30 |
# cols[1].subheader("Segmentation heatmap")
|
31 |
+
cols[1].subheader("OCR output")
|
32 |
+
cols[2].subheader("Page reconstitution")
|
33 |
|
34 |
# Sidebar
|
35 |
# File selection
|
|
|
74 |
)
|
75 |
|
76 |
with st.spinner("Analyzing..."):
|
77 |
+
# # Forward the image to the model
|
78 |
+
# seg_map = forward_image(predictor, page, forward_device)
|
79 |
+
# seg_map = np.squeeze(seg_map)
|
80 |
+
# seg_map = cv2.resize(seg_map, (page.shape[1], page.shape[0]), interpolation=cv2.INTER_LINEAR)
|
81 |
+
|
82 |
+
# # Plot the raw heatmap
|
83 |
+
# fig, ax = plt.subplots()
|
84 |
+
# ax.imshow(seg_map)
|
85 |
+
# ax.axis("off")
|
86 |
+
# cols[1].pyplot(fig)
|
87 |
|
88 |
# Plot OCR output
|
89 |
out = predictor([page])
|
90 |
fig = visualize_page(out.pages[0].export(), out.pages[0].page, interactive=False, add_labels=False)
|
91 |
+
cols[1].pyplot(fig)
|
92 |
|
93 |
# Page reconsitution under input page
|
94 |
page_export = out.pages[0].export()
|
95 |
if assume_straight_pages or (not assume_straight_pages and straighten_pages):
|
96 |
img = out.pages[0].synthesize()
|
97 |
+
cols[2].image(img, clamp=True)
|
98 |
|
99 |
# Display JSON
|
100 |
st.markdown("\nHere are your analysis results in JSON format:")
|