Update README.md
Browse files
README.md
CHANGED
@@ -47,22 +47,32 @@ The choice depends on whether you need to download full length videos and/or you
|
|
47 |
## Example
|
48 |
The data can either be downloaded or [streamed](https://huggingface.co/docs/datasets/stream).
|
49 |
|
50 |
-
|
51 |
```python
|
52 |
from datasets import load_dataset
|
53 |
from torchvision.io import read_video
|
54 |
|
55 |
config = 'no-full' # ['all', 'no-full', 'has-masks', 'full-masks']
|
56 |
-
|
57 |
-
streaming = True
|
58 |
-
if streaming:
|
59 |
-
dataset = load_dataset("AlexBlck/ANAKIN", streaming=True)
|
60 |
-
else:
|
61 |
-
dataset = load_dataset("AlexBlck/ANAKIN", config, nproc=8)
|
62 |
|
63 |
for sample in dataset['train']: # ['train', 'validation', 'test']
|
64 |
trimmed_video, trimmed_audio, _ = read_video(sample['trimmed'], output_format="TCHW")
|
65 |
edited_video, edited_audio, _ = read_video(sample['edited'], output_format="TCHW")
|
66 |
masks = sample['masks']
|
67 |
print(sample.keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
```
|
|
|
47 |
## Example
|
48 |
The data can either be downloaded or [streamed](https://huggingface.co/docs/datasets/stream).
|
49 |
|
50 |
+
### Downloaded
|
51 |
```python
|
52 |
from datasets import load_dataset
|
53 |
from torchvision.io import read_video
|
54 |
|
55 |
config = 'no-full' # ['all', 'no-full', 'has-masks', 'full-masks']
|
56 |
+
dataset = load_dataset("AlexBlck/ANAKIN", config, nproc=8)
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
for sample in dataset['train']: # ['train', 'validation', 'test']
|
59 |
trimmed_video, trimmed_audio, _ = read_video(sample['trimmed'], output_format="TCHW")
|
60 |
edited_video, edited_audio, _ = read_video(sample['edited'], output_format="TCHW")
|
61 |
masks = sample['masks']
|
62 |
print(sample.keys())
|
63 |
+
```
|
64 |
+
|
65 |
+
### Streamed
|
66 |
+
```python
|
67 |
+
from datasets import load_dataset
|
68 |
+
import cv2
|
69 |
+
|
70 |
+
dataset = load_dataset("AlexBlck/ANAKIN", streaming=True)
|
71 |
+
|
72 |
+
sample = next(iter(dataset['train'])) # ['train', 'validation', 'test']
|
73 |
+
cap = cv2.VideoCapture(sample['trimmed'])
|
74 |
+
|
75 |
+
while(cap.isOpened()):
|
76 |
+
ret, frame = cap.read()
|
77 |
+
# ...
|
78 |
```
|