Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import requests
|
|
@@ -25,19 +24,34 @@ if 'server_started' not in st.session_state:
|
|
| 25 |
if not st.session_state['server_started']:
|
| 26 |
start_server()
|
| 27 |
|
| 28 |
-
st.title(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
if image_path is not None:
|
| 33 |
-
st.image(image_path, caption="Uploaded Image.", use_column_width=True)
|
| 34 |
-
st.write("")
|
| 35 |
-
st.write("Classifying...")
|
| 36 |
|
| 37 |
-
with
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
import requests
|
|
|
|
| 24 |
if not st.session_state['server_started']:
|
| 25 |
start_server()
|
| 26 |
|
| 27 |
+
st.sidebar.title("Server Status")
|
| 28 |
+
st.sidebar.write("🟢 Server is running" if st.session_state['server_started'] else "🔴 Server is not running")
|
| 29 |
+
|
| 30 |
+
st.title('Passport Recognition with passportEYE, paddleocr and a LLM')
|
| 31 |
+
|
| 32 |
+
upload_option = st.radio("Select Image Source", ("Upload Image", "Load Example Image"), index=0)
|
| 33 |
|
| 34 |
+
if upload_option == "Load Example Image":
|
| 35 |
+
image_path = "sample.jpg"
|
| 36 |
+
else:
|
| 37 |
+
image_path = st.file_uploader("Upload Passport Image", type=["jpg", "jpeg", "png"], key="image_uploader")
|
| 38 |
|
| 39 |
+
if image_path is not None and st.button("Read Passport"):
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
with st.spinner("Running..."):
|
| 42 |
+
if upload_option == "Upload Image":
|
| 43 |
+
with open("temp_image.jpg", "wb") as f:
|
| 44 |
+
f.write(image_path.read())
|
| 45 |
+
else:
|
| 46 |
+
passport_info = recognize_passport(image_path)
|
| 47 |
+
|
| 48 |
+
if upload_option == "Upload Image":
|
| 49 |
+
passport_info = recognize_passport("temp_image.jpg")
|
| 50 |
|
| 51 |
+
col1, col2 = st.columns(2)
|
| 52 |
+
with col1:
|
| 53 |
+
st.markdown(f'## Passport Recognition Results')
|
| 54 |
+
st.json(json.dumps(passport_info, indent=2))
|
| 55 |
|
| 56 |
+
with col2:
|
| 57 |
+
st.image(image_path, caption="Uploaded Image.", use_column_width=True)
|