Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- app.py +12 -12
- backend/pytorch.py +3 -1
- backend/tensorflow.py +3 -1
- packages.txt +1 -0
app.py
CHANGED
@@ -71,15 +71,14 @@ def main(det_archs, reco_archs):
|
|
71 |
# Only straight pages or possible rotation
|
72 |
st.sidebar.title("Parameters")
|
73 |
assume_straight_pages = st.sidebar.checkbox("Assume straight pages", value=True)
|
74 |
-
st.sidebar.write("\n")
|
75 |
# Disable page orientation detection
|
76 |
disable_page_orientation = st.sidebar.checkbox("Disable page orientation detection", value=False)
|
77 |
-
st.sidebar.write("\n")
|
78 |
# Disable crop orientation detection
|
79 |
disable_crop_orientation = st.sidebar.checkbox("Disable crop orientation detection", value=False)
|
80 |
-
st.sidebar.write("\n")
|
81 |
# Straighten pages
|
82 |
straighten_pages = st.sidebar.checkbox("Straighten pages", value=False)
|
|
|
|
|
83 |
st.sidebar.write("\n")
|
84 |
# Binarization threshold
|
85 |
bin_thresh = st.sidebar.slider("Binarization threshold", min_value=0.1, max_value=0.9, value=0.3, step=0.1)
|
@@ -95,15 +94,16 @@ def main(det_archs, reco_archs):
|
|
95 |
else:
|
96 |
with st.spinner("Loading model..."):
|
97 |
predictor = load_predictor(
|
98 |
-
det_arch,
|
99 |
-
reco_arch,
|
100 |
-
assume_straight_pages,
|
101 |
-
straighten_pages,
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
107 |
)
|
108 |
|
109 |
with st.spinner("Analyzing..."):
|
|
|
71 |
# Only straight pages or possible rotation
|
72 |
st.sidebar.title("Parameters")
|
73 |
assume_straight_pages = st.sidebar.checkbox("Assume straight pages", value=True)
|
|
|
74 |
# Disable page orientation detection
|
75 |
disable_page_orientation = st.sidebar.checkbox("Disable page orientation detection", value=False)
|
|
|
76 |
# Disable crop orientation detection
|
77 |
disable_crop_orientation = st.sidebar.checkbox("Disable crop orientation detection", value=False)
|
|
|
78 |
# Straighten pages
|
79 |
straighten_pages = st.sidebar.checkbox("Straighten pages", value=False)
|
80 |
+
# Export as straight boxes
|
81 |
+
export_straight_boxes = st.sidebar.checkbox("Export as straight boxes", value=False)
|
82 |
st.sidebar.write("\n")
|
83 |
# Binarization threshold
|
84 |
bin_thresh = st.sidebar.slider("Binarization threshold", min_value=0.1, max_value=0.9, value=0.3, step=0.1)
|
|
|
94 |
else:
|
95 |
with st.spinner("Loading model..."):
|
96 |
predictor = load_predictor(
|
97 |
+
det_arch=det_arch,
|
98 |
+
reco_arch=reco_arch,
|
99 |
+
assume_straight_pages=assume_straight_pages,
|
100 |
+
straighten_pages=straighten_pages,
|
101 |
+
export_as_straight_boxes=export_straight_boxes,
|
102 |
+
disable_page_orientation=disable_page_orientation,
|
103 |
+
disable_crop_orientation=disable_crop_orientation,
|
104 |
+
bin_thresh=bin_thresh,
|
105 |
+
box_thresh=box_thresh,
|
106 |
+
device=forward_device,
|
107 |
)
|
108 |
|
109 |
with st.spinner("Analyzing..."):
|
backend/pytorch.py
CHANGED
@@ -37,6 +37,7 @@ def load_predictor(
|
|
37 |
reco_arch: str,
|
38 |
assume_straight_pages: bool,
|
39 |
straighten_pages: bool,
|
|
|
40 |
disable_page_orientation: bool,
|
41 |
disable_crop_orientation: bool,
|
42 |
bin_thresh: float,
|
@@ -51,6 +52,7 @@ def load_predictor(
|
|
51 |
reco_arch: recognition architecture
|
52 |
assume_straight_pages: whether to assume straight pages or not
|
53 |
straighten_pages: whether to straighten rotated pages or not
|
|
|
54 |
disable_page_orientation: whether to disable page orientation or not
|
55 |
disable_crop_orientation: whether to disable crop orientation or not
|
56 |
bin_thresh: binarization threshold for the segmentation map
|
@@ -67,7 +69,7 @@ def load_predictor(
|
|
67 |
pretrained=True,
|
68 |
assume_straight_pages=assume_straight_pages,
|
69 |
straighten_pages=straighten_pages,
|
70 |
-
export_as_straight_boxes=
|
71 |
detect_orientation=not assume_straight_pages,
|
72 |
disable_page_orientation=disable_page_orientation,
|
73 |
disable_crop_orientation=disable_crop_orientation,
|
|
|
37 |
reco_arch: str,
|
38 |
assume_straight_pages: bool,
|
39 |
straighten_pages: bool,
|
40 |
+
export_as_straight_boxes: bool,
|
41 |
disable_page_orientation: bool,
|
42 |
disable_crop_orientation: bool,
|
43 |
bin_thresh: float,
|
|
|
52 |
reco_arch: recognition architecture
|
53 |
assume_straight_pages: whether to assume straight pages or not
|
54 |
straighten_pages: whether to straighten rotated pages or not
|
55 |
+
export_as_straight_boxes: whether to export boxes as straight or not
|
56 |
disable_page_orientation: whether to disable page orientation or not
|
57 |
disable_crop_orientation: whether to disable crop orientation or not
|
58 |
bin_thresh: binarization threshold for the segmentation map
|
|
|
69 |
pretrained=True,
|
70 |
assume_straight_pages=assume_straight_pages,
|
71 |
straighten_pages=straighten_pages,
|
72 |
+
export_as_straight_boxes=export_as_straight_boxes,
|
73 |
detect_orientation=not assume_straight_pages,
|
74 |
disable_page_orientation=disable_page_orientation,
|
75 |
disable_crop_orientation=disable_crop_orientation,
|
backend/tensorflow.py
CHANGED
@@ -36,6 +36,7 @@ def load_predictor(
|
|
36 |
reco_arch: str,
|
37 |
assume_straight_pages: bool,
|
38 |
straighten_pages: bool,
|
|
|
39 |
disable_page_orientation: bool,
|
40 |
disable_crop_orientation: bool,
|
41 |
bin_thresh: float,
|
@@ -50,6 +51,7 @@ def load_predictor(
|
|
50 |
reco_arch: recognition architecture
|
51 |
assume_straight_pages: whether to assume straight pages or not
|
52 |
straighten_pages: whether to straighten rotated pages or not
|
|
|
53 |
disable_page_orientation: whether to disable page orientation or not
|
54 |
disable_crop_orientation: whether to disable crop orientation or not
|
55 |
bin_thresh: binarization threshold for the segmentation map
|
@@ -67,7 +69,7 @@ def load_predictor(
|
|
67 |
pretrained=True,
|
68 |
assume_straight_pages=assume_straight_pages,
|
69 |
straighten_pages=straighten_pages,
|
70 |
-
export_as_straight_boxes=
|
71 |
detect_orientation=not assume_straight_pages,
|
72 |
disable_page_orientation=disable_page_orientation,
|
73 |
disable_crop_orientation=disable_crop_orientation,
|
|
|
36 |
reco_arch: str,
|
37 |
assume_straight_pages: bool,
|
38 |
straighten_pages: bool,
|
39 |
+
export_as_straight_boxes: bool,
|
40 |
disable_page_orientation: bool,
|
41 |
disable_crop_orientation: bool,
|
42 |
bin_thresh: float,
|
|
|
51 |
reco_arch: recognition architecture
|
52 |
assume_straight_pages: whether to assume straight pages or not
|
53 |
straighten_pages: whether to straighten rotated pages or not
|
54 |
+
export_as_straight_boxes: whether to export boxes as straight or not
|
55 |
disable_page_orientation: whether to disable page orientation or not
|
56 |
disable_crop_orientation: whether to disable crop orientation or not
|
57 |
bin_thresh: binarization threshold for the segmentation map
|
|
|
69 |
pretrained=True,
|
70 |
assume_straight_pages=assume_straight_pages,
|
71 |
straighten_pages=straighten_pages,
|
72 |
+
export_as_straight_boxes=export_as_straight_boxes,
|
73 |
detect_orientation=not assume_straight_pages,
|
74 |
disable_page_orientation=disable_page_orientation,
|
75 |
disable_crop_orientation=disable_crop_orientation,
|
packages.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
python3-opencv
|
|
|
|
1 |
python3-opencv
|
2 |
+
fonts-freefont-ttf
|