Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uploadfile.read() empty bug #18

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app_doctr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import streamlit as st

from msfocr.data import dhis2
from msfocr.data import ocr_functions
from msfocr.doctr import ocr_functions

def configure_secrets():
"""Checks that necessary environment variables are set for fast failing.
Expand Down Expand Up @@ -156,7 +156,12 @@ def get_uploaded_images(tally_sheet):
:param Files uploaded by user
:return List of images uploaded by user as docTR DocumentFiles
"""
return [DocumentFile.from_images(sheet.read()) for sheet in tally_sheet]
res = []
for sheet in tally_sheet:
sheet.seek(0, 0)
image = sheet.read()
res.append(DocumentFile.from_images(image))
return res

@st.cache_data
def get_results(uploaded_images):
Expand Down Expand Up @@ -292,14 +297,15 @@ def get_period():
if 'table_dfs' in st.session_state:
del st.session_state['table_dfs']
st.rerun()

uploaded_images = get_uploaded_images(tally_sheet)
results = get_results(uploaded_images)

### CORRECT THIS TO ALLOW PROCESSING OF ALL IMAGES
# ***************************************
image = uploaded_images[0]
result = results[0]
print(result)
# ***************************************

# form_type looks like [dataSet, orgUnit, period=[startDate, endDate]]
Expand Down
Loading