Text-to-Image
Transformers
English
SupraDiT
feature-extraction
small
supra
image
flux
img
t2i
from scratch
custom_code
Instructions to use SupraLabs/Supra2-IMG with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SupraLabs/Supra2-IMG with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("SupraLabs/Supra2-IMG", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update inference.py
Browse files- inference.py +2 -3
inference.py
CHANGED
|
@@ -19,6 +19,7 @@ import math
|
|
| 19 |
import os
|
| 20 |
import sys
|
| 21 |
import time
|
|
|
|
| 22 |
|
| 23 |
import torch
|
| 24 |
import torch.nn as nn
|
|
@@ -359,7 +360,7 @@ def generate(args: argparse.Namespace, device: torch.device) -> None:
|
|
| 359 |
log(f"[sample] Euler flow, {args.steps} steps ...")
|
| 360 |
t_sample = time.perf_counter()
|
| 361 |
|
| 362 |
-
for i in range(args.steps):
|
| 363 |
t = torch.full((args.n,), i * dt, device=device)
|
| 364 |
with torch.autocast("cuda", dtype=torch.bfloat16, enabled=use_amp):
|
| 365 |
if use_cfg:
|
|
@@ -369,8 +370,6 @@ def generate(args: argparse.Namespace, device: torch.device) -> None:
|
|
| 369 |
else:
|
| 370 |
v = model(z, t, ctx, cmask).float()
|
| 371 |
z = z + dt * v
|
| 372 |
-
if (i + 1) % max(1, args.steps // 10) == 0 or i == 0:
|
| 373 |
-
log(f" step {i + 1}/{args.steps}")
|
| 374 |
|
| 375 |
log(f"[sample] denoising done in {time.perf_counter() - t_sample:.1f}s")
|
| 376 |
log("[vae] decoding latents ...")
|
|
|
|
| 19 |
import os
|
| 20 |
import sys
|
| 21 |
import time
|
| 22 |
+
from tqdm import tqdm
|
| 23 |
|
| 24 |
import torch
|
| 25 |
import torch.nn as nn
|
|
|
|
| 360 |
log(f"[sample] Euler flow, {args.steps} steps ...")
|
| 361 |
t_sample = time.perf_counter()
|
| 362 |
|
| 363 |
+
for i in tqdm(range(args.steps), desc="Generating", unit="step", dynamic_ncols=True):
|
| 364 |
t = torch.full((args.n,), i * dt, device=device)
|
| 365 |
with torch.autocast("cuda", dtype=torch.bfloat16, enabled=use_amp):
|
| 366 |
if use_cfg:
|
|
|
|
| 370 |
else:
|
| 371 |
v = model(z, t, ctx, cmask).float()
|
| 372 |
z = z + dt * v
|
|
|
|
|
|
|
| 373 |
|
| 374 |
log(f"[sample] denoising done in {time.perf_counter() - t_sample:.1f}s")
|
| 375 |
log("[vae] decoding latents ...")
|