2511
Browse files- media/result_grid.jpg +2 -2
- media/result_grid.png +0 -3
- samples/unet_320x640_0.jpg +2 -2
- samples/unet_384x640_0.jpg +2 -2
- samples/unet_448x640_0.jpg +2 -2
- samples/unet_512x640_0.jpg +2 -2
- samples/unet_576x640_0.jpg +2 -2
- samples/unet_640x320_0.jpg +2 -2
- samples/unet_640x384_0.jpg +2 -2
- samples/unet_640x448_0.jpg +2 -2
- samples/unet_640x512_0.jpg +2 -2
- samples/unet_640x576_0.jpg +2 -2
- samples/unet_640x640_0.jpg +2 -2
- pipeline_sdxs-Copy1.py → src/pipeline_sdxs-Copy1.py +0 -0
- test.ipynb +2 -2
- train.py +7 -20
- unet/diffusion_pytorch_model.safetensors +1 -1
media/result_grid.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
media/result_grid.png
DELETED
Git LFS Details
|
samples/unet_320x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_384x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_448x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_512x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_576x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x320_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x384_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x448_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x512_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x576_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
samples/unet_640x640_0.jpg
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
pipeline_sdxs-Copy1.py → src/pipeline_sdxs-Copy1.py
RENAMED
|
File without changes
|
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:7754efea243246c21b73b743ea55055cff9ed385f22d119ee489931185366cf1
|
| 3 |
+
size 8316949
|
train.py
CHANGED
|
@@ -447,35 +447,22 @@ def get_negative_embedding(neg_prompt="", batch_size=1):
|
|
| 447 |
# Загрузка моделей (если ещё не загружены)
|
| 448 |
if not hasattr(get_negative_embedding, "tokenizer"):
|
| 449 |
get_negative_embedding.tokenizer = AutoTokenizer.from_pretrained(
|
| 450 |
-
"Qwen/Qwen3-
|
| 451 |
)
|
| 452 |
get_negative_embedding.text_model = AutoModel.from_pretrained(
|
| 453 |
-
"Qwen/Qwen3-
|
| 454 |
).to(device).eval()
|
| 455 |
|
| 456 |
-
# Вспомогательная функция для пулинга
|
| 457 |
-
def last_token_pool(last_hidden_states, attention_mask):
|
| 458 |
-
left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
|
| 459 |
-
if left_padding:
|
| 460 |
-
return last_hidden_states[:, -1]
|
| 461 |
-
else:
|
| 462 |
-
sequence_lengths = attention_mask.sum(dim=1) - 1
|
| 463 |
-
batch_size = last_hidden_states.shape[0]
|
| 464 |
-
return last_hidden_states[
|
| 465 |
-
torch.arange(batch_size, device=last_hidden_states.device),
|
| 466 |
-
sequence_lengths
|
| 467 |
-
]
|
| 468 |
-
|
| 469 |
# Вычисление эмбеддинга
|
| 470 |
-
def encode_texts(texts, max_length=
|
| 471 |
with torch.inference_mode():
|
| 472 |
toks = get_negative_embedding.tokenizer(
|
| 473 |
texts, return_tensors="pt", padding="max_length", truncation=True, max_length=max_length
|
| 474 |
).to(device)
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
return
|
| 479 |
|
| 480 |
# Возвращаем эмбеддинг
|
| 481 |
if not neg_prompt:
|
|
|
|
| 447 |
# Загрузка моделей (если ещё не загружены)
|
| 448 |
if not hasattr(get_negative_embedding, "tokenizer"):
|
| 449 |
get_negative_embedding.tokenizer = AutoTokenizer.from_pretrained(
|
| 450 |
+
"Qwen/Qwen3-0.6B"
|
| 451 |
)
|
| 452 |
get_negative_embedding.text_model = AutoModel.from_pretrained(
|
| 453 |
+
"Qwen/Qwen3-0.6B"
|
| 454 |
).to(device).eval()
|
| 455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
# Вычисление эмбеддинга
|
| 457 |
+
def encode_texts(texts, max_length=150):
|
| 458 |
with torch.inference_mode():
|
| 459 |
toks = get_negative_embedding.tokenizer(
|
| 460 |
texts, return_tensors="pt", padding="max_length", truncation=True, max_length=max_length
|
| 461 |
).to(device)
|
| 462 |
+
|
| 463 |
+
outs = get_negative_embedding.text_model(**toks, output_hidden_states=True)
|
| 464 |
+
hidden_states = outs.hidden_states[-1] # [B, L, D]
|
| 465 |
+
return hidden_states
|
| 466 |
|
| 467 |
# Возвращаем эмбеддинг
|
| 468 |
if not neg_prompt:
|
unet/diffusion_pytorch_model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 6184944280
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c093c51d6be0a372c91657f1abdce28a61577134ef09eac531479ca384cef933
|
| 3 |
size 6184944280
|