Darknsu commited on
Commit
7f32c66
·
verified ·
1 Parent(s): 5e00bb9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -35
main.py CHANGED
@@ -509,58 +509,29 @@ class HFVideoDataSet(VideoDataSet):
509
  shutil.rmtree(self.temp_dir)
510
  raise e
511
 
512
- # CRITICAL FIX: Ensure the temp directory path ends with a slash
513
- # This is needed because the parent VideoDataSet class likely does string concatenation
514
- if not self.temp_dir.endswith(os.sep):
515
- self.temp_dir = self.temp_dir + os.sep
516
-
517
  opt['video_feature_all_test'] = self.temp_dir
518
  print(f"Set video_feature_all_test to: {opt['video_feature_all_test']}")
519
 
520
- # Store reference for potential path fixes
521
- self.video_name_for_single_video = video_name
522
-
523
  # Initialize parent class
524
  try:
525
  super().__init__(opt, subset, video_name)
526
  print(f"Successfully initialized dataset with {len(self.video_list)} videos")
527
  except Exception as e:
528
  print(f"Error initializing parent VideoDataSet: {str(e)}")
529
- # Debug: Let's see what files are actually in the temp directory
530
- temp_dir_clean = self.temp_dir.rstrip(os.sep)
531
- if os.path.exists(temp_dir_clean):
532
- files_in_temp = os.listdir(temp_dir_clean)
533
- print(f"Files in temp directory: {files_in_temp}")
534
-
535
- # Try to find the expected file with different possible constructions
536
- expected_file_1 = os.path.join(temp_dir_clean, f"{video_name}.npz")
537
- expected_file_2 = f"{temp_dir_clean}{video_name}.npz"
538
- expected_file_3 = f"{self.temp_dir}{video_name}.npz"
539
-
540
- print(f"Expected file path 1: {expected_file_1} - Exists: {os.path.exists(expected_file_1)}")
541
- print(f"Expected file path 2: {expected_file_2} - Exists: {os.path.exists(expected_file_2)}")
542
- print(f"Expected file path 3: {expected_file_3} - Exists: {os.path.exists(expected_file_3)}")
543
-
544
  # Clean up temp directory on error
545
- if hasattr(self, 'temp_dir') and os.path.exists(temp_dir_clean):
546
- shutil.rmtree(temp_dir_clean)
547
  raise e
548
 
549
  def __del__(self):
550
  # Clean up temporary directory
551
  try:
552
- if hasattr(self, 'temp_dir'):
553
- temp_dir_clean = self.temp_dir.rstrip(os.sep)
554
- if os.path.exists(temp_dir_clean):
555
- shutil.rmtree(temp_dir_clean)
556
- print(f"Cleaned up temp directory: {temp_dir_clean}")
557
  except Exception as e:
558
  print(f"Warning: Could not clean up temp directory: {e}")
559
-
560
- def get_video_feature_path(self, video_name):
561
- """Override to ensure proper path construction"""
562
- temp_dir_clean = self.temp_dir.rstrip(os.sep)
563
- return os.path.join(temp_dir_clean, f"{video_name}.npz")
564
 
565
  def eval_frame(opt, model, dataset):
566
  """Evaluate model frame by frame"""
 
509
  shutil.rmtree(self.temp_dir)
510
  raise e
511
 
512
+ # Set the feature path to our temp directory
 
 
 
 
513
  opt['video_feature_all_test'] = self.temp_dir
514
  print(f"Set video_feature_all_test to: {opt['video_feature_all_test']}")
515
 
 
 
 
516
  # Initialize parent class
517
  try:
518
  super().__init__(opt, subset, video_name)
519
  print(f"Successfully initialized dataset with {len(self.video_list)} videos")
520
  except Exception as e:
521
  print(f"Error initializing parent VideoDataSet: {str(e)}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  # Clean up temp directory on error
523
+ if hasattr(self, 'temp_dir') and os.path.exists(self.temp_dir):
524
+ shutil.rmtree(self.temp_dir)
525
  raise e
526
 
527
  def __del__(self):
528
  # Clean up temporary directory
529
  try:
530
+ if hasattr(self, 'temp_dir') and os.path.exists(self.temp_dir):
531
+ shutil.rmtree(self.temp_dir)
532
+ print(f"Cleaned up temp directory: {self.temp_dir}")
 
 
533
  except Exception as e:
534
  print(f"Warning: Could not clean up temp directory: {e}")
 
 
 
 
 
535
 
536
  def eval_frame(opt, model, dataset):
537
  """Evaluate model frame by frame"""