Created
June 11, 2018 03:45
-
-
Save Multihuntr/02a935a165a291f59d13ce215f41b088 to your computer and use it in GitHub Desktop.
Minimal examples of using NVIDIA/nvvl
This file contains hidden or 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
# Simplest case (note: VideoDataset.__get__ puts frames on CPU) | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3) | |
fr = d[0] | |
print(type(fr)) | |
print(fr.shape) | |
# Custom processing (note: VideoDataset.__get__ puts frames on CPU) | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, processing={'a': nvvl.ProcessDesc()}) | |
fr = d[0] | |
print(type(fr)) | |
print(fr['a'].shape) | |
# Custom labels associated with frames (note: VideoDataset.__get__ puts frames on CPU) | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, get_label=lambda x,y: (x,y)) | |
fr = d[0] | |
print(type(fr)) | |
print(fr['default'].shape) | |
print(fr['labels']) | |
for x in [50, 121, 31, 50]: | |
print(d[x]['labels']) | |
# Both custom processing and custom labels (note: VideoDataset.__get__ puts frames on CPU) | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, processing={'a': nvvl.ProcessDesc()}, get_label=lambda x,y: (x,y)) | |
fr = d[0] | |
print(type(fr)) | |
print(fr['a'].shape) | |
print(fr['labels']) | |
for x in [50, 121, 31, 50]: | |
print(d[x]['labels']) | |
# Simplest Dataloader use | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3) | |
lo = nvvl.VideoLoader(d, batch_size=3) | |
it = lo.__iter__() | |
fr = next(it) | |
print(type(fr)) | |
print(fr['default'].shape) | |
# Sequential Dataloader with custom processing | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, processing={'a': nvvl.ProcessDesc()}) | |
lo = nvvl.VideoLoader(d, batch_size=3) | |
it = lo.__iter__() | |
fr = next(it) | |
print(type(fr)) | |
print(fr['a'].shape) | |
# Sequential Dataloader with default processing and custom labels | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, get_label=lambda x,y: (x,y)) | |
lo = nvvl.VideoLoader(d, batch_size=3) | |
it = lo.__iter__() | |
fr = next(it) | |
print(type(fr)) | |
print(fr['default'].shape) | |
# Sequential Dataloader with custom processing and custom labels | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, processing={'a': nvvl.ProcessDesc()}, get_label=lambda x,y: (x,y)) | |
lo = nvvl.VideoLoader(d, batch_size=3) | |
it = lo.__iter__() | |
fr = next(it) | |
print(type(fr)) | |
print(fr['a'].shape) | |
print(fr['labels']) | |
# Shuffled Dataloader with custom processing and custom labels | |
import nvvl | |
d = nvvl.VideoDataset(['prepared.mp4'], 3, processing={'a': nvvl.ProcessDesc()}, get_label=lambda x,y: (x,y)) | |
lo = nvvl.VideoLoader(d, batch_size=3, shuffle=True) | |
it = lo.__iter__() | |
fr = next(it) | |
print(type(fr)) | |
print(fr['a'].shape) | |
print(fr['labels']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment