eagle0504 commited on
Commit
1a69f98
·
1 Parent(s): 6738563

app updated

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -83,6 +83,9 @@ def main():
83
 
84
  # OCR by API Call of AWS Textract via Post Method
85
  if input_method == "Upload Image":
 
 
 
86
  st.success("Running textract!")
87
  url = "https://2tsig211e0.execute-api.us-east-1.amazonaws.com/my_textract"
88
  payload = {"image": image_base64}
@@ -99,6 +102,7 @@ def main():
99
  st.table(df)
100
 
101
  # Using an expander to hide the table
 
102
  with st.expander("Show/Hide Annotation"):
103
  try:
104
  image = Image.open(image)
@@ -107,7 +111,6 @@ def main():
107
  image_with_boxes = draw_bounding_boxes_for_textract(
108
  image.copy(), result_dict
109
  )
110
- st.success("Bounding boxes drawn.")
111
 
112
  # Display annotated image
113
  st.image(
@@ -121,6 +124,9 @@ def main():
121
 
122
  if api_key:
123
  # Make API call
 
 
 
124
  st.success("Running Gemini!")
125
  with st.spinner("Wait for it..."):
126
  response = call_gemini_api(image_base64, api_key)
@@ -136,6 +142,9 @@ def main():
136
  with st.spinner("Wait for it..."):
137
  st.write(text_from_response)
138
 
 
 
 
139
  with st.spinner("Processing csv to download..."):
140
  try:
141
  keys = ["First Name", "Last Name", "Policy Number"]
@@ -204,7 +213,9 @@ def main():
204
 
205
  # YOLO
206
  if image is not None:
207
- st.sidebar.success("Check the following box to run YOLO algorithm if desired!")
 
 
208
  use_yolo = st.sidebar.checkbox("Use YOLO!", value=False)
209
  if use_yolo:
210
  yolo_option = st.selectbox(
@@ -222,9 +233,9 @@ def main():
222
  "object-detection", model="eagle0504/detr-finetuned-balloon-v2"
223
  )
224
  else:
225
- yolo_pipe = pipeline("object-detection", model="hustvl/yolos-small")
226
 
227
- if use_yolo:
228
  # Process image with YOLO
229
  image = Image.open(image)
230
  with st.spinner("Wait for it..."):
 
83
 
84
  # OCR by API Call of AWS Textract via Post Method
85
  if input_method == "Upload Image":
86
+ st.markdown(
87
+ "# OCR (Optical Character Recognition) - computer vision technology to locate letters/numbers from image."
88
+ )
89
  st.success("Running textract!")
90
  url = "https://2tsig211e0.execute-api.us-east-1.amazonaws.com/my_textract"
91
  payload = {"image": image_base64}
 
102
  st.table(df)
103
 
104
  # Using an expander to hide the table
105
+ st.success("Bounding boxes drawn!")
106
  with st.expander("Show/Hide Annotation"):
107
  try:
108
  image = Image.open(image)
 
111
  image_with_boxes = draw_bounding_boxes_for_textract(
112
  image.copy(), result_dict
113
  )
 
114
 
115
  # Display annotated image
116
  st.image(
 
124
 
125
  if api_key:
126
  # Make API call
127
+ st.markdown(
128
+ "# Gemini (Generative AI) - read the image content in a general form"
129
+ )
130
  st.success("Running Gemini!")
131
  with st.spinner("Wait for it..."):
132
  response = call_gemini_api(image_base64, api_key)
 
142
  with st.spinner("Wait for it..."):
143
  st.write(text_from_response)
144
 
145
+ st.markdown(
146
+ "# Information Retrieval - use Gemini to extract the values for the keys required by the stakeholders"
147
+ )
148
  with st.spinner("Processing csv to download..."):
149
  try:
150
  keys = ["First Name", "Last Name", "Policy Number"]
 
213
 
214
  # YOLO
215
  if image is not None:
216
+ st.sidebar.success(
217
+ "Check the following box to run YOLO algorithm if desired (only do this if the task at hand is an object detection task)!"
218
+ )
219
  use_yolo = st.sidebar.checkbox("Use YOLO!", value=False)
220
  if use_yolo:
221
  yolo_option = st.selectbox(
 
233
  "object-detection", model="eagle0504/detr-finetuned-balloon-v2"
234
  )
235
  else:
236
+ yolo_pipe = None
237
 
238
+ if yolo_pipe is not None:
239
  # Process image with YOLO
240
  image = Image.open(image)
241
  with st.spinner("Wait for it..."):