-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change dataset_preparation.py to command lines
- Loading branch information
1 parent
f895c01
commit 54829b9
Showing
3 changed files
with
84 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Dataset pre-processing: convert .txt files to .json files | ||
""" | ||
import json | ||
|
||
|
||
# We use the .json files for the annotations. | ||
# One can convert the train_split_1.txt to train_split_1.json | ||
# by using the following code: | ||
|
||
ann_path = [ | ||
"data/ucf101/annotations/train_split_1.txt", | ||
"data/ucf101/annotations/test_split_1.txt", | ||
] | ||
out_path = [ | ||
"data/ucf101/annotations/train_split_1.json", | ||
"data/ucf101/annotations/test_split_1.json", | ||
] | ||
|
||
assert len(ann_path) == len(out_path) | ||
|
||
for i in range(len(ann_path)): | ||
with open(ann_path[i], "r") as f: | ||
lines = f.read().splitlines() | ||
anns = [] | ||
for line in lines: | ||
if line.strip() == "": | ||
continue | ||
name, label = line.split(" ") | ||
anns.append({"name": name, "label": int(label)}) | ||
with open(out_path[i], "w") as f: | ||
json.dump(anns, f, indent=2) | ||
|
This file was deleted.
Oops, something went wrong.