Text-to-Image
Diffusers
Safetensors
English
Chinese
QwenImage21Pipeline
sdnq
int4
uint4
image-generation
image-editing
apple-silicon
8-bit precision
Instructions to use ixim/Image21-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ixim/Image21-INT4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("ixim/Image21-INT4", 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
| """Editing inputs: independent noise and unchanged RGBA pixels.""" | |
| import math | |
| from pathlib import Path | |
| from PIL import Image, ImageOps | |
| DEFAULT_SEEDS = (1000042, 1000123) | |
| def validate_seeds(cases, seeds): | |
| if (not seeds or len(set(seeds)) != len(seeds) | |
| or any(type(s) is not int or not 0 <= s < 2**63 for s in seeds)): | |
| raise ValueError('Use distinct integer seeds in [0, 2**63)') | |
| source_seeds = {c.get('source_seed') for c in cases} - {None} | |
| if source_seeds.intersection(seeds): | |
| raise ValueError('Editing seeds must differ from every known source seed (noise replay)') | |
| return list(seeds) | |
| def load_input(path): | |
| with Image.open(path) as image: | |
| image = ImageOps.exif_transpose(image) | |
| has_alpha = 'A' in image.getbands() or 'transparency' in image.info | |
| return image.convert('RGBA' if has_alpha else 'RGB') | |
| def edit_dimensions(size, resolution): | |
| if resolution < 32 or resolution % 32 or min(size) <= 0: | |
| raise ValueError('Positive image size and resolution divisible by 32 required') | |
| ratio = size[0] / size[1] | |
| width = math.sqrt(resolution**2 * ratio) | |
| return max(32, round(width / 32) * 32), max(32, round(width / ratio / 32) * 32) | |