Datasets:

Modalities:
Video
Languages:
English
Tags:
video
License:
qingy2024 commited on
Commit
dadfe61
·
verified ·
1 Parent(s): 8152689

Upload k600/train/train/check_videos_exist.py with huggingface_hub

Browse files
k600/train/train/check_videos_exist.py CHANGED
@@ -4,13 +4,11 @@ import sys
4
 
5
  def check_video_files(json_file_path):
6
  try:
7
- # Load the JSON file
8
  with open(json_file_path, 'r') as file:
9
  data = json.load(file)
10
 
11
  missing_files = []
12
 
13
- # Check each entry in the JSON
14
  for entry in data:
15
  video_path = entry.get('video', '')
16
  caption = entry.get('caption', '')
@@ -22,7 +20,6 @@ def check_video_files(json_file_path):
22
  'error': 'File not found'
23
  })
24
 
25
- # Print results
26
  if not missing_files:
27
  print("All video files exist!")
28
  else:
@@ -33,7 +30,6 @@ def check_video_files(json_file_path):
33
  print(f"Error: {missing['error']}")
34
  print("-" * 40)
35
 
36
- # Optionally save missing files to a new JSON
37
  with open('missing_files.json', 'w') as outfile:
38
  json.dump(missing_files, outfile, indent=2)
39
  print("\nMissing files list saved to 'missing_files.json'")
@@ -55,3 +51,4 @@ if __name__ == "__main__":
55
  json_path = sys.argv[1]
56
  missing_count = check_video_files(json_path)
57
  sys.exit(0 if missing_count == 0 else 1)
 
 
4
 
5
  def check_video_files(json_file_path):
6
  try:
 
7
  with open(json_file_path, 'r') as file:
8
  data = json.load(file)
9
 
10
  missing_files = []
11
 
 
12
  for entry in data:
13
  video_path = entry.get('video', '')
14
  caption = entry.get('caption', '')
 
20
  'error': 'File not found'
21
  })
22
 
 
23
  if not missing_files:
24
  print("All video files exist!")
25
  else:
 
30
  print(f"Error: {missing['error']}")
31
  print("-" * 40)
32
 
 
33
  with open('missing_files.json', 'w') as outfile:
34
  json.dump(missing_files, outfile, indent=2)
35
  print("\nMissing files list saved to 'missing_files.json'")
 
51
  json_path = sys.argv[1]
52
  missing_count = check_video_files(json_path)
53
  sys.exit(0 if missing_count == 0 else 1)
54
+