Instructions to use ProCreations/Image-2.1-Calibrated-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ProCreations/Image-2.1-Calibrated-NVFP4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ProCreations/Image-2.1-Calibrated-NVFP4", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Release calibrated Image2.1 NVFP4 transformer with dynamic scaling and BF16 rank correction, native SM120 runtime, quality evidence and real-time demo
1961af5 verified Download source/evaluate.py from ProCreations/Image-2.1-Calibrated-NVFP4: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/ProCreations/Image-2.1-Calibrated-NVFP4/resolve/main/source/evaluate.py
- Command line
-
hf download hf://ProCreations/Image-2.1-Calibrated-NVFP4/source/evaluate.py
-
curl -L -o evaluate.py https://huggingface.co/ProCreations/Image-2.1-Calibrated-NVFP4/resolve/main/source/evaluate.py
2.36 kB
| import sys,time,json,argparse | |
| from pathlib import Path | |
| import torch | |
| from PIL import Image | |
| from safetensors.torch import save_file | |
| from nvfp4_runtime import load_pipeline | |
| from acceleration import accelerate_pipeline | |
| ROOT=Path(__file__).resolve().parent | |
| OLD=Path('/home/user/.local/share/rtx-pro-apps/qwen-image-2.1-fp8') | |
| sys.path.insert(0,str(OLD));from prompts import EVALUATION | |
| ap=argparse.ArgumentParser();ap.add_argument('--indices',default='all');ap.add_argument('--out',default='evaluation');ap.add_argument('--quant',default='release/transformer');ap.add_argument('--eager',action='store_true');args=ap.parse_args() | |
| out=ROOT/args.out;out.mkdir(exist_ok=True) | |
| def main(): | |
| pipe=load_pipeline('/home/user/models/qwen-image-2.1-b3179ad',ROOT/args.quant) | |
| if not args.eager:accelerate_pipeline(pipe) | |
| rows=[];indices=list(range(16)) if args.indices=='all' else [int(x) for x in args.indices.split(',')] | |
| for i in indices: | |
| prompt=EVALUATION[i];w=h=2048 if i%4==0 else 1024 | |
| if i==12:w,h=1536,864 | |
| if i==13:w,h=864,1536 | |
| latest={} | |
| def cb(p,step,t,kw): | |
| if step==39:latest['latents']=kw['latents'].detach() | |
| return kw | |
| torch.cuda.synchronize();t=time.perf_counter() | |
| im=pipe(prompt=prompt,width=w,height=h,num_inference_steps=40,generator=torch.Generator('cuda').manual_seed(20000+i),callback_on_step_end=cb).images[0] | |
| torch.cuda.synchronize();sec=time.perf_counter()-t;im.save(out/f'{i:02d}.png') | |
| assert torch.isfinite(latest['latents']).all() | |
| save_file({'latents':latest['latents'].cpu().contiguous()},str(out/f'{i:02d}-latents.safetensors')) | |
| row={'index':i,'width':w,'height':h,'seconds_including_any_compilation':sec,'seed':20000+i};rows.append(row);(out/'runs.json').write_text(json.dumps(rows,indent=2));print(json.dumps(row),flush=True) | |
| if args.indices=='all': | |
| for j,prompt in enumerate(['Replace the background with a blooming spring garden and preserve the animal.','Turn this room into a warm evening scene with lamps switched on, preserving its furniture.']): | |
| im=Image.open(OLD/'evaluation/bf16'/f'{[0,3][j]:02d}.png').resize((1024,1024)) | |
| result=pipe(prompt=prompt,image=im,width=1024,height=1024,num_inference_steps=40,generator=torch.Generator('cuda').manual_seed(21000+j)).images[0] | |
| result.save(out/f'edit-{j}.png');print('EDIT',j,flush=True) | |
| print('EVALUATION_COMPLETE',flush=True) | |
| main() | |