Spaces:
Runtime error
Runtime error
NassimeBejaia
commited on
Commit
•
6b8ee3c
1
Parent(s):
ab96962
Update app.py
Browse files
app.py
CHANGED
@@ -19,11 +19,6 @@ import tempfile
|
|
19 |
import subprocess
|
20 |
|
21 |
|
22 |
-
# @st.cache(allow_output_mutation=True)
|
23 |
-
# # @st.cache_resource(allow_output_mutation=True)
|
24 |
-
# def get_model():
|
25 |
-
# return load_model()
|
26 |
-
|
27 |
# Load the OCR model outside the function to prevent reloading it every time
|
28 |
ocr_model = load_model()
|
29 |
|
@@ -180,27 +175,6 @@ def download_ultralytics_yolov3_folder():
|
|
180 |
st.text("Download and extraction completed!")
|
181 |
|
182 |
|
183 |
-
def get_detected_boxes(txt_path, img_width, img_height):
|
184 |
-
with open(txt_path, 'r') as f:
|
185 |
-
lines = f.readlines()
|
186 |
-
boxes = []
|
187 |
-
for line in lines:
|
188 |
-
parts = list(map(float, line.strip().split()))
|
189 |
-
# Assuming the format is: class x_center y_center width height confidence
|
190 |
-
x_center, y_center, width, height = parts[1:5]
|
191 |
-
|
192 |
-
# Convert to pixel values
|
193 |
-
x_center *= img_width
|
194 |
-
y_center *= img_height
|
195 |
-
width *= img_width
|
196 |
-
height *= img_height
|
197 |
-
|
198 |
-
boxes.append([x_center, y_center, width, height])
|
199 |
-
|
200 |
-
return boxes
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
def process_with_yolo(img_pil):
|
205 |
|
206 |
|
@@ -309,12 +283,6 @@ def display_detected_lines(original_path, output_path):
|
|
309 |
|
310 |
|
311 |
|
312 |
-
def crop_detected_line(img_path, bounding_box):
|
313 |
-
with Image.open(img_path) as img:
|
314 |
-
cropped_img = img.crop(bounding_box)
|
315 |
-
return cropped_img
|
316 |
-
|
317 |
-
|
318 |
def perform_ocr_on_detected_lines(detected_line_paths):
|
319 |
"""
|
320 |
Performs OCR on the provided list of detected line image paths.
|
|
|
19 |
import subprocess
|
20 |
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
# Load the OCR model outside the function to prevent reloading it every time
|
23 |
ocr_model = load_model()
|
24 |
|
|
|
175 |
st.text("Download and extraction completed!")
|
176 |
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
def process_with_yolo(img_pil):
|
179 |
|
180 |
|
|
|
283 |
|
284 |
|
285 |
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
def perform_ocr_on_detected_lines(detected_line_paths):
|
287 |
"""
|
288 |
Performs OCR on the provided list of detected line image paths.
|