Instructions to use AiArtLab/sdxs-1b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use AiArtLab/sdxs-1b with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("AiArtLab/sdxs-1b", dtype=torch.bfloat16, device_map="cuda") prompt = "sdxs-1b" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
2604
Browse files- README.md +4 -4
- media/gandr.jpg +2 -2
- media/girl1.jpg +2 -2
- media/result_grid.jpg +2 -2
- pipeline_sdxs.py +3 -4
- samples/unet_384x704_0.jpg +2 -2
- samples/unet_416x704_0.jpg +2 -2
- samples/unet_448x704_0.jpg +2 -2
- samples/unet_480x704_0.jpg +2 -2
- samples/unet_512x704_0.jpg +2 -2
- samples/unet_544x704_0.jpg +2 -2
- samples/unet_576x704_0.jpg +2 -2
- samples/unet_608x704_0.jpg +2 -2
- samples/unet_640x704_0.jpg +2 -2
- samples/unet_672x704_0.jpg +2 -2
- samples/unet_704x384_0.jpg +2 -2
- samples/unet_704x416_0.jpg +2 -2
- samples/unet_704x448_0.jpg +2 -2
- samples/unet_704x480_0.jpg +2 -2
- samples/unet_704x512_0.jpg +2 -2
- samples/unet_704x544_0.jpg +2 -2
- samples/unet_704x576_0.jpg +2 -2
- samples/unet_704x608_0.jpg +2 -2
- samples/unet_704x640_0.jpg +2 -2
- samples/unet_704x672_0.jpg +2 -2
- samples/unet_704x704_0.jpg +2 -2
- test.ipynb +2 -2
- train.py +8 -6
- unet/diffusion_pytorch_model.safetensors +1 -1
README.md
CHANGED
|
@@ -11,7 +11,7 @@ datasets:
|
|
| 11 |
|
| 12 |
*XS Size, Excess Quality (not for now)*
|
| 13 |
|
| 14 |
-
Train status:
|
| 15 |
|
| 16 |
<img src="media/gandr.jpg" height="256"/>
|
| 17 |
|
|
@@ -325,7 +325,7 @@ cd sdxs-1b
|
|
| 325 |
pip install -r requirements.txt -U
|
| 326 |
mkdir datasets
|
| 327 |
cd datasets
|
| 328 |
-
hf download babkasotona/ds1234_noanime_704_vae8x16x --repo-type dataset --local-dir ds1234_noanime_704_vae8x16x
|
| 329 |
cd ..
|
| 330 |
nohup accelerate launch train.py &
|
| 331 |
```
|
|
@@ -337,9 +337,9 @@ nohup accelerate launch train.py &
|
|
| 337 |
- **[CaptionEmporium](https://huggingface.co/CaptionEmporium)**
|
| 338 |
|
| 339 |
## Donations
|
| 340 |
-
Thanks for your support! Every $5 equals a full day of RTX
|
| 341 |
|
| 342 |
-
- Euro / dollars
|
| 343 |
- RUB: [donate in rub](https://www.tbank.ru/cf/90ensBQqpJj)
|
| 344 |
- DOGE: DEw2DR8C7BnF8GgcrfTzUjSnGkuMeJhg83
|
| 345 |
- BTC: 3JHv9Hb8kEW8zMAccdgCdZGfrHeMhH1rpN
|
|
|
|
| 11 |
|
| 12 |
*XS Size, Excess Quality (not for now)*
|
| 13 |
|
| 14 |
+
Train status: 1xRTX4090 / we need more gold / [support us please..](https://huggingface.co/AiArtLab/sdxs-1b#donations)
|
| 15 |
|
| 16 |
<img src="media/gandr.jpg" height="256"/>
|
| 17 |
|
|
|
|
| 325 |
pip install -r requirements.txt -U
|
| 326 |
mkdir datasets
|
| 327 |
cd datasets
|
| 328 |
+
#hf download babkasotona/ds1234_noanime_704_vae8x16x --repo-type dataset --local-dir ds1234_noanime_704_vae8x16x
|
| 329 |
cd ..
|
| 330 |
nohup accelerate launch train.py &
|
| 331 |
```
|
|
|
|
| 337 |
- **[CaptionEmporium](https://huggingface.co/CaptionEmporium)**
|
| 338 |
|
| 339 |
## Donations
|
| 340 |
+
Thanks for your support! Every $5 equals a full day of RTX 4090 rental and makes the waifu 0.01% better!
|
| 341 |
|
| 342 |
+
- Euro / dollars: sorry, we can’t accept payments via Patreon or Ko-fi. Please register on [vast.ai](https://cloud.vast.ai/billing/) (this is the GPU provider we use for training the model), top up any amount, and transfer: Transfer Money / User / Email: vadim-kulibaba@yandex.ru.
|
| 343 |
- RUB: [donate in rub](https://www.tbank.ru/cf/90ensBQqpJj)
|
| 344 |
- DOGE: DEw2DR8C7BnF8GgcrfTzUjSnGkuMeJhg83
|
| 345 |
- BTC: 3JHv9Hb8kEW8zMAccdgCdZGfrHeMhH1rpN
|
media/gandr.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
media/girl1.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
media/result_grid.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
pipeline_sdxs.py
CHANGED
|
@@ -14,7 +14,7 @@ class SdxsPipelineOutput(BaseOutput):
|
|
| 14 |
prompt: Optional[Union[str, List[str]]] = None
|
| 15 |
|
| 16 |
class SdxsPipeline(DiffusionPipeline):
|
| 17 |
-
MAX_TEXT_TOKENS =
|
| 18 |
|
| 19 |
def __init__(self, vae, text_encoder, processor, tokenizer, unet, scheduler):
|
| 20 |
super().__init__()
|
|
@@ -154,9 +154,8 @@ class SdxsPipeline(DiffusionPipeline):
|
|
| 154 |
final_mask = torch.cat([torch.ones((batch_size, 1), device=device, dtype=inputs.attention_mask.dtype), inputs.attention_mask], dim=1)
|
| 155 |
|
| 156 |
return final_embeddings.to(dtype=dtype), final_mask.to(dtype=torch.int64)
|
|
|
|
| 157 |
@torch.no_grad()
|
| 158 |
-
|
| 159 |
-
|
| 160 |
def encode_text_and_image_naive(self, text: Union[str, List[str]], image: Optional[Union[Image.Image, List[Image.Image], str, List[str]]] = None, scale = 0.5) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 161 |
# 1. Получаем текстовый эмбеддинг
|
| 162 |
text_embeds, text_mask = self.encode_text(text)
|
|
@@ -276,7 +275,7 @@ class SdxsPipeline(DiffusionPipeline):
|
|
| 276 |
height: int = 1408,
|
| 277 |
width: int = 1024,
|
| 278 |
num_inference_steps: int = 40,
|
| 279 |
-
guidance_scale: float =
|
| 280 |
generator: Optional[torch.Generator] = None,
|
| 281 |
seed: Optional[int] = None,
|
| 282 |
output_type: str = "pil",
|
|
|
|
| 14 |
prompt: Optional[Union[str, List[str]]] = None
|
| 15 |
|
| 16 |
class SdxsPipeline(DiffusionPipeline):
|
| 17 |
+
MAX_TEXT_TOKENS = 250
|
| 18 |
|
| 19 |
def __init__(self, vae, text_encoder, processor, tokenizer, unet, scheduler):
|
| 20 |
super().__init__()
|
|
|
|
| 154 |
final_mask = torch.cat([torch.ones((batch_size, 1), device=device, dtype=inputs.attention_mask.dtype), inputs.attention_mask], dim=1)
|
| 155 |
|
| 156 |
return final_embeddings.to(dtype=dtype), final_mask.to(dtype=torch.int64)
|
| 157 |
+
|
| 158 |
@torch.no_grad()
|
|
|
|
|
|
|
| 159 |
def encode_text_and_image_naive(self, text: Union[str, List[str]], image: Optional[Union[Image.Image, List[Image.Image], str, List[str]]] = None, scale = 0.5) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 160 |
# 1. Получаем текстовый эмбеддинг
|
| 161 |
text_embeds, text_mask = self.encode_text(text)
|
|
|
|
| 275 |
height: int = 1408,
|
| 276 |
width: int = 1024,
|
| 277 |
num_inference_steps: int = 40,
|
| 278 |
+
guidance_scale: float = 4.0,
|
| 279 |
generator: Optional[torch.Generator] = None,
|
| 280 |
seed: Optional[int] = None,
|
| 281 |
output_type: str = "pil",
|
samples/unet_384x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_416x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_448x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_480x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_512x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_544x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_576x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_608x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_672x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x384_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x416_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x448_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x480_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x512_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x544_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x576_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x608_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x672_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_704x704_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
test.ipynb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f490d6558ed482b844dcac5723d174fe4bd5a13f4767641cff9c306ee05f385
|
| 3 |
+
size 17750930
|
train.py
CHANGED
|
@@ -32,7 +32,7 @@ os.environ["NCCL_IB_DISABLE"] = "1" # comment this on H100!
|
|
| 32 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
|
| 33 |
|
| 34 |
# --------------------------- Параметры ---------------------------
|
| 35 |
-
ds_path = "datasets/ds1234_noanime_704_vae8x16x" #
|
| 36 |
project = "unet"
|
| 37 |
|
| 38 |
gpu_mem_gb = torch.cuda.get_device_properties(0).total_memory / 1e9
|
|
@@ -62,7 +62,7 @@ use_wandb = True
|
|
| 62 |
use_comet_ml = False
|
| 63 |
save_model = True
|
| 64 |
use_decay = True
|
| 65 |
-
fbp =
|
| 66 |
torch_compile = False
|
| 67 |
unet_gradient = True
|
| 68 |
loss_normalize = False
|
|
@@ -83,13 +83,13 @@ torch.backends.cuda.enable_math_sdp(False) # Отключаем медленны
|
|
| 83 |
save_barrier = 1.25
|
| 84 |
warmup_percent = 0.0025
|
| 85 |
betta2 = 0.997
|
| 86 |
-
eps = 1e-
|
| 87 |
clip_grad_norm = 1.0
|
| 88 |
limit = 0
|
| 89 |
checkpoints_folder = ""
|
| 90 |
gradient_accumulation_steps = 1
|
| 91 |
dtype = torch.float32
|
| 92 |
-
mixed_precision = "
|
| 93 |
|
| 94 |
# Параметры для диффузии
|
| 95 |
n_diffusion_steps = 40
|
|
@@ -461,11 +461,11 @@ else:
|
|
| 461 |
def create_optimizer(name, params):
|
| 462 |
if name == "adam8bit":
|
| 463 |
return bnb.optim.AdamW8bit(
|
| 464 |
-
params, lr=base_learning_rate, betas=(0.9, betta2), eps=eps, weight_decay=0.
|
| 465 |
)
|
| 466 |
elif name == "adam":
|
| 467 |
return torch.optim.AdamW(
|
| 468 |
-
params, lr=base_learning_rate, betas=(0.9, betta2), eps=eps, weight_decay=0.
|
| 469 |
)
|
| 470 |
elif name == "muon_adam8bit":
|
| 471 |
return MuonAdamW8bit(
|
|
@@ -799,6 +799,8 @@ for epoch in range(start_epoch, start_epoch + num_epochs):
|
|
| 799 |
|
| 800 |
# 3. Время t, bias = -0.5 (Фокус на Деталях ~300) bias = 0.5 (Фокус на структуре) bias = 0 (колокол/ равномерно)
|
| 801 |
bias = 0.2
|
|
|
|
|
|
|
| 802 |
t = torch.sigmoid(torch.randn(latents.shape[0], device=latents.device, dtype=latents.dtype) + bias)
|
| 803 |
|
| 804 |
# интерполяция между x0 и шумом
|
|
|
|
| 32 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
|
| 33 |
|
| 34 |
# --------------------------- Параметры ---------------------------
|
| 35 |
+
ds_path = "datasets/alchemist_704_vae8x16x_imgpool" #ds1234_noanime_704_vae8x16x" #"
|
| 36 |
project = "unet"
|
| 37 |
|
| 38 |
gpu_mem_gb = torch.cuda.get_device_properties(0).total_memory / 1e9
|
|
|
|
| 62 |
use_comet_ml = False
|
| 63 |
save_model = True
|
| 64 |
use_decay = True
|
| 65 |
+
fbp = True
|
| 66 |
torch_compile = False
|
| 67 |
unet_gradient = True
|
| 68 |
loss_normalize = False
|
|
|
|
| 83 |
save_barrier = 1.25
|
| 84 |
warmup_percent = 0.0025
|
| 85 |
betta2 = 0.997
|
| 86 |
+
eps = 1e-6
|
| 87 |
clip_grad_norm = 1.0
|
| 88 |
limit = 0
|
| 89 |
checkpoints_folder = ""
|
| 90 |
gradient_accumulation_steps = 1
|
| 91 |
dtype = torch.float32
|
| 92 |
+
mixed_precision = "bf16"
|
| 93 |
|
| 94 |
# Параметры для диффузии
|
| 95 |
n_diffusion_steps = 40
|
|
|
|
| 461 |
def create_optimizer(name, params):
|
| 462 |
if name == "adam8bit":
|
| 463 |
return bnb.optim.AdamW8bit(
|
| 464 |
+
params, lr=base_learning_rate, betas=(0.9, betta2), eps=eps, weight_decay=0.001
|
| 465 |
)
|
| 466 |
elif name == "adam":
|
| 467 |
return torch.optim.AdamW(
|
| 468 |
+
params, lr=base_learning_rate, betas=(0.9, betta2), eps=eps, weight_decay=0.001
|
| 469 |
)
|
| 470 |
elif name == "muon_adam8bit":
|
| 471 |
return MuonAdamW8bit(
|
|
|
|
| 799 |
|
| 800 |
# 3. Время t, bias = -0.5 (Фокус на Деталях ~300) bias = 0.5 (Фокус на структуре) bias = 0 (колокол/ равномерно)
|
| 801 |
bias = 0.2
|
| 802 |
+
if lvl>3:
|
| 803 |
+
bias = -0.2
|
| 804 |
t = torch.sigmoid(torch.randn(latents.shape[0], device=latents.device, dtype=latents.dtype) + bias)
|
| 805 |
|
| 806 |
# интерполяция между x0 и шумом
|
unet/diffusion_pytorch_model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 3210307232
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:656fb4709a2c0a80f31787fd508c946b569a63d4b700aa8817bdc1e77ac4b163
|
| 3 |
size 3210307232
|