milwright commited on
Commit
4585f4e
·
1 Parent(s): 7647e70

Update UI components based on feedback: remove performance mode, make preprocessing sections collapsible, reduce title size, decenter Mistral AI credit

Browse files
Files changed (1) hide show
  1. ui_components.py +50 -62
ui_components.py CHANGED
@@ -72,11 +72,6 @@ def create_sidebar_options():
72
  st.subheader("Model Selection")
73
  use_vision = st.toggle("Use Vision Model", value=True, help="Use vision model for better understanding of document structure")
74
 
75
- # Performance mode
76
- perf_mode = st.radio("Performance Mode", PERFORMANCE_MODES,
77
- horizontal=True,
78
- help="Quality: Best results but slower. Speed: Faster but may be less accurate.")
79
-
80
  # Document type selection
81
  st.subheader("Document Type")
82
  doc_type = st.selectbox("Document Type", DOCUMENT_TYPES,
@@ -107,74 +102,67 @@ def create_sidebar_options():
107
  help="Customize the instructions for processing this document",
108
  height=100)
109
 
110
- # Image preprocessing options
111
- st.subheader("Image Preprocessing")
112
-
113
- # Document type for preprocessing
114
- preprocessing_doc_type = st.radio("Document Type",
115
- PREPROCESSING_DOC_TYPES,
116
- horizontal=True,
117
- help="Select the type of document for preprocessing")
118
-
119
- # Grayscale conversion
120
- grayscale = st.checkbox("Convert to Grayscale",
121
- value=False,
122
- help="Convert color images to grayscale for better OCR")
123
-
124
- # Denoise
125
- denoise = st.checkbox("Denoise Image",
126
- value=False,
127
- help="Remove noise from the image")
128
-
129
- # Contrast adjustment
130
- contrast = st.slider("Contrast Adjustment",
131
- min_value=-50,
132
- max_value=50,
133
- value=0,
134
- step=10,
135
- help="Adjust image contrast")
136
-
137
- # Rotation
138
- rotation = st.slider("Rotation",
139
- min_value=-45,
140
- max_value=45,
141
- value=0,
142
- step=5,
143
- help="Rotate image if needed")
144
 
145
  # Create preprocessing options dictionary
146
  preprocessing_options = {
147
- "document_type": preprocessing_doc_type,
148
  "grayscale": grayscale,
149
  "denoise": denoise,
150
  "contrast": contrast,
151
  "rotation": rotation
152
  }
153
 
154
- # PDF-specific options
155
- st.subheader("PDF Options")
156
- pdf_dpi = st.slider("PDF Resolution (DPI)",
157
- min_value=MIN_PDF_DPI,
158
- max_value=MAX_PDF_DPI,
159
- value=DEFAULT_PDF_DPI,
160
- step=25,
161
- help="Higher DPI gives better quality but slower processing")
162
-
163
- max_pages = st.number_input("Maximum Pages to Process",
164
- min_value=1,
165
- max_value=20,
166
- value=DEFAULT_MAX_PAGES,
167
- help="Limit the number of pages to process (for multi-page PDFs)")
168
-
169
- pdf_rotation = st.radio("PDF Rotation", ROTATION_OPTIONS,
170
- horizontal=True,
171
- format_func=lambda x: f"{x}°",
172
- help="Rotate PDF pages if needed")
173
 
174
  # Create options dictionary
