Text-to-Image
Diffusers
Safetensors
English
Chinese
flow-matching
qwen-image
ascend
lora
recursive-self-improvement
Instructions to use DALabCommunity/Haidass-Image-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use DALabCommunity/Haidass-Image-Instruct with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("DALabCommunity/Haidass-Image-Base-v1_0.6B_512px", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("DALabCommunity/Haidass-Image-Instruct") 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
Download runtime/routing.py from DALabCommunity/Haidass-Image-Instruct: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/DALabCommunity/Haidass-Image-Instruct/resolve/main/runtime/routing.py
- Command line
-
hf download hf://DALabCommunity/Haidass-Image-Instruct/runtime/routing.py
-
curl -L -o routing.py https://huggingface.co/DALabCommunity/Haidass-Image-Instruct/resolve/main/runtime/routing.py
1.13 kB
| """Quote routing and spelling-format preservation.""" | |
| import re | |
| from .prompt_routing import ( | |
| normalize_single_quotes, | |
| preprocess_and_route_text_prompt, | |
| should_load_writing_lora, | |
| ) | |
| QUOTE_PATTERN = re.compile(r'"([^"\n]+)"|β([^β\n]+)β|γ([^γ\n]+)γ|γ([^γ\n]+)γ|' | |
| r'(?<!\w)\x27([^\x27\n]+)\x27(?!\w)|β([^β\n]+)β') | |
| SPELLING_PATTERN = re.compile(r'\s*\(spelled: [^\n)]*\)') | |
| def triggers(prompt, adapter): | |
| if adapter != 'text': | |
| raise ValueError('Only the writing adapter is available') | |
| return should_load_writing_lora(prompt) | |
| def spell_prompt(prompt, canonical_spelling): | |
| """Append spelling annotations without changing the original quote marks.""" | |
| def annotate(match): | |
| quoted = match[0] | |
| target = quoted[1:-1] | |
| if SPELLING_PATTERN.match(prompt, match.end()): | |
| return quoted | |
| if quoted[0] in '"β': | |
| return canonical_spelling(quoted) | |
| canonical = f'"{target}"' | |
| return quoted + canonical_spelling(canonical)[len(canonical):] | |
| return QUOTE_PATTERN.sub(annotate, prompt) | |