Spaces:
Runtime error
Runtime error
Commit ·
bbf2928
0
Parent(s):
Initial commit for HF
Browse files- .gitignore +25 -0
- app.py +51 -0
- packages.txt +2 -0
- requirements.txt +3 -0
.gitignore
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Virtual Environment
|
| 2 |
+
venv/
|
| 3 |
+
.venv/
|
| 4 |
+
ENV/
|
| 5 |
+
|
| 6 |
+
# Python
|
| 7 |
+
__pycache__/
|
| 8 |
+
*.py[cod]
|
| 9 |
+
*$py.class
|
| 10 |
+
*.pyd
|
| 11 |
+
*.so
|
| 12 |
+
*.dll
|
| 13 |
+
|
| 14 |
+
# Distribution / packaging
|
| 15 |
+
dist/
|
| 16 |
+
build/
|
| 17 |
+
*.egg-info/
|
| 18 |
+
|
| 19 |
+
# IDE settings
|
| 20 |
+
.vscode/
|
| 21 |
+
.idea/
|
| 22 |
+
|
| 23 |
+
# Misc
|
| 24 |
+
*.log
|
| 25 |
+
.env
|
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from modal import Function
|
| 4 |
+
|
| 5 |
+
def main():
|
| 6 |
+
st.title("Financial Statement Analyzer")
|
| 7 |
+
|
| 8 |
+
uploaded_files = st.file_uploader(
|
| 9 |
+
"Choose PDF files",
|
| 10 |
+
type="pdf",
|
| 11 |
+
accept_multiple_files=True,
|
| 12 |
+
help="Upload Consolidated Financial Statements in Russian"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
if uploaded_files:
|
| 16 |
+
for file in uploaded_files:
|
| 17 |
+
with st.expander(f"Processing {file.name}", expanded=True):
|
| 18 |
+
progress_bar = st.progress(0)
|
| 19 |
+
status = st.empty()
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
status.info("Starting PDF processing...")
|
| 23 |
+
progress_bar.progress(25)
|
| 24 |
+
|
| 25 |
+
# Process PDF through Modal backend
|
| 26 |
+
pdf_processor = Function.lookup("stem", "process_pdf")
|
| 27 |
+
financial_data = pdf_processor.remote(file)
|
| 28 |
+
progress_bar.progress(75)
|
| 29 |
+
|
| 30 |
+
if financial_data:
|
| 31 |
+
# Display results in tabs
|
| 32 |
+
tab1, tab2 = st.tabs(["Financial Ratios", "Raw Data"])
|
| 33 |
+
|
| 34 |
+
with tab1:
|
| 35 |
+
st.subheader("Key Financial Ratios")
|
| 36 |
+
st.dataframe(pd.DataFrame([financial_data]))
|
| 37 |
+
|
| 38 |
+
with tab2:
|
| 39 |
+
st.subheader("Extracted Financial Data")
|
| 40 |
+
st.json(financial_data)
|
| 41 |
+
|
| 42 |
+
status.success("Processing complete!")
|
| 43 |
+
else:
|
| 44 |
+
status.error("Failed to extract financial data")
|
| 45 |
+
|
| 46 |
+
except Exception as e:
|
| 47 |
+
status.error(f"Error: {str(e)}")
|
| 48 |
+
progress_bar.empty()
|
| 49 |
+
|
| 50 |
+
if __name__ == "__main__":
|
| 51 |
+
main()
|
packages.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
poppler-utils
|
| 2 |
+
git
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
modal>=0.56.4
|
| 2 |
+
streamlit>=1.32.0
|
| 3 |
+
pandas>=2.2.0
|