flaxdiff 0.1.19__tar.gz → 0.1.20__tar.gz
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.
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/PKG-INFO +1 -1
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/data/online_loader.py +28 -18
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff.egg-info/PKG-INFO +1 -1
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/setup.py +1 -1
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/README.md +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/data/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/attention.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/autoencoder/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/autoencoder/autoencoder.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/autoencoder/diffusers.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/autoencoder/simple_autoenc.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/common.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/favor_fastattn.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/simple_unet.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/models/simple_vit.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/predictors/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/common.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/ddim.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/ddpm.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/euler.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/heun_sampler.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/multistep_dpm.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/samplers/rk4_sampler.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/common.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/continuous.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/cosine.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/discrete.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/exp.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/karras.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/linear.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/schedulers/sqrt.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/trainer/__init__.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/trainer/autoencoder_trainer.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/trainer/diffusion_trainer.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/trainer/simple_trainer.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff/utils.py +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff.egg-info/SOURCES.txt +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff.egg-info/dependency_links.txt +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff.egg-info/requires.txt +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/flaxdiff.egg-info/top_level.txt +0 -0
- {flaxdiff-0.1.19 → flaxdiff-0.1.20}/setup.cfg +0 -0
@@ -25,7 +25,6 @@ import cv2
|
|
25
25
|
USER_AGENT = get_datasets_user_agent()
|
26
26
|
|
27
27
|
data_queue = Queue(16*2000)
|
28
|
-
error_queue = Queue()
|
29
28
|
|
30
29
|
|
31
30
|
def fetch_single_image(image_url, timeout=None, retries=0):
|
@@ -60,6 +59,7 @@ def default_image_processor(image, image_shape, interpolation=cv2.INTER_CUBIC):
|
|
60
59
|
def map_sample(
|
61
60
|
url, caption,
|
62
61
|
image_shape=(256, 256),
|
62
|
+
min_image_shape=(128, 128),
|
63
63
|
timeout=15,
|
64
64
|
retries=3,
|
65
65
|
upscale_interpolation=cv2.INTER_CUBIC,
|
@@ -75,10 +75,10 @@ def map_sample(
|
|
75
75
|
image = np.array(image)
|
76
76
|
original_height, original_width = image.shape[:2]
|
77
77
|
# check if the image is too small
|
78
|
-
if min(original_height, original_width) < min(
|
78
|
+
if min(original_height, original_width) < min(min_image_shape):
|
79
79
|
return
|
80
80
|
# check if wrong aspect ratio
|
81
|
-
if max(original_height, original_width) / min(original_height, original_width) > 2:
|
81
|
+
if max(original_height, original_width) / min(original_height, original_width) > 2.4:
|
82
82
|
return
|
83
83
|
# check if the variance is too low
|
84
84
|
if np.std(image) < 1e-4:
|
@@ -98,40 +98,45 @@ def map_sample(
|
|
98
98
|
"original_width": original_width,
|
99
99
|
})
|
100
100
|
except Exception as e:
|
101
|
-
error_queue.put_nowait({
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
})
|
101
|
+
# error_queue.put_nowait({
|
102
|
+
# "url": url,
|
103
|
+
# "caption": caption,
|
104
|
+
# "error": str(e)
|
105
|
+
# })
|
106
|
+
pass
|
106
107
|
|
107
108
|
|
108
109
|
def map_batch(
|
109
110
|
batch, num_threads=256, image_shape=(256, 256),
|
111
|
+
min_image_shape=(128, 128),
|
110
112
|
timeout=15, retries=3, image_processor=default_image_processor,
|
111
113
|
upscale_interpolation=cv2.INTER_CUBIC,
|
112
114
|
downscale_interpolation=cv2.INTER_AREA,
|
113
115
|
):
|
114
116
|
try:
|
115
|
-
map_sample_fn = partial(map_sample, image_shape=image_shape,
|
117
|
+
map_sample_fn = partial(map_sample, image_shape=image_shape, min_image_shape=min_image_shape,
|
116
118
|
timeout=timeout, retries=retries, image_processor=image_processor,
|
117
119
|
upscale_interpolation=upscale_interpolation,
|
118
120
|
downscale_interpolation=downscale_interpolation)
|
119
121
|
with ThreadPoolExecutor(max_workers=num_threads) as executor:
|
120
122
|
executor.map(map_sample_fn, batch["url"], batch['caption'])
|
121
123
|
except Exception as e:
|
122
|
-
error_queue.
|
123
|
-
|
124
|
-
|
125
|
-
})
|
124
|
+
# error_queue.put_nowait({
|
125
|
+
# "batch": batch,
|
126
|
+
# "error": str(e)
|
127
|
+
# })
|
128
|
+
pass
|
126
129
|
|
127
130
|
|
128
131
|
def parallel_image_loader(
|
129
132
|
dataset: Dataset, num_workers: int = 8, image_shape=(256, 256),
|
133
|
+
min_image_shape=(128, 128),
|
130
134
|
num_threads=256, timeout=15, retries=3, image_processor=default_image_processor,
|
131
135
|
upscale_interpolation=cv2.INTER_CUBIC,
|
132
136
|
downscale_interpolation=cv2.INTER_AREA,
|
133
137
|
):
|
134
|
-
map_batch_fn = partial(map_batch, num_threads=num_threads, image_shape=image_shape,
|
138
|
+
map_batch_fn = partial(map_batch, num_threads=num_threads, image_shape=image_shape,
|
139
|
+
min_image_shape=min_image_shape,
|
135
140
|
timeout=timeout, retries=retries, image_processor=image_processor,
|
136
141
|
upscale_interpolation=upscale_interpolation,
|
137
142
|
downscale_interpolation=downscale_interpolation)
|
@@ -149,13 +154,14 @@ def parallel_image_loader(
|
|
149
154
|
print(f"Shuffling dataset with seed {iteration}")
|
150
155
|
dataset = dataset.shuffle(seed=iteration)
|
151
156
|
# Clear the error queue
|
152
|
-
while not error_queue.empty():
|
153
|
-
|
157
|
+
# while not error_queue.empty():
|
158
|
+
# error_queue.get_nowait()
|
154
159
|
|
155
160
|
|
156
161
|
class ImageBatchIterator:
|
157
162
|
def __init__(
|
158
163
|
self, dataset: Dataset, batch_size: int = 64, image_shape=(256, 256),
|
164
|
+
min_image_shape=(128, 128),
|
159
165
|
num_workers: int = 8, num_threads=256, timeout=15, retries=3,
|
160
166
|
image_processor=default_image_processor,
|
161
167
|
upscale_interpolation=cv2.INTER_CUBIC,
|
@@ -165,7 +171,9 @@ class ImageBatchIterator:
|
|
165
171
|
self.num_workers = num_workers
|
166
172
|
self.batch_size = batch_size
|
167
173
|
loader = partial(parallel_image_loader, num_threads=num_threads,
|
168
|
-
image_shape=image_shape,
|
174
|
+
image_shape=image_shape,
|
175
|
+
min_image_shape=min_image_shape,
|
176
|
+
num_workers=num_workers,
|
169
177
|
timeout=timeout, retries=retries, image_processor=image_processor,
|
170
178
|
upscale_interpolation=upscale_interpolation,
|
171
179
|
downscale_interpolation=downscale_interpolation)
|
@@ -215,6 +223,7 @@ class OnlineStreamingDataLoader():
|
|
215
223
|
dataset,
|
216
224
|
batch_size=64,
|
217
225
|
image_shape=(256, 256),
|
226
|
+
min_image_shape=(128, 128),
|
218
227
|
num_workers=16,
|
219
228
|
num_threads=512,
|
220
229
|
default_split="all",
|
@@ -253,8 +262,9 @@ class OnlineStreamingDataLoader():
|
|
253
262
|
num_shards=global_process_count, index=global_process_index)
|
254
263
|
print(f"Dataset length: {len(dataset)}")
|
255
264
|
self.iterator = ImageBatchIterator(self.dataset, image_shape=image_shape,
|
265
|
+
min_image_shape=min_image_shape,
|
256
266
|
num_workers=num_workers, batch_size=batch_size, num_threads=num_threads,
|
257
|
-
|
267
|
+
timeout=timeout, retries=retries, image_processor=image_processor,
|
258
268
|
upscale_interpolation=upscale_interpolation,
|
259
269
|
downscale_interpolation=downscale_interpolation)
|
260
270
|
self.batch_size = batch_size
|
@@ -11,7 +11,7 @@ required_packages=[
|
|
11
11
|
setup(
|
12
12
|
name='flaxdiff',
|
13
13
|
packages=find_packages(),
|
14
|
-
version='0.1.
|
14
|
+
version='0.1.20',
|
15
15
|
description='A versatile and easy to understand Diffusion library',
|
16
16
|
long_description=open('README.md').read(),
|
17
17
|
long_description_content_type='text/markdown',
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|