1
1
import io
2
2
from collections import namedtuple
3
- from typing import Any , Callable , Dict , List , Optional , Tuple , Iterator
3
+ from typing import Any , Dict , List , Optional , Tuple , Iterator
4
4
5
- import torch
6
5
from torchdata .datapipes .iter import IterDataPipe , Mapper , Zipper
7
6
from torchvision .prototype import features
8
7
from torchvision .prototype .datasets .utils import (
9
8
Dataset ,
10
9
DatasetConfig ,
11
10
DatasetInfo ,
12
11
OnlineResource ,
13
- DatasetType ,
14
12
GDriveResource ,
15
13
)
16
14
from torchvision .prototype .datasets .utils ._internal import (
@@ -46,7 +44,6 @@ class PCAM(Dataset):
46
44
def _make_info (self ) -> DatasetInfo :
47
45
return DatasetInfo (
48
46
"pcam" ,
49
- type = DatasetType .RAW ,
50
47
homepage = "https://github.com/basveeling/pcam" ,
51
48
categories = 2 ,
52
49
valid_options = dict (split = ("train" , "test" , "val" )),
@@ -98,7 +95,7 @@ def resources(self, config: DatasetConfig) -> List[OnlineResource]:
98
95
for file_name , gdrive_id , sha256 in self ._RESOURCES [config .split ]
99
96
]
100
97
101
- def _collate_and_decode (self , data : Tuple [Any , Any ]) -> Dict [str , Any ]:
98
+ def _prepare_sample (self , data : Tuple [Any , Any ]) -> Dict [str , Any ]:
102
99
image , target = data # They're both numpy arrays at this point
103
100
104
101
return {
@@ -107,11 +104,7 @@ def _collate_and_decode(self, data: Tuple[Any, Any]) -> Dict[str, Any]:
107
104
}
108
105
109
106
def _make_datapipe (
110
- self ,
111
- resource_dps : List [IterDataPipe ],
112
- * ,
113
- config : DatasetConfig ,
114
- decoder : Optional [Callable [[io .IOBase ], torch .Tensor ]],
107
+ self , resource_dps : List [IterDataPipe ], * , config : DatasetConfig
115
108
) -> IterDataPipe [Dict [str , Any ]]:
116
109
117
110
images_dp , targets_dp = resource_dps
@@ -122,4 +115,4 @@ def _make_datapipe(
122
115
dp = Zipper (images_dp , targets_dp )
123
116
dp = hint_sharding (dp )
124
117
dp = hint_shuffling (dp )
125
- return Mapper (dp , self ._collate_and_decode )
118
+ return Mapper (dp , self ._prepare_sample )
0 commit comments