Spaces:
Build error
Build error
File size: 2,449 Bytes
52c1998 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import streamlit as st
from utils.logger import setup_logger
import pandas as pd
from PIL import Image
import os
logger = setup_logger(__name__)
def prune_driving_license_for_display(analysis_results_for_id):
data_to_display = {}
data_to_display["document_category"] = "identity_verification_document"
data_to_display["document_type"] = "driving_license"
data_to_display["surname"] = analysis_results_for_id.get(
"surname", None)
data_to_display["first_name"] = analysis_results_for_id.get(
"first_name", None)
data_to_display["date_of_birth"] = analysis_results_for_id.get(
"date_of_birth", None)
data_to_display["place_of_birth"] = analysis_results_for_id.get(
"place_of_birth", None)
data_to_display["date_of_issue"] = analysis_results_for_id.get(
"date_of_issue", None)
data_to_display["date_of_expiry"] = analysis_results_for_id.get(
"date_of_expiry", None)
data_to_display["issuing_authority"] = analysis_results_for_id.get(
"issuing_authority", None)
data_to_display["driver_number"] = analysis_results_for_id.get(
"driver_number", None)
data_to_display["address"] = analysis_results_for_id.get(
"address", None)
data_to_display["entitlements"] = analysis_results_for_id.get(
"entitlements", None)
return data_to_display
def display_driving_license(extracted_files, analysis_results_pruned):
col1, col2 = st.columns([2, 3])
logger.info(f"file_path while displaying: {extracted_files}")
st.markdown("---")
with col1:
if len(extracted_files) > 1:
st.image(extracted_files, caption=[os.path.basename(
img) for img in extracted_files], use_container_width=True)
else:
image = Image.open(extracted_files[0])
st.image(image, caption=os.path.basename(
extracted_files[0])) # ,
# use_container_width=True)
logger.info(
f"analysis_results_pruned : {analysis_results_pruned}")
with col2:
simple_df = pd.DataFrame.from_dict(
analysis_results_pruned,
orient='index', columns=['Value']).reset_index()
simple_df.columns = ['Key', 'Value']
simple_df = simple_df.fillna(value="Missing")
simple_df.index += 1
st.dataframe(simple_df, use_container_width=True)
# logger.info(f"simple_df: {simple_df}")
|