flaxdiff 0.1.31__py3-none-any.whl → 0.1.32__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,7 +117,12 @@ def map_sample(
117
117
  # "error": str(e)
118
118
  # })
119
119
  pass
120
-
120
+
121
+ def default_feature_extractor(sample):
122
+ return {
123
+ "url": sample["url"],
124
+ "caption": sample["caption"],
125
+ }
121
126
 
122
127
  def map_batch(
123
128
  batch, num_threads=256, image_shape=(256, 256),
@@ -125,6 +130,7 @@ def map_batch(
125
130
  timeout=15, retries=3, image_processor=default_image_processor,
126
131
  upscale_interpolation=cv2.INTER_CUBIC,
127
132
  downscale_interpolation=cv2.INTER_AREA,
133
+ feature_extractor=default_feature_extractor,
128
134
  ):
129
135
  try:
130
136
  map_sample_fn = partial(map_sample, image_shape=image_shape, min_image_shape=min_image_shape,
@@ -132,7 +138,9 @@ def map_batch(
132
138
  upscale_interpolation=upscale_interpolation,
133
139
  downscale_interpolation=downscale_interpolation)
134
140
  with ThreadPoolExecutor(max_workers=num_threads) as executor:
135
- executor.map(map_sample_fn, batch["url"], batch['caption'])
141
+ features = feature_extractor(batch)
142
+ url, caption = features["url"], features["caption"]
143
+ executor.map(map_sample_fn, url, caption)
136
144
  except Exception as e:
137
145
  print(f"Error maping batch", e)
138
146
  traceback.print_exc()
@@ -149,12 +157,14 @@ def parallel_image_loader(
149
157
  num_threads=256, timeout=15, retries=3, image_processor=default_image_processor,
150
158
  upscale_interpolation=cv2.INTER_CUBIC,
151
159
  downscale_interpolation=cv2.INTER_AREA,
160
+ feature_extractor=default_feature_extractor,
152
161
  ):
153
162
  map_batch_fn = partial(map_batch, num_threads=num_threads, image_shape=image_shape,
154
163
  min_image_shape=min_image_shape,
155
164
  timeout=timeout, retries=retries, image_processor=image_processor,
156
165
  upscale_interpolation=upscale_interpolation,
157
- downscale_interpolation=downscale_interpolation)
166
+ downscale_interpolation=downscale_interpolation,
167
+ feature_extractor=feature_extractor)
158
168
  shard_len = len(dataset) // num_workers
159
169
  print(f"Local Shard lengths: {shard_len}")
160
170
  with multiprocessing.Pool(num_workers) as pool:
@@ -181,6 +191,7 @@ class ImageBatchIterator:
181
191
  image_processor=default_image_processor,
182
192
  upscale_interpolation=cv2.INTER_CUBIC,
183
193
  downscale_interpolation=cv2.INTER_AREA,
194
+ feature_extractor=default_feature_extractor,
184
195
  ):
185
196
  self.dataset = dataset
186
197
  self.num_workers = num_workers
@@ -191,7 +202,8 @@ class ImageBatchIterator:
191
202
  num_workers=num_workers,
192
203
  timeout=timeout, retries=retries, image_processor=image_processor,
193
204
  upscale_interpolation=upscale_interpolation,
194
- downscale_interpolation=downscale_interpolation)
205
+ downscale_interpolation=downscale_interpolation,
206
+ feature_extractor=feature_extractor)
195
207
  self.thread = threading.Thread(target=loader, args=(dataset,))
196
208
  self.thread.start()
197
209
 
@@ -256,6 +268,7 @@ class OnlineStreamingDataLoader():
256
268
  image_processor=default_image_processor,
257
269
  upscale_interpolation=cv2.INTER_CUBIC,
258
270
  downscale_interpolation=cv2.INTER_AREA,
271
+ feature_extractor=default_feature_extractor,
259
272
  ):
260
273
  if isinstance(dataset, str):
