Raghvender commited on
Commit
abb346a
·
1 Parent(s): 3ad1b79

save original images

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -1,11 +1,23 @@
1
  import gradio as gr
2
  from ultralytics import YOLO
 
 
3
  import cv2
4
 
5
  model = YOLO('head_yolov8s.pt')
6
 
7
  def head_detect(path):
 
 
 
8
  img = cv2.imread(path)
 
 
 
 
 
 
 
9
  output = model(source=img)
10
  res = output[0].cpu().numpy()
11
 
 
1
  import gradio as gr
2
  from ultralytics import YOLO
3
+ import os
4
+ from datetime import datetime
5
  import cv2
6
 
7
  model = YOLO('head_yolov8s.pt')
8
 
9
  def head_detect(path):
10
+ if path is None:
11
+ return None
12
+
13
  img = cv2.imread(path)
14
+ # Save the original image
15
+ if not os.path.exists('uploaded_images'):
16
+ os.makedirs('uploaded_images')
17
+ current_time = datetime.now().strftime("%Y%m%d_%H%M%S")
18
+ filename = f'uploaded_images/{current_time}.jpg'
19
+ cv2.imwrite(filename, img)
20
+
21
  output = model(source=img)
22
  res = output[0].cpu().numpy()
23