Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import time
|
|
| 9 |
# Configuration - Get API key from Streamlit secrets
|
| 10 |
GEMINI_API_KEY = st.secrets["GEMINI_API_KEY"]
|
| 11 |
GEMINI_MODEL = "gemini-2.0-flash"
|
| 12 |
-
DOCUMENT_TYPES = ["Land Records", "Caste Certificates", "Property Registrations"]
|
| 13 |
|
| 14 |
# Initialize session state (excluding widget-controlled keys)
|
| 15 |
def initialize_session_state():
|
|
@@ -139,7 +139,7 @@ def process_document():
|
|
| 139 |
details = query_gemini(extract_prompt, image_b64)
|
| 140 |
|
| 141 |
# Verify authenticity
|
| 142 |
-
verify_prompt = "Analyze this document for signs of tampering. Provide verification status."
|
| 143 |
verification = query_gemini(verify_prompt, image_b64)
|
| 144 |
|
| 145 |
st.session_state.processed_doc = {
|
|
@@ -163,6 +163,11 @@ def main():
|
|
| 163 |
# Sidebar Controls
|
| 164 |
with st.sidebar:
|
| 165 |
st.header("Document Controls")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
# The file uploader widget manages its own state with key "uploaded_file"
|
| 167 |
st.file_uploader(
|
| 168 |
"Upload Document",
|
|
@@ -185,7 +190,7 @@ def main():
|
|
| 185 |
# Main Interface
|
| 186 |
st.title("📄 Automated Document Verifier")
|
| 187 |
|
| 188 |
-
if st.session_state.get("processed_doc")
|
| 189 |
col1, col2 = st.columns([1, 2])
|
| 190 |
with col1:
|
| 191 |
st.subheader("Document Preview")
|
|
|
|
| 9 |
# Configuration - Get API key from Streamlit secrets
|
| 10 |
GEMINI_API_KEY = st.secrets["GEMINI_API_KEY"]
|
| 11 |
GEMINI_MODEL = "gemini-2.0-flash"
|
| 12 |
+
DOCUMENT_TYPES = ["Land Records", "Caste Certificates", "Property Registrations", "Others"]
|
| 13 |
|
| 14 |
# Initialize session state (excluding widget-controlled keys)
|
| 15 |
def initialize_session_state():
|
|
|
|
| 139 |
details = query_gemini(extract_prompt, image_b64)
|
| 140 |
|
| 141 |
# Verify authenticity
|
| 142 |
+
verify_prompt = "Analyze this document for signs of tampering. Provide verification status in short (2 Lines)."
|
| 143 |
verification = query_gemini(verify_prompt, image_b64)
|
| 144 |
|
| 145 |
st.session_state.processed_doc = {
|
|
|
|
| 163 |
# Sidebar Controls
|
| 164 |
with st.sidebar:
|
| 165 |
st.header("Document Controls")
|
| 166 |
+
# If a document preview exists, show it above the upload button
|
| 167 |
+
if st.session_state.get("doc_preview"):
|
| 168 |
+
st.subheader("Document Preview")
|
| 169 |
+
st.image(st.session_state.doc_preview, use_column_width=True)
|
| 170 |
+
|
| 171 |
# The file uploader widget manages its own state with key "uploaded_file"
|
| 172 |
st.file_uploader(
|
| 173 |
"Upload Document",
|
|
|
|
| 190 |
# Main Interface
|
| 191 |
st.title("📄 Automated Document Verifier")
|
| 192 |
|
| 193 |
+
if st.session_state.get("processed_doc"):
|
| 194 |
col1, col2 = st.columns([1, 2])
|
| 195 |
with col1:
|
| 196 |
st.subheader("Document Preview")
|