bravewiki commited on
Commit
596e28e
Β·
verified Β·
1 Parent(s): b77d6eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -5
app.py CHANGED
@@ -32,26 +32,49 @@ def transcribe_handwriting(image):
32
 
33
  # Set Streamlit page configuration
34
  st.set_page_config(
35
- page_title="Prescription Reader",
36
  page_icon="πŸ’Š",
37
  layout="centered",
38
  )
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  # Header
41
- st.title("Doctor's Prescription Reader πŸ’Š")
42
 
43
  # Upload prescription image
44
- uploaded_file = st.file_uploader("Upload Prescription Image", type=["jpg", "jpeg", "png"])
45
 
46
  if uploaded_file is not None:
47
  # Open the image using PIL
48
  image = Image.open(uploaded_file)
49
 
50
  # Display uploaded image
51
- st.image(image, caption="Uploaded Prescription", use_column_width=True)
52
 
53
  with st.spinner("Transcribing handwriting..."):
54
  # Transcribe handwritten notes
55
  extracted_text = transcribe_handwriting(image)
56
  st.subheader("Transcribed Text from Prescription:")
57
- st.text(extracted_text)
 
 
 
 
 
 
32
 
33
  # Set Streamlit page configuration
34
  st.set_page_config(
35
+ page_title="AI and ML Handwriting Reader",
36
  page_icon="πŸ’Š",
37
  layout="centered",
38
  )
39
 
40
+ # Function to display extracted text in a fancy div
41
+ def display_extracted_text(extracted_text):
42
+ # Custom HTML and CSS for styling
43
+ fancy_div = f"""
44
+ <div style="
45
+ border: 2px solid #128c7E;
46
+ border-radius: 10px;
47
+ padding: 20px;
48
+ background-color: #f0f0f0;
49
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
50
+ font-family: 'Arial', sans-serif;
51
+ color: #333;">
52
+ <h2 style="color: #128c7E;">Transcribed Text from Image:</h2>
53
+ <p style="font-size: 16px;">{extracted_text}</p>
54
+ </div>
55
+ """
56
+ st.markdown(fancy_div, unsafe_allow_html=True)
57
+
58
  # Header
59
+ st.title("AI and ML based Handwriting Reader")
60
 
61
  # Upload prescription image
62
+ uploaded_file = st.file_uploader("Upload Handwriting Image", type=["jpg", "jpeg", "png"])
63
 
64
  if uploaded_file is not None:
65
  # Open the image using PIL
66
  image = Image.open(uploaded_file)
67
 
68
  # Display uploaded image
69
+ st.image(image, caption="Uploaded Handwriting Image", width="400")
70
 
71
  with st.spinner("Transcribing handwriting..."):
72
  # Transcribe handwritten notes
73
  extracted_text = transcribe_handwriting(image)
74
  st.subheader("Transcribed Text from Prescription:")
75
+ display_extracted_text(extracted_text)
76
+
77
+
78
+
79
+
80
+