Nick088 commited on
Commit
66f1352
·
verified ·
1 Parent(s): caaf48c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -62,8 +62,12 @@ def inference_image(image, size):
62
  def inference_video(video, size):
63
  _id = randint(1, 10000)
64
  INPUT_DIR = "tmp/" + str(_id)
65
- os.system("rm -rf " + INPUT_DIR)
66
- os.system("mkdir -p " + INPUT_DIR)
 
 
 
 
67
  os.system(f"cd {INPUT_DIR}")
68
  upload_folder = 'upload'
69
  result_folder = 'results'
 
62
  def inference_video(video, size):
63
  _id = randint(1, 10000)
64
  INPUT_DIR = "tmp/" + str(_id)
65
+ # Check if the directory exists, if so remove it
66
+ if os.path.exists(INPUT_DIR):
67
+ shutil.rmtree(INPUT_DIR)
68
+ else:
69
+ # Create the directory, equivalent to 'mkdir -p'
70
+ os.makedirs(INPUT_DIR, exist_ok=True)
71
  os.system(f"cd {INPUT_DIR}")
72
  upload_folder = 'upload'
73
  result_folder = 'results'