Remove overlap option
Browse filesThe generation is almost too slow on HF's hardware when running in default (no overlap) mode. Any other setting slows it down even further, so the best option here is no option :)
app.py
CHANGED
@@ -45,39 +45,20 @@ st.title(':memo: Swedish OCR correction')
|
|
45 |
tab1, tab2 = st.tabs(["Text input", "From file"])
|
46 |
|
47 |
|
48 |
-
# Initialize session
|
49 |
-
def clean_inputs():
|
50 |
-
st.session_state.inputs = {'tab1': None, 'tab2': None}
|
51 |
-
|
52 |
if 'inputs' not in st.session_state:
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
def clean_outputs():
|
57 |
-
st.session_state.outputs = {'tab1': None, 'tab2': None}
|
58 |
|
59 |
if 'outputs' not in st.session_state:
|
60 |
-
|
61 |
|
62 |
|
63 |
-
# Sidebar (
|
64 |
with st.sidebar:
|
65 |
-
|
66 |
-
st.header('Welcome')
|
67 |
st.markdown(info)
|
68 |
|
69 |
-
st.header('Settings')
|
70 |
-
overlap2candidates = {'None': 1, 'Little': 3, 'Much': 5}
|
71 |
-
overlap_help = '''Long texts are processed in chunks using a sliding window technique.
|
72 |
-
Here you can choose how much overlap the sliding window should have with the previous
|
73 |
-
processed chunk. No overlap is the fastest, but some overlap may increase accuracy.'''
|
74 |
-
overlap = st.selectbox(
|
75 |
-
'Overlap',
|
76 |
-
options=overlap2candidates,
|
77 |
-
help=overlap_help,
|
78 |
-
on_change=clean_inputs)
|
79 |
-
n_candidates = overlap2candidates[overlap]
|
80 |
-
|
81 |
|
82 |
def handle_input(input_, id_):
|
83 |
"""Generate and display output"""
|
@@ -90,7 +71,7 @@ def handle_input(input_, id_):
|
|
90 |
if input_ and st.session_state.inputs[id_] != input_:
|
91 |
st.session_state.inputs[id_] = input_
|
92 |
with st.spinner('Generating...'):
|
93 |
-
output = post_ocr.process(input_
|
94 |
st.session_state.outputs[id_] = output
|
95 |
|
96 |
# This container is needed to display the `show changes` toggle
|
|
|
45 |
tab1, tab2 = st.tabs(["Text input", "From file"])
|
46 |
|
47 |
|
48 |
+
# Initialize session states
|
|
|
|
|
|
|
49 |
if 'inputs' not in st.session_state:
|
50 |
+
st.session_state.inputs = {'tab1': None, 'tab2': None}
|
|
|
51 |
|
|
|
|
|
52 |
|
53 |
if 'outputs' not in st.session_state:
|
54 |
+
st.session_state.outputs = {'tab1': None, 'tab2': None}
|
55 |
|
56 |
|
57 |
+
# Sidebar (info)
|
58 |
with st.sidebar:
|
59 |
+
st.header('About')
|
|
|
60 |
st.markdown(info)
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
def handle_input(input_, id_):
|
64 |
"""Generate and display output"""
|
|
|
71 |
if input_ and st.session_state.inputs[id_] != input_:
|
72 |
st.session_state.inputs[id_] = input_
|
73 |
with st.spinner('Generating...'):
|
74 |
+
output = post_ocr.process(input_)
|
75 |
st.session_state.outputs[id_] = output
|
76 |
|
77 |
# This container is needed to display the `show changes` toggle
|