Luongdzung commited on
Commit
5e991eb
·
1 Parent(s): 3453605

create subfolder in inference

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -49,7 +49,12 @@ def detect_img(img,model):
49
 
50
  # save the upload image to Inference
51
  current_image_name = "current_img.jpg"
52
- save_current_path = os.path.join("./Inference/images", current_image_name)
 
 
 
 
 
53
  img = np.array(img)
54
  img = img[:,:,::-1] #convert color because np change it to bgr
55
  cv2.imwrite(save_current_path, img)
@@ -226,6 +231,11 @@ def detect_vid(vid,model):
226
 
227
  # save the upload video to Inference
228
  current_video_name = "current_vid.mp4"
 
 
 
 
 
229
  save_current_path = os.path.join("./Inference/videos", current_video_name)
230
 
231
  frames = cv2.VideoCapture(vid)
 
49
 
50
  # save the upload image to Inference
51
  current_image_name = "current_img.jpg"
52
+ img_folder = "Inference/images"
53
+ try:
54
+ os.mkdir(img_folder)
55
+ except FileExistsError:
56
+ print(f"Folder already exists.")
57
+ save_current_path = os.path.join(img_folder, current_image_name)
58
  img = np.array(img)
59
  img = img[:,:,::-1] #convert color because np change it to bgr
60
  cv2.imwrite(save_current_path, img)
 
231
 
232
  # save the upload video to Inference
233
  current_video_name = "current_vid.mp4"
234
+ vid_folder = "Inference/videos"
235
+ try:
236
+ mkdir(vid_folder)
237
+ except FileExistsError:
238
+ print(f"Folder already exists.")
239
  save_current_path = os.path.join("./Inference/videos", current_video_name)
240
 
241
  frames = cv2.VideoCapture(vid)