Spaces:
Sleeping
Sleeping
bug fix
Browse files- app.py +6 -0
- src/transcribe_image.py +2 -2
app.py
CHANGED
@@ -70,7 +70,13 @@ if st.button("Process Essays"):
|
|
70 |
else:
|
71 |
st.text("Processing essays...This may take a few seconds.")
|
72 |
st.text("A download button will appear underneath once the process is complete.")
|
|
|
|
|
|
|
|
|
73 |
uploaded_files = sorted(uploaded_files, key=lambda x: x.name)
|
|
|
|
|
74 |
# Process student info file
|
75 |
workbook = load_workbook(excel_file)
|
76 |
|
|
|
70 |
else:
|
71 |
st.text("Processing essays...This may take a few seconds.")
|
72 |
st.text("A download button will appear underneath once the process is complete.")
|
73 |
+
# assert that no duplicate files are uploaded
|
74 |
+
uploaded_files_names = [file.name for file in uploaded_files]
|
75 |
+
assert len(uploaded_files_names) == len(set(uploaded_files_names)), "Duplicate images uploaded. Please ensure that each image is only uploaded once."
|
76 |
+
|
77 |
uploaded_files = sorted(uploaded_files, key=lambda x: x.name)
|
78 |
+
|
79 |
+
print(uploaded_files)
|
80 |
# Process student info file
|
81 |
workbook = load_workbook(excel_file)
|
82 |
|
src/transcribe_image.py
CHANGED
@@ -8,7 +8,7 @@ def resize_image(image, max_size=800):
|
|
8 |
"""Resize the image to ensure the max side length is `max_size` while maintaining aspect ratio."""
|
9 |
# Open the image using Pillow
|
10 |
img = Image.open(image)
|
11 |
-
|
12 |
# Get the current width and height of the image
|
13 |
width, height = img.size
|
14 |
|
@@ -22,7 +22,7 @@ def resize_image(image, max_size=800):
|
|
22 |
|
23 |
# Resize the image using the LANCZOS filter for high-quality rescaling
|
24 |
img = img.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
25 |
-
|
26 |
# Save the resized image to a BytesIO object to later encode to base64
|
27 |
img_byte_arr = io.BytesIO()
|
28 |
img.save(img_byte_arr, format='PNG')
|
|
|
8 |
"""Resize the image to ensure the max side length is `max_size` while maintaining aspect ratio."""
|
9 |
# Open the image using Pillow
|
10 |
img = Image.open(image)
|
11 |
+
print(img.size)
|
12 |
# Get the current width and height of the image
|
13 |
width, height = img.size
|
14 |
|
|
|
22 |
|
23 |
# Resize the image using the LANCZOS filter for high-quality rescaling
|
24 |
img = img.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
25 |
+
print('after resizing', img.size)
|
26 |
# Save the resized image to a BytesIO object to later encode to base64
|
27 |
img_byte_arr = io.BytesIO()
|
28 |
img.save(img_byte_arr, format='PNG')
|