Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,9 @@ from utils import (
|
|
7 |
csv_to_dataframe,
|
8 |
save_csv,
|
9 |
get_pdf_metadata,
|
10 |
-
extract_csv_from_response
|
|
|
|
|
11 |
)
|
12 |
import base64
|
13 |
from datetime import datetime
|
@@ -93,7 +95,7 @@ with st.sidebar:
|
|
93 |
st.markdown("---")
|
94 |
st.info("""
|
95 |
**Features:**
|
96 |
-
-
|
97 |
- Individual analysis for each document
|
98 |
- Downloadable CSV reports
|
99 |
""")
|
@@ -126,11 +128,17 @@ if uploaded_files and api_key:
|
|
126 |
with st.spinner(f"Analyzing {uploaded_file.name}..."):
|
127 |
try:
|
128 |
# Analyze PDF directly
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
# Process response
|
136 |
csv_data = extract_csv_from_response(raw_response)
|
@@ -139,8 +147,9 @@ if uploaded_files and api_key:
|
|
139 |
with st.expander("View Analysis Results", expanded=True):
|
140 |
if csv_data:
|
141 |
df = csv_to_dataframe(csv_data)
|
|
|
142 |
if not df.empty:
|
143 |
-
st.dataframe(df
|
144 |
|
145 |
# Download button
|
146 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
|
7 |
csv_to_dataframe,
|
8 |
save_csv,
|
9 |
get_pdf_metadata,
|
10 |
+
extract_csv_from_response,
|
11 |
+
pdf_to_images,
|
12 |
+
analyze_single_document
|
13 |
)
|
14 |
import base64
|
15 |
from datetime import datetime
|
|
|
95 |
st.markdown("---")
|
96 |
st.info("""
|
97 |
**Features:**
|
98 |
+
- PDF processing using images partitioned by page
|
99 |
- Individual analysis for each document
|
100 |
- Downloadable CSV reports
|
101 |
""")
|
|
|
128 |
with st.spinner(f"Analyzing {uploaded_file.name}..."):
|
129 |
try:
|
130 |
# Analyze PDF directly
|
131 |
+
# Convert PDF to images
|
132 |
+
images = pdf_to_images(uploaded_file.getvalue())
|
133 |
+
|
134 |
+
# Analyze document
|
135 |
+
raw_response = analyze_single_document(images, PROMPT)
|
136 |
+
|
137 |
+
# raw_response = analyze_pdf_directly(
|
138 |
+
# pdf_bytes=uploaded_file.getvalue(),
|
139 |
+
# prompt=PROMPT,
|
140 |
+
# model_name="gemini-1.5-pro" # or "gemini-1.5-flash"
|
141 |
+
# )
|
142 |
|
143 |
# Process response
|
144 |
csv_data = extract_csv_from_response(raw_response)
|
|
|
147 |
with st.expander("View Analysis Results", expanded=True):
|
148 |
if csv_data:
|
149 |
df = csv_to_dataframe(csv_data)
|
150 |
+
print(f"DataFrame: {df}")
|
151 |
if not df.empty:
|
152 |
+
st.dataframe(df)
|
153 |
|
154 |
# Download button
|
155 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|