File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 4343PREFETCH_SIZE = int (os .environ .get ('TFDS_PREFETCH_SIZE' , 2048 )) # samples to prefetch
4444
4545
46+ @tfds .decode .make_decoder ()
47+ def decode_example (serialized_image , feature , dct_method = 'INTEGER_ACCURATE' ):
48+ return tf .image .decode_jpeg (
49+ serialized_image ,
50+ channels = 3 ,
51+ dct_method = dct_method ,
52+ )
53+
54+
4655def even_split_indices (split , n , num_samples ):
4756 partitions = [round (i * num_samples / n ) for i in range (n + 1 )]
4857 return [f"{ split } [{ partitions [i ]} :{ partitions [i + 1 ]} ]" for i in range (n )]
@@ -242,6 +251,7 @@ def _lazy_init(self):
242251 ds = self .builder .as_dataset (
243252 split = self .subsplit or self .split ,
244253 shuffle_files = self .is_training ,
254+ decoders = dict (image = decode_example ()),
245255 read_config = read_config ,
246256 )
247257 # avoid overloading threading w/ combo of TF ds threads + PyTorch workers
You can’t perform that action at this time.
0 commit comments