Sivakkanth commited on
Commit
fc6c654
·
1 Parent(s): 5bb903e

Model updated with retrive the detetcted image

Browse files
Files changed (2) hide show
  1. app.py +9 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -5,6 +5,7 @@ import easyocr
5
  import numpy as np
6
  import re
7
  from datetime import datetime
 
8
 
9
  # Load YOLO model
10
  model = YOLO("model/best.pt")
@@ -202,15 +203,20 @@ def extract_receipt(image):
202
  if not output["time"]:
203
  output["time"] = now.strftime("%H:%M:%S")
204
 
205
- return output
 
 
 
 
 
206
 
207
  # ---------- Gradio Interface ----------
208
  iface = gr.Interface(
209
  fn=extract_receipt,
210
  inputs=gr.Image(type="pil"),
211
- outputs=gr.JSON(),
212
  title="Receipt Extractor",
213
- description="Upload a receipt image to extract merchant, date, total, time, and items."
214
  )
215
 
216
  iface.launch(share=True)
 
5
  import numpy as np
6
  import re
7
  from datetime import datetime
8
+ from PIL import Image
9
 
10
  # Load YOLO model
11
  model = YOLO("model/best.pt")
 
203
  if not output["time"]:
204
  output["time"] = now.strftime("%H:%M:%S")
205
 
206
+ # ---------- Generate YOLO prediction image ----------
207
+ yolo_img = results.plot()
208
+ yolo_img = cv2.cvtColor(yolo_img, cv2.COLOR_BGR2RGB)
209
+ yolo_img_pil = Image.fromarray(yolo_img)
210
+
211
+ return output, yolo_img_pil
212
 
213
  # ---------- Gradio Interface ----------
214
  iface = gr.Interface(
215
  fn=extract_receipt,
216
  inputs=gr.Image(type="pil"),
217
+ outputs=[gr.JSON(), gr.Image(type="pil")],
218
  title="Receipt Extractor",
219
+ description="Upload a receipt image to extract merchant, date, total, time, items, and see YOLO predictions."
220
  )
221
 
222
  iface.launch(share=True)
requirements.txt CHANGED
@@ -4,4 +4,5 @@ ultralytics==8.3.203
4
  opencv-python-headless==4.12.0.88
5
  easyocr==1.7.2
6
  gradio==5.46.0
7
- numpy==2.0.2
 
 
4
  opencv-python-headless==4.12.0.88
5
  easyocr==1.7.2
6
  gradio==5.46.0
7
+ numpy==2.0.2
8
+ pillow==11.1.0