175
  options = {
176
  "use_vision": use_vision,
177
- "perf_mode": perf_mode,
178
  "pdf_dpi": pdf_dpi,
179
  "max_pages": max_pages,
180
  "pdf_rotation": pdf_rotation,
@@ -189,8 +177,8 @@ def create_file_uploader():
189
  # Add app description
190
  favicon_path = os.path.join(os.path.dirname(__file__), "static/favicon.png")
191
  favicon_base64 = get_base64_from_image(favicon_path)
192
- st.markdown(f'<div style="display: flex; align-items: center; gap: 10px;"><img src="data:image/png;base64,{favicon_base64}" width="36" height="36" alt="Scroll Icon"/> <div><h1 style="margin: 0; padding: 20px 0 0 0;">Historical Document OCR</h1></div></div>', unsafe_allow_html=True)
193
- st.subheader("Made possible by Mistral AI")
194
 
195
  # Add project framing
196
  st.markdown("""
 
72
  st.subheader("Model Selection")
73
  use_vision = st.toggle("Use Vision Model", value=True, help="Use vision model for better understanding of document structure")
74
 
 
 
 
 
 
75
  # Document type selection
76
  st.subheader("Document Type")
77
  doc_type = st.selectbox("Document Type", DOCUMENT_TYPES,
 
102
  help="Customize the instructions for processing this document",
103
  height=100)
104
 
105
+ # Image preprocessing options in an expandable section
106
+ with st.expander("Image Preprocessing"):
107
+ # Grayscale conversion
108
+ grayscale = st.checkbox("Convert to Grayscale",
109
+ value=False,
110
+ help="Convert color images to grayscale for better OCR")
111
+
112
+ # Denoise
113
+ denoise = st.checkbox("Denoise Image",
114
+ value=False,
115
+ help="Remove noise from the image")
116
+
117
+ # Contrast adjustment
118
+ contrast = st.slider("Contrast Adjustment",
119
+ min_value=-50,
120
+ max_value=50,
121
+ value=0,
122
+ step=10,
123
+ help="Adjust image contrast")
124
+
125
+ # Rotation
126
+ rotation = st.slider("Rotation",
127
+ min_value=-45,
128
+ max_value=45,
129
+ value=0,
130
+ step=5,
131
+ help="Rotate image if needed")
 
 
 
 
 
 
 
132
 
133
  # Create preprocessing options dictionary
134
  preprocessing_options = {
135
+ "document_type": "standard", # Use standard as default, removed duplicate option
136
  "grayscale": grayscale,
137
  "denoise": denoise,
138
  "contrast": contrast,
139
  "rotation": rotation
140
  }
141
 
142
+ # PDF-specific options in an expandable section
143
+ with st.expander("PDF Options"):
144
+ pdf_dpi = st.slider("PDF Resolution (DPI)",
145
+ min_value=MIN_PDF_DPI,
146
+ max_value=MAX_PDF_DPI,
147
+ value=DEFAULT_PDF_DPI,
148
+ step=25,
149
+ help="Higher DPI gives better quality but slower processing")
150
+
151
+ max_pages = st.number_input("Maximum Pages to Process",
152
+ min_value=1,
153
+ max_value=20,
154
+ value=DEFAULT_MAX_PAGES,
155
+ help="Limit the number of pages to process (for multi-page PDFs)")
156
+
157
+ pdf_rotation = st.radio("PDF Rotation", ROTATION_OPTIONS,
158
+ horizontal=True,
159
+ format_func=lambda x: f"{x}°",
160
+ help="Rotate PDF pages if needed")
161
 
162
  # Create options dictionary
163
  options = {
164
  "use_vision": use_vision,
165
+ "perf_mode": "Quality", # Default to Quality, removed performance mode option
166
  "pdf_dpi": pdf_dpi,
167
  "max_pages": max_pages,
168
  "pdf_rotation": pdf_rotation,
 
177
  # Add app description
178
  favicon_path = os.path.join(os.path.dirname(__file__), "static/favicon.png")
179
  favicon_base64 = get_base64_from_image(favicon_path)
180
+ st.markdown(f'<div style="display: flex; align-items: center; gap: 10px;"><img src="data:image/png;base64,{favicon_base64}" width="36" height="36" alt="Scroll Icon"/> <div><h2 style="margin: 0; padding: 10px 0 0 0;">Historical Document OCR</h2></div></div>', unsafe_allow_html=True)
181
+ st.markdown("<p style='font-size: 0.8em; color: #666; text-align: right;'>Made possible by Mistral AI</p>", unsafe_allow_html=True)
182
 
183
  # Add project framing
184
  st.markdown("""