flaxdiff 0.1.36.1__py3-none-any.whl → 0.1.36.2__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.
- data/__init__.py +1 -0
- data/dataset_map.py +71 -0
- data/datasets.py +169 -0
- data/online_loader.py +363 -0
- data/sources/gcs.py +81 -0
- data/sources/tfds.py +67 -0
- {flaxdiff-0.1.36.1.dist-info → flaxdiff-0.1.36.2.dist-info}/METADATA +1 -1
- flaxdiff-0.1.36.2.dist-info/RECORD +47 -0
- flaxdiff-0.1.36.2.dist-info/top_level.txt +9 -0
- metrics/inception.py +658 -0
- metrics/utils.py +49 -0
- models/__init__.py +1 -0
- models/attention.py +368 -0
- models/autoencoder/__init__.py +2 -0
- models/autoencoder/autoencoder.py +19 -0
- models/autoencoder/diffusers.py +91 -0
- models/autoencoder/simple_autoenc.py +26 -0
- models/common.py +346 -0
- models/favor_fastattn.py +723 -0
- models/simple_unet.py +233 -0
- models/simple_vit.py +180 -0
- predictors/__init__.py +96 -0
- samplers/__init__.py +7 -0
- samplers/common.py +165 -0
- samplers/ddim.py +10 -0
- samplers/ddpm.py +37 -0
- samplers/euler.py +56 -0
- samplers/heun_sampler.py +27 -0
- samplers/multistep_dpm.py +59 -0
- samplers/rk4_sampler.py +34 -0
- schedulers/__init__.py +6 -0
- schedulers/common.py +98 -0
- schedulers/continuous.py +12 -0
- schedulers/cosine.py +40 -0
- schedulers/discrete.py +74 -0
- schedulers/exp.py +13 -0
- schedulers/karras.py +69 -0
- schedulers/linear.py +14 -0
- schedulers/sqrt.py +10 -0
- trainer/__init__.py +2 -0
- trainer/autoencoder_trainer.py +182 -0
- trainer/diffusion_trainer.py +326 -0
- trainer/simple_trainer.py +540 -0
- trainer/video_diffusion_trainer.py +62 -0
- flaxdiff-0.1.36.1.dist-info/RECORD +0 -6
- flaxdiff-0.1.36.1.dist-info/top_level.txt +0 -1
- /flaxdiff/__init__.py → /__init__.py +0 -0
- {flaxdiff-0.1.36.1.dist-info → flaxdiff-0.1.36.2.dist-info}/WHEEL +0 -0
- /flaxdiff/utils.py → /utils.py +0 -0
data/sources/tfds.py
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
import cv2
|
2
|
+
import jax.numpy as jnp
|
3
|
+
import grain.python as pygrain
|
4
|
+
from flaxdiff.utils import AutoTextTokenizer
|
5
|
+
from typing import Dict
|
6
|
+
import random
|
7
|
+
|
8
|
+
# -----------------------------------------------------------------------------------------------#
|
9
|
+
# Oxford flowers and other TFDS datasources -----------------------------------------------------#
|
10
|
+
# -----------------------------------------------------------------------------------------------#
|
11
|
+
|
12
|
+
PROMPT_TEMPLATES = [
|
13
|
+
"a photo of a {}",
|
14
|
+
"a photo of a {} flower",
|
15
|
+
"This is a photo of a {}",
|
16
|
+
"This is a photo of a {} flower",
|
17
|
+
"A photo of a {} flower",
|
18
|
+
]
|
19
|
+
|
20
|
+
def data_source_tfds(name, use_tf=True, split="all"):
|
21
|
+
import tensorflow_datasets as tfds
|
22
|
+
if use_tf:
|
23
|
+
def data_source(path_override):
|
24
|
+
return tfds.load(name, split=split, shuffle_files=True)
|
25
|
+
else:
|
26
|
+
def data_source(path_override):
|
27
|
+
return tfds.data_source(name, split=split, try_gcs=False)
|
28
|
+
return data_source
|
29
|
+
|
30
|
+
def labelizer_oxford_flowers102(path):
|
31
|
+
with open(path, "r") as f:
|
32
|
+
textlabels = [i.strip() for i in f.readlines()]
|
33
|
+
|
34
|
+
def load_labels(sample):
|
35
|
+
raw = textlabels[int(sample['label'])]
|
36
|
+
# randomly select a prompt template
|
37
|
+
template = random.choice(PROMPT_TEMPLATES)
|
38
|
+
# format the template with the label
|
39
|
+
caption = template.format(raw)
|
40
|
+
# return the caption
|
41
|
+
return caption
|
42
|
+
return load_labels
|
43
|
+
|
44
|
+
def tfds_augmenters(image_scale, method):
|
45
|
+
labelizer = labelizer_oxford_flowers102("/home/mrwhite0racle/tensorflow_datasets/oxford_flowers102/2.1.1/label.labels.txt")
|
46
|
+
if image_scale > 256:
|
47
|
+
interpolation = cv2.INTER_CUBIC
|
48
|
+
else:
|
49
|
+
interpolation = cv2.INTER_AREA
|
50
|
+
class augmenters(pygrain.MapTransform):
|
51
|
+
def __init__(self, *args, **kwargs):
|
52
|
+
super().__init__(*args, **kwargs)
|
53
|
+
self.tokenize = AutoTextTokenizer(tensor_type="np")
|
54
|
+
|
55
|
+
def map(self, element) -> Dict[str, jnp.array]:
|
56
|
+
image = element['image']
|
57
|
+
image = cv2.resize(image, (image_scale, image_scale),
|
58
|
+
interpolation=interpolation)
|
59
|
+
# image = (image - 127.5) / 127.5
|
60
|
+
caption = labelizer(element)
|
61
|
+
results = self.tokenize(caption)
|
62
|
+
return {
|
63
|
+
"image": image,
|
64
|
+
"input_ids": results['input_ids'][0],
|
65
|
+
"attention_mask": results['attention_mask'][0],
|
66
|
+
}
|
67
|
+
return augmenters
|
@@ -0,0 +1,47 @@
|
|
1
|
+
__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
utils.py,sha256=b_hFXsam2NICQYCFk0EOcqtBjM-RUqnN0NKTn0lQ070,6532
|
3
|
+
data/__init__.py,sha256=PM3PkHihyohT5SHVYKc8vQ4IeVfGPpCktkSVwvqMjQ4,52
|
4
|
+
data/dataset_map.py,sha256=hcHaoR2IbNQmfyPUhYd6_8xinurxxCqawQijAsDI0Ek,3093
|
5
|
+
data/datasets.py,sha256=YUMoSvF2yAyikRvRofZVlHwfEOU3zXSSG4KkLnVfpoA,5626
|
6
|
+
data/online_loader.py,sha256=1Fi_QRixxRzbt602nORINcDeHEccvCrBpagrz4PURYg,12499
|
7
|
+
data/sources/gcs.py,sha256=11ZuQhvMyJRLg21DgVdzO5qEuae7zgzTXGNOskF-cbs,3380
|
8
|
+
data/sources/tfds.py,sha256=WA3h9lyR4yotCNEmJON2noIN-2HNcqhf6zigx1XXsMI,2481
|
9
|
+
metrics/inception.py,sha256=a5kjMCPMT9gB88c_HCKiek-2vsAyoE35K7nDt4h4pVI,31843
|
10
|
+
metrics/utils.py,sha256=YuuOfqvqgIjsceupwNeJ59vQ2TnGeNMIyKdkIqOmoNg,1702
|
11
|
+
models/__init__.py,sha256=FAivVYXxM2JrCFIXf-C3374RB2Hth25dBrzOeNFhH1U,26
|
12
|
+
models/attention.py,sha256=JvrP7-09MV6IfRLRBhqjPmNUU-lkEMk9TOnJSBKcar8,13289
|
13
|
+
models/common.py,sha256=hWsSs2BP2J-JN1s4qLRr-h-KYkcVyl2hOp1Wsm_L-h8,10994
|
14
|
+
models/favor_fastattn.py,sha256=79Ew1nqarsNLPzZaBSd1ILORzJr74CupYeqGiCQK5E4,27689
|
15
|
+
models/simple_unet.py,sha256=L5m2j5580QP7pJ5VIme7U5xYA22PZiGP7qdvcKUnB38,11463
|
16
|
+
models/simple_vit.py,sha256=UCDDr0XVnpf6tbJWKFtEt3_nAqMqOoakXf5amyVWZNo,7929
|
17
|
+
models/autoencoder/__init__.py,sha256=qY-7MldZpsfkF-_T2LqlRK7VHbqfmosz0NmvzDlBkOk,78
|
18
|
+
models/autoencoder/autoencoder.py,sha256=27_hYl0yXAdH9Mx4Xu9J79mSNo-FEKr9SxhVaS3ffn4,591
|
19
|
+
models/autoencoder/diffusers.py,sha256=JHeFLCxiHhu-QHwhKiCuKsQJn4AZumquiuxgZkiYGQ0,3643
|
20
|
+
models/autoencoder/simple_autoenc.py,sha256=UXHPgDmwGTnv3Uts6Zj3p9R9nJXnEiEXbllgarwDfXM,805
|
21
|
+
predictors/__init__.py,sha256=SKkYYRF9Wfgk2zhtZw4vCXOdOeRlrm2Mk6cvuaEvAzc,4403
|
22
|
+
samplers/__init__.py,sha256=_S-9TwDeshrI0VmapV-J2hqjTByOa0-oOeUs_IdovjU,285
|
23
|
+
samplers/common.py,sha256=ZA08VyovxegpRx4wOQq9LSwZi0gSCz2lrbS5oVYOEYg,8488
|
24
|
+
samplers/ddim.py,sha256=pB8Kod8ZLJ3GXev4uM3cOj1Uy6ibR0jsaZa-VE0fyJM,552
|
25
|
+
samplers/ddpm.py,sha256=u1OchQu0XPhc_6w9JXoaFp2wo4y-zXyQNtGAIJwxNLg,2209
|
26
|
+
samplers/euler.py,sha256=Htb-IJeu7jSgY6mvgYr9yl9pUnos49vijlVk5IQsRps,2740
|
27
|
+
samplers/heun_sampler.py,sha256=UyI-hSlyWvt-7VEUJj27zjgyzKkGVl8fDUHV-YpSOCc,1421
|
28
|
+
samplers/multistep_dpm.py,sha256=3Wu3MrMLYaBb1ObraTbWrJmtEtU0adl1dDbz5fPJ4Gs,2735
|
29
|
+
samplers/rk4_sampler.py,sha256=1j1pES_Q2QiaURvEWeedbbT1LHmkc3jsu0GgH83qBL0,1926
|
30
|
+
schedulers/__init__.py,sha256=3id390WEfdf-MN-oLSPAhlRFIXrFWr6ioAHPAwURJyE,375
|
31
|
+
schedulers/common.py,sha256=b-W4iI-aqScpVE8VZbBpiYvAVI6rqDkUP-C_hEVBwCI,4151
|
32
|
+
schedulers/continuous.py,sha256=5c_niOA20fxJ5oJDi09FfayIRogBGwtfG0XThW2IUZk,334
|
33
|
+
schedulers/cosine.py,sha256=9ban0dFHLMm35wQvaBT4nCQwPGmzNsXwQ1xI0oppmJI,2005
|
34
|
+
schedulers/discrete.py,sha256=O54wH2HVu3olJA71NxgAXFW9cr6B6Gl-DR_uZeytpds,3319
|
35
|
+
schedulers/exp.py,sha256=cPTnUJpYdzJRRZqMLYQz0rRUCpEmaP2tXhRumLx94jA,605
|
36
|
+
schedulers/karras.py,sha256=4GN120kGwdxxU-h2mVdhBVy9IORkUMm_vvz3XjthBcI,3355
|
37
|
+
schedulers/linear.py,sha256=6003F5ISq1Wc0h6UAzY95MJgsDIKGMhBzbiVALpea0k,581
|
38
|
+
schedulers/sqrt.py,sha256=1F84ZgQPuoNMhe6yxGTR2G0h7dPOZtm4UDQOakbSsEU,445
|
39
|
+
trainer/__init__.py,sha256=T-vUVq4zHcMK6kpCsG4Gu8vn71q6lZD-lg-Ul7yKfEk,128
|
40
|
+
trainer/autoencoder_trainer.py,sha256=hxihkRL9WCIQVGOP-pc1jjjIUaRXDLcNo3_erTKsuWM,7049
|
41
|
+
trainer/diffusion_trainer.py,sha256=ajOWBgFFwXP_VQScUjcuPoaB4Gk02aF0Ls5LNlA8wqA,12691
|
42
|
+
trainer/simple_trainer.py,sha256=lmRo8N0bMupIyS3ejPvPtxoskY_3GLC8iyJE6u4TIWc,21990
|
43
|
+
trainer/video_diffusion_trainer.py,sha256=gMkKpnKNTo8QhTx5ptEEkc7W5-7rzXIr9queU53hXyQ,2197
|
44
|
+
flaxdiff-0.1.36.2.dist-info/METADATA,sha256=4c3Kl8wDAN6pzg_nLfQ3VSbN6e9xVv3flLCsh1ub-4U,22310
|
45
|
+
flaxdiff-0.1.36.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
46
|
+
flaxdiff-0.1.36.2.dist-info/top_level.txt,sha256=FMc3ZGZsKPjeaG9fWYdPl5HYvG4JBNSxqXJj2WwJz6s,74
|
47
|
+
flaxdiff-0.1.36.2.dist-info/RECORD,,
|