Instructions to use ACCC1380/nyako_style with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ACCC1380/nyako_style with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("circlestone-labs/Anima", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("ACCC1380/nyako_style") 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 scripts/prepare.py from ACCC1380/nyako_style: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/ACCC1380/nyako_style/resolve/main/scripts/prepare.py
- Command line
-
hf download hf://ACCC1380/nyako_style/scripts/prepare.py
-
curl -L -o prepare.py https://huggingface.co/ACCC1380/nyako_style/resolve/main/scripts/prepare.py
1.76 kB
| from pathlib import Path | |
| import shutil,json,hashlib | |
| from PIL import Image | |
| root=Path('/data/nyako-training');src=root/'source_dataset';dst=root/'artifacts/dataset';dst.mkdir(exist_ok=True) | |
| prefix=b'@nyako, '; rows=[] | |
| for p in sorted(src.rglob('*.jpg')): | |
| c=p.with_suffix('.txt'); assert c.exists(), 'Missing caption' | |
| rel=p.relative_to(src); target=dst/rel;target.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(p,target) | |
| # Opaque byte operation only: caption text is never printed or interpreted. | |
| original=c.read_bytes(); amended=prefix+original | |
| target.with_suffix('.txt').write_bytes(amended) | |
| assert target.with_suffix('.txt').read_bytes()[len(prefix):]==original | |
| with Image.open(p) as im: size=im.size | |
| rows.append({'image':str(rel),'size':size,'original_caption_sha256':hashlib.sha256(original).hexdigest(),'prefixed_caption_sha256':hashlib.sha256(amended).hexdigest()}) | |
| assert rows | |
| (root/'artifacts/config/dataset_manifest.json').write_text(json.dumps({'repo':'ACCC1380/Nyako','revision':'f1048ee38473bc253ebdc4b4eba3b0c2dcebacb3','prefix':'@nyako, ','count':len(rows),'files':rows},indent=2)) | |
| print('Prepared image/caption pairs:',len(rows)); print('Image dimensions range:',[min(r['size'][i] for r in rows) for i in (0,1)],[max(r['size'][i] for r in rows) for i in (0,1)]) | |
| folders=sorted(set(str((dst/r['image']).parent) for r in rows)) | |
| text='[general]\ncaption_extension = ".txt"\nshuffle_caption = false\n\n[[datasets]]\nresolution = 1024\nbatch_size = 2\nenable_bucket = true\nmin_bucket_reso = 256\nmax_bucket_reso = 2048\nbucket_reso_steps = 64\nbucket_no_upscale = false\n' | |
| for folder in folders:text+='\n[[datasets.subsets]]\nimage_dir = '+json.dumps(folder)+'\nnum_repeats = 1\n' | |
| (root/'artifacts/config/dataset.toml').write_text(text) | |