QinOwen commited on
Commit
20910ba
1 Parent(s): f016f7c

delete-oldest-temperal-video

Browse files
VADER-VideoCrafter/scripts/main/train_t2v_lora.py CHANGED
@@ -848,9 +848,9 @@ def run_training(args, model, **kwargs):
848
 
849
  # if the number of the video is more than 20, remove the oldest one
850
  if len(os.listdir(dir_name[0])) > 20:
851
- # get the oldest video
852
- oldest_video = min(os.listdir(dir_name[0]), key=os.path.getctime)
853
- os.remove(os.path.join(dir_name[0], oldest_video))
854
 
855
  # # read the video from the saved path
856
  video_path = os.path.join(dir_name[0], filenames[0]+".mp4")
 
848
 
849
  # if the number of the video is more than 20, remove the oldest one
850
  if len(os.listdir(dir_name[0])) > 20:
851
+ # get the oldest file
852
+ oldest = min(os.listdir(dir_name[0]), key=lambda x: os.path.getctime(os.path.join(dir_name[0], x)))
853
+ os.remove(os.path.join(dir_name[0], oldest))
854
 
855
  # # read the video from the saved path
856
  video_path = os.path.join(dir_name[0], filenames[0]+".mp4")