Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/caltech.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/cifar.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/cityscapes.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/clevr.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/dtd.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/eurosat.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/fgvc_aircraft.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/flowers102.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/folder.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/food101.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/hmdb51.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/imagenette.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/lfw.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/mnist.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/moving_mnist.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/pcam.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/phototour.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/places365.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/rendered_sst2.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/semeion.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/stanford_cars.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/sun397.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/svhn.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/ucf101.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/usps.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/video_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/vision.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/voc.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/__init__.py +3 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/__pycache__/clip_sampler.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/clip_sampler.py +173 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/_api.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/_meta.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/_utils.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/alexnet.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/convnext.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/densenet.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/efficientnet.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/feature_extraction.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/googlenet.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/inception.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/maxvit.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mnasnet.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mobilenet.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mobilenetv2.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mobilenetv3.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/regnet.cpython-310.pyc +0 -0
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (3.34 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/caltech.cpython-310.pyc
ADDED
|
Binary file (8.23 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/cifar.cpython-310.pyc
ADDED
|
Binary file (5.89 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/cityscapes.cpython-310.pyc
ADDED
|
Binary file (8.6 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/clevr.cpython-310.pyc
ADDED
|
Binary file (4.52 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/dtd.cpython-310.pyc
ADDED
|
Binary file (4.76 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/eurosat.cpython-310.pyc
ADDED
|
Binary file (3.16 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/fgvc_aircraft.cpython-310.pyc
ADDED
|
Binary file (5.21 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/flowers102.cpython-310.pyc
ADDED
|
Binary file (6.43 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/folder.cpython-310.pyc
ADDED
|
Binary file (12.4 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/food101.cpython-310.pyc
ADDED
|
Binary file (4.77 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/hmdb51.cpython-310.pyc
ADDED
|
Binary file (5.77 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/imagenette.cpython-310.pyc
ADDED
|
Binary file (5.06 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/lfw.cpython-310.pyc
ADDED
|
Binary file (11.3 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/mnist.cpython-310.pyc
ADDED
|
Binary file (21.4 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/moving_mnist.cpython-310.pyc
ADDED
|
Binary file (4.02 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/pcam.cpython-310.pyc
ADDED
|
Binary file (5.02 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/phototour.cpython-310.pyc
ADDED
|
Binary file (7.81 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/places365.cpython-310.pyc
ADDED
|
Binary file (8.15 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/rendered_sst2.cpython-310.pyc
ADDED
|
Binary file (4.41 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/semeion.cpython-310.pyc
ADDED
|
Binary file (3.37 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/stanford_cars.cpython-310.pyc
ADDED
|
Binary file (4.6 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/sun397.cpython-310.pyc
ADDED
|
Binary file (3.83 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/svhn.cpython-310.pyc
ADDED
|
Binary file (4.46 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/ucf101.cpython-310.pyc
ADDED
|
Binary file (5.92 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/usps.cpython-310.pyc
ADDED
|
Binary file (4.1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/video_utils.cpython-310.pyc
ADDED
|
Binary file (13.8 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/vision.cpython-310.pyc
ADDED
|
Binary file (4.95 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/__pycache__/voc.cpython-310.pyc
ADDED
|
Binary file (8.94 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .clip_sampler import DistributedSampler, RandomClipSampler, UniformClipSampler
|
| 2 |
+
|
| 3 |
+
__all__ = ("DistributedSampler", "UniformClipSampler", "RandomClipSampler")
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (347 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/__pycache__/clip_sampler.cpython-310.pyc
ADDED
|
Binary file (6.26 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/datasets/samplers/clip_sampler.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
from collections.abc import Iterator, Sized
|
| 3 |
+
from typing import cast, Optional, Union
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
import torch.distributed as dist
|
| 7 |
+
from torch.utils.data import Sampler
|
| 8 |
+
from torchvision.datasets.video_utils import VideoClips
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class DistributedSampler(Sampler):
|
| 12 |
+
"""
|
| 13 |
+
Extension of DistributedSampler, as discussed in
|
| 14 |
+
https://github.com/pytorch/pytorch/issues/23430
|
| 15 |
+
|
| 16 |
+
Example:
|
| 17 |
+
dataset: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
| 18 |
+
num_replicas: 4
|
| 19 |
+
shuffle: False
|
| 20 |
+
|
| 21 |
+
when group_size = 1
|
| 22 |
+
RANK | shard_dataset
|
| 23 |
+
=========================
|
| 24 |
+
rank_0 | [0, 4, 8, 12]
|
| 25 |
+
rank_1 | [1, 5, 9, 13]
|
| 26 |
+
rank_2 | [2, 6, 10, 0]
|
| 27 |
+
rank_3 | [3, 7, 11, 1]
|
| 28 |
+
|
| 29 |
+
when group_size = 2
|
| 30 |
+
|
| 31 |
+
RANK | shard_dataset
|
| 32 |
+
=========================
|
| 33 |
+
rank_0 | [0, 1, 8, 9]
|
| 34 |
+
rank_1 | [2, 3, 10, 11]
|
| 35 |
+
rank_2 | [4, 5, 12, 13]
|
| 36 |
+
rank_3 | [6, 7, 0, 1]
|
| 37 |
+
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
def __init__(
|
| 41 |
+
self,
|
| 42 |
+
dataset: Sized,
|
| 43 |
+
num_replicas: Optional[int] = None,
|
| 44 |
+
rank: Optional[int] = None,
|
| 45 |
+
shuffle: bool = False,
|
| 46 |
+
group_size: int = 1,
|
| 47 |
+
) -> None:
|
| 48 |
+
if num_replicas is None:
|
| 49 |
+
if not dist.is_available():
|
| 50 |
+
raise RuntimeError("Requires distributed package to be available")
|
| 51 |
+
num_replicas = dist.get_world_size()
|
| 52 |
+
if rank is None:
|
| 53 |
+
if not dist.is_available():
|
| 54 |
+
raise RuntimeError("Requires distributed package to be available")
|
| 55 |
+
rank = dist.get_rank()
|
| 56 |
+
if len(dataset) % group_size != 0:
|
| 57 |
+
raise ValueError(
|
| 58 |
+
f"dataset length must be a multiplier of group size dataset length: {len(dataset)}, group size: {group_size}"
|
| 59 |
+
)
|
| 60 |
+
self.dataset = dataset
|
| 61 |
+
self.group_size = group_size
|
| 62 |
+
self.num_replicas = num_replicas
|
| 63 |
+
self.rank = rank
|
| 64 |
+
self.epoch = 0
|
| 65 |
+
dataset_group_length = len(dataset) // group_size
|
| 66 |
+
self.num_group_samples = int(math.ceil(dataset_group_length * 1.0 / self.num_replicas))
|
| 67 |
+
self.num_samples = self.num_group_samples * group_size
|
| 68 |
+
self.total_size = self.num_samples * self.num_replicas
|
| 69 |
+
self.shuffle = shuffle
|
| 70 |
+
|
| 71 |
+
def __iter__(self) -> Iterator[int]:
|
| 72 |
+
# deterministically shuffle based on epoch
|
| 73 |
+
g = torch.Generator()
|
| 74 |
+
g.manual_seed(self.epoch)
|
| 75 |
+
indices: Union[torch.Tensor, list[int]]
|
| 76 |
+
if self.shuffle:
|
| 77 |
+
indices = torch.randperm(len(self.dataset), generator=g).tolist()
|
| 78 |
+
else:
|
| 79 |
+
indices = list(range(len(self.dataset)))
|
| 80 |
+
|
| 81 |
+
# add extra samples to make it evenly divisible
|
| 82 |
+
indices += indices[: (self.total_size - len(indices))]
|
| 83 |
+
assert len(indices) == self.total_size
|
| 84 |
+
|
| 85 |
+
total_group_size = self.total_size // self.group_size
|
| 86 |
+
indices = torch.reshape(torch.LongTensor(indices), (total_group_size, self.group_size))
|
| 87 |
+
|
| 88 |
+
# subsample
|
| 89 |
+
indices = indices[self.rank : total_group_size : self.num_replicas, :]
|
| 90 |
+
indices = torch.reshape(indices, (-1,)).tolist()
|
| 91 |
+
assert len(indices) == self.num_samples
|
| 92 |
+
|
| 93 |
+
if isinstance(self.dataset, Sampler):
|
| 94 |
+
orig_indices = list(iter(self.dataset))
|
| 95 |
+
indices = [orig_indices[i] for i in indices]
|
| 96 |
+
|
| 97 |
+
return iter(indices)
|
| 98 |
+
|
| 99 |
+
def __len__(self) -> int:
|
| 100 |
+
return self.num_samples
|
| 101 |
+
|
| 102 |
+
def set_epoch(self, epoch: int) -> None:
|
| 103 |
+
self.epoch = epoch
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class UniformClipSampler(Sampler):
|
| 107 |
+
"""
|
| 108 |
+
Sample `num_video_clips_per_video` clips for each video, equally spaced.
|
| 109 |
+
When number of unique clips in the video is fewer than num_video_clips_per_video,
|
| 110 |
+
repeat the clips until `num_video_clips_per_video` clips are collected
|
| 111 |
+
|
| 112 |
+
Args:
|
| 113 |
+
video_clips (VideoClips): video clips to sample from
|
| 114 |
+
num_clips_per_video (int): number of clips to be sampled per video
|
| 115 |
+
"""
|
| 116 |
+
|
| 117 |
+
def __init__(self, video_clips: VideoClips, num_clips_per_video: int) -> None:
|
| 118 |
+
if not isinstance(video_clips, VideoClips):
|
| 119 |
+
raise TypeError(f"Expected video_clips to be an instance of VideoClips, got {type(video_clips)}")
|
| 120 |
+
self.video_clips = video_clips
|
| 121 |
+
self.num_clips_per_video = num_clips_per_video
|
| 122 |
+
|
| 123 |
+
def __iter__(self) -> Iterator[int]:
|
| 124 |
+
idxs = []
|
| 125 |
+
s = 0
|
| 126 |
+
# select num_clips_per_video for each video, uniformly spaced
|
| 127 |
+
for c in self.video_clips.clips:
|
| 128 |
+
length = len(c)
|
| 129 |
+
if length == 0:
|
| 130 |
+
# corner case where video decoding fails
|
| 131 |
+
continue
|
| 132 |
+
|
| 133 |
+
sampled = torch.linspace(s, s + length - 1, steps=self.num_clips_per_video).floor().to(torch.int64)
|
| 134 |
+
s += length
|
| 135 |
+
idxs.append(sampled)
|
| 136 |
+
return iter(cast(list[int], torch.cat(idxs).tolist()))
|
| 137 |
+
|
| 138 |
+
def __len__(self) -> int:
|
| 139 |
+
return sum(self.num_clips_per_video for c in self.video_clips.clips if len(c) > 0)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
class RandomClipSampler(Sampler):
|
| 143 |
+
"""
|
| 144 |
+
Samples at most `max_video_clips_per_video` clips for each video randomly
|
| 145 |
+
|
| 146 |
+
Args:
|
| 147 |
+
video_clips (VideoClips): video clips to sample from
|
| 148 |
+
max_clips_per_video (int): maximum number of clips to be sampled per video
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
def __init__(self, video_clips: VideoClips, max_clips_per_video: int) -> None:
|
| 152 |
+
if not isinstance(video_clips, VideoClips):
|
| 153 |
+
raise TypeError(f"Expected video_clips to be an instance of VideoClips, got {type(video_clips)}")
|
| 154 |
+
self.video_clips = video_clips
|
| 155 |
+
self.max_clips_per_video = max_clips_per_video
|
| 156 |
+
|
| 157 |
+
def __iter__(self) -> Iterator[int]:
|
| 158 |
+
idxs = []
|
| 159 |
+
s = 0
|
| 160 |
+
# select at most max_clips_per_video for each video, randomly
|
| 161 |
+
for c in self.video_clips.clips:
|
| 162 |
+
length = len(c)
|
| 163 |
+
size = min(length, self.max_clips_per_video)
|
| 164 |
+
sampled = torch.randperm(length)[:size] + s
|
| 165 |
+
s += length
|
| 166 |
+
idxs.append(sampled)
|
| 167 |
+
idxs_ = torch.cat(idxs)
|
| 168 |
+
# shuffle all clips randomly
|
| 169 |
+
perm = torch.randperm(len(idxs_))
|
| 170 |
+
return iter(idxs_[perm].tolist())
|
| 171 |
+
|
| 172 |
+
def __len__(self) -> int:
|
| 173 |
+
return sum(min(len(c), self.max_clips_per_video) for c in self.video_clips.clips)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (831 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/_api.cpython-310.pyc
ADDED
|
Binary file (9.56 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/_meta.cpython-310.pyc
ADDED
|
Binary file (19.5 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/_utils.cpython-310.pyc
ADDED
|
Binary file (9.66 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/alexnet.cpython-310.pyc
ADDED
|
Binary file (4.41 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/convnext.cpython-310.pyc
ADDED
|
Binary file (12.6 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/densenet.cpython-310.pyc
ADDED
|
Binary file (14.2 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/efficientnet.cpython-310.pyc
ADDED
|
Binary file (29.2 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/feature_extraction.cpython-310.pyc
ADDED
|
Binary file (22.5 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/googlenet.cpython-310.pyc
ADDED
|
Binary file (10.3 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/inception.cpython-310.pyc
ADDED
|
Binary file (14.4 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/maxvit.cpython-310.pyc
ADDED
|
Binary file (24.6 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mnasnet.cpython-310.pyc
ADDED
|
Binary file (13.7 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mobilenet.cpython-310.pyc
ADDED
|
Binary file (316 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mobilenetv2.cpython-310.pyc
ADDED
|
Binary file (7.78 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/mobilenetv3.cpython-310.pyc
ADDED
|
Binary file (12.1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/torchvision/models/__pycache__/regnet.cpython-310.pyc
ADDED
|
Binary file (37.3 kB). View file
|
|
|