261
274
  dataset_path = dataset
@@ -281,7 +294,8 @@ class OnlineStreamingDataLoader():
281
294
  num_workers=num_workers, batch_size=batch_size, num_threads=num_threads,
282
295
  timeout=timeout, retries=retries, image_processor=image_processor,
283
296
  upscale_interpolation=upscale_interpolation,
284
- downscale_interpolation=downscale_interpolation)
297
+ downscale_interpolation=downscale_interpolation,
298
+ feature_extractor=feature_extractor)
285
299
  self.batch_size = batch_size
286
300
 
287
301
  # Launch a thread to load batches in the background
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flaxdiff
3
- Version: 0.1.31
3
+ Version: 0.1.32
4
4
  Summary: A versatile and easy to understand Diffusion library
5
5
  Author: Ashish Kumar Singh
6
6
  Author-email: ashishkmr472@gmail.com
@@ -1,7 +1,7 @@
1
1
  flaxdiff/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  flaxdiff/utils.py,sha256=B0GcHlzlVYDNEIdh2v5qmP4u0neIT-FqexNohuyuCvg,2452
3
3
  flaxdiff/data/__init__.py,sha256=PM3PkHihyohT5SHVYKc8vQ4IeVfGPpCktkSVwvqMjQ4,52
4
- flaxdiff/data/online_loader.py,sha256=LIK_O1C3yDPvvAEOWvsJrVeBopVqjg2IOMTbiSIvH6M,11025
4
+ flaxdiff/data/online_loader.py,sha256=Yi1thc2izJoXeB9UPTAkfWhWp8m4UYWi6cDwW6I6zUc,11661
5
5
  flaxdiff/models/__init__.py,sha256=FAivVYXxM2JrCFIXf-C3374RB2Hth25dBrzOeNFhH1U,26
6
6
  flaxdiff/models/attention.py,sha256=ZbDGIb5Q6FRqJ6qRY660cqw4WvF9IwCnhEuYdTpLPdM,13023
7
7
  flaxdiff/models/common.py,sha256=hWsSs2BP2J-JN1s4qLRr-h-KYkcVyl2hOp1Wsm_L-h8,10994
@@ -34,7 +34,7 @@ flaxdiff/trainer/__init__.py,sha256=T-vUVq4zHcMK6kpCsG4Gu8vn71q6lZD-lg-Ul7yKfEk,
34
34
  flaxdiff/trainer/autoencoder_trainer.py,sha256=al7AsZ7yeDMEiDD-gbcXf0ADq_xfk1VMxvg24GfA-XQ,7008
35
35
  flaxdiff/trainer/diffusion_trainer.py,sha256=wKkg63DWZjx2MoM3VQNCDIr40rWN8fUGxH9jWWxfZao,9373
36
36
  flaxdiff/trainer/simple_trainer.py,sha256=Z77zRS5viJpd2Mpl6sonJk5WcnEWi2Cd4gl4u5tIX2M,18206
37
- flaxdiff-0.1.31.dist-info/METADATA,sha256=Vh-cTPdUEyYBY-SFA7GxIVXucEOlDqDqkGULQyw6TIM,22083
38
- flaxdiff-0.1.31.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
39
- flaxdiff-0.1.31.dist-info/top_level.txt,sha256=-2-nXnfkJgSfkki1tjm5Faw6Dso7vhtdn2szwCdX5CQ,9
40
- flaxdiff-0.1.31.dist-info/RECORD,,
37
+ flaxdiff-0.1.32.dist-info/METADATA,sha256=yqODOUEAlcE_60tOOfSP7XoH0VTBm3dY9J1ali36VFY,22083
38
+ flaxdiff-0.1.32.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
39
+ flaxdiff-0.1.32.dist-info/top_level.txt,sha256=-2-nXnfkJgSfkki1tjm5Faw6Dso7vhtdn2szwCdX5CQ,9
40
+ flaxdiff-0.1.32.dist-info/RECORD,,