jinmang2 commited on
Commit
8a2dfed
·
1 Parent(s): a07c281

Update ucf_crime.py

Browse files
Files changed (1) hide show
  1. ucf_crime.py +11 -3
ucf_crime.py CHANGED
@@ -82,7 +82,7 @@ _SPLIT_FILES = {
82
  _NAMES = [
83
  "Abuse", "Arrest", "Arson", "Assault",
84
  "Burglary", "Explosion", "Fighting",
85
- "RoadAccidents", "Robbery", "Shooting",
86
  "Shoplifting", "Stealing", "Vandalism",
87
  "Normal",
88
  ]
@@ -189,7 +189,7 @@ class UCFCrime(datasets.GeneratorBasedBuilder):
189
  split_files = []
190
  if split_path is not None:
191
  with open(split_path, "r") as f:
192
- split_files = [line.strip().split("/")[-1] for line in f.readlines()]
193
  for extracted_path in extracted.values():
194
  for root, _, files in os.walk(extracted_path, topdown=False):
195
  for name in files:
@@ -203,7 +203,15 @@ class UCFCrime(datasets.GeneratorBasedBuilder):
203
 
204
  images = [None]
205
  if self.config.to_images == True:
206
- pass
 
 
 
 
 
 
 
 
207
 
208
  yield idx, {
209
  "video_path": absolute_file_path,
 
82
  _NAMES = [
83
  "Abuse", "Arrest", "Arson", "Assault",
84
  "Burglary", "Explosion", "Fighting",
85
+ "RoadAccidents", "Robbery", "Shooting"
86
  "Shoplifting", "Stealing", "Vandalism",
87
  "Normal",
88
  ]
 
189
  split_files = []
190
  if split_path is not None:
191
  with open(split_path, "r") as f:
192
+ split_files = [line.strip().split(os.sep)[-1] for line in f.readlines()]
193
  for extracted_path in extracted.values():
194
  for root, _, files in os.walk(extracted_path, topdown=False):
195
  for name in files:
 
203
 
204
  images = [None]
205
  if self.config.to_images == True:
206
+ outpath = os.path.join(root, "frames")
207
+ ffmpeg_cmd = ["ffmpeg", "-i", absolute_file_path]
208
+ ffmpeg_cmd += [os.path.join(outpath, "image_%05d.jpg")]
209
+ subprocess.run(ffmpeg_cmd)
210
+
211
+ images = [
212
+ os.path.join(outpath, img_file)
213
+ for img_file in sorted(os.listdir(outpath))
214
+ ]
215
 
216
  yield idx, {
217
  "video_path": absolute_file_path,