-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added updates to movieCLIP data parsing
- Loading branch information
Showing
3 changed files
with
151 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import json | ||
import pandas as pd | ||
import numpy as np | ||
import argparse | ||
from tqdm import tqdm | ||
from collections import Counter | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--source_file', type=str, required=True) | ||
parser.add_argument('--destination_folder', type=str, required=True) | ||
|
||
|
||
args = parser.parse_args() | ||
source_file = args.source_file | ||
dest_folder = args.destination_folder | ||
|
||
#read the json file | ||
with open(source_file,'r') as f: | ||
data=json.load(f) | ||
|
||
video_keys=list(data.keys()) | ||
total_labels_list=[] | ||
|
||
for video_key in tqdm(list(video_keys)): | ||
|
||
video_data=data[video_key] | ||
|
||
for shot_name in list(video_data.keys()): | ||
shot_data=video_data[shot_name] | ||
labels=shot_data['labels'] | ||
shot_labels={l for l in list(labels.keys()) if labels[l]>=0.4} | ||
total_labels_list=total_labels_list+list(shot_labels) | ||
|
||
#print(shot_data['labels']) | ||
total_labels_counter=Counter(total_labels_list) | ||
total_labels_dict=dict(total_labels_counter) | ||
print(len(total_labels_dict)) | ||
|
||
#save the total labels dict | ||
with open(os.path.join(dest_folder,'clean_labels_movieCLIP_distribution.json'),'w') as f: | ||
json.dump(total_labels_dict,f,indent=4) | ||
|
||
|
||
|
||
|
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,72 @@ | ||
# MovieCLIP Dataset | ||
|
||
|
||
## Raw videos | ||
|
||
* Download the original videos by requesting access to the [**Condensed Movies Dataset**](https://github.com/m-bain/CondensedMovies). Our video tagging was peformed on the videos present in **Condensed Movies** dataset. We do not own the raw videos. | ||
|
||
## CLIP tags | ||
|
||
* The complete list of CLIP tags for the shots in the MovieCLIP dataset can be downloaded from this [**Drive Link**](https://drive.google.com/file/d/15EhA0BT3IF0EuLP1yXr5nn5ad9soxxox/view?usp=share_link) | ||
|
||
* Load the CLIP tags using the following code snippet: | ||
|
||
```python | ||
import json | ||
with open('movieCLIP_dataset.json', 'r') as f: | ||
movieCLIP_tags = json.load(f) | ||
``` | ||
* **movieCLIP_tags** is a dictionary with keys as the video names (youtube ids in **Condensed Movies**) and values as a list of CLIP tags for each shot in the video: | ||
|
||
```python | ||
"qM8jk56Vj9Y": | ||
"qM8jk56Vj9Y-Scene-018.mp4": { | ||
"start_frame": 1059.0, | ||
"end_frame": 1137.0, | ||
"start_time": 44.169, | ||
"end_time": 47.422, | ||
"labels": { | ||
"banquet": 0.7861328125, | ||
"dining room": 0.07110595703125, | ||
"restaurant": 0.028594970703125, | ||
"penthouse": 0.01611328125, | ||
"salon": 0.01186370849609375 | ||
} | ||
}, | ||
"B-tq7mbTvrA": | ||
"B-tq7mbTvrA-Scene-003.mp4": { | ||
"start_frame": 54.0, | ||
"end_frame": 74.0, | ||
"start_time": 2.252, | ||
"end_time": 3.086, | ||
"labels": { | ||
"batting cage": 0.479248046875, | ||
"locker room": 0.160400390625, | ||
"baseball field": 0.11248779296875, | ||
"stadium": 0.0601806640625, | ||
"bowling alley": 0.040496826171875 | ||
} | ||
}, | ||
"Ld2g77JckSk": | ||
"Ld2g77JckSk-Scene-018.mp4": { | ||
"start_frame": 974.0, | ||
"end_frame": 1031.0, | ||
"start_time": 40.627, | ||
"end_time": 43.004, | ||
"labels": { | ||
"animal shelter": 0.640625, | ||
"zoo": 0.07684326171875, | ||
"farm": 0.04071044921875, | ||
"fair": 0.0256500244140625, | ||
"suburban": 0.0123748779296875 | ||
} | ||
} | ||
``` | ||
|
||
## TODOS | ||
* Check the distribution of the labels from the json if they look the same as previous version | ||
|
||
|
||
|
||
|
||
|