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
File size: 5,874 Bytes
f927ea3 a0912d2 f927ea3 a0912d2 f927ea3 a0912d2 f927ea3 a0912d2 f927ea3 a0912d2 f927ea3 a0912d2 f927ea3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | from pathlib import Path
import os,json,time,csv,hashlib,shutil,math
from huggingface_hub import HfApi
from safetensors import safe_open
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
root=Path('/data/nyako-training-150');art=root/'artifacts';repo='ACCC1380/nyako_style'
def status(stage,**kw): (root/'status.json').write_text(json.dumps({'stage':stage,'time':time.time(),**kw}))
final=art/'output/nyako_style.safetensors';state=art/'output/nyako_style-state'
assert final.is_file() and state.is_dir(),'Final weight/state missing'
assert json.loads((state/'train_state.json').read_text()) == {'current_epoch':150,'current_step':2100}, 'Incorrect final resume progress'
assert (state/'optimizer.bin').is_file() and (state/'scheduler.bin').is_file(),'Incomplete resume state'
with safe_open(final,framework='pt') as f:
m=f.metadata(); assert int(m['ss_epoch'])==150;assert int(m['ss_network_dim'])==16;assert float(m['ss_network_alpha'])==16
summary={k:m[k] for k in ['ss_epoch','ss_steps','ss_network_dim','ss_network_alpha','ss_learning_rate','ss_optimizer','ss_lr_scheduler'] if k in m}
# Read scalar events only; never display or inspect captions.
rows=[]
for p in (art/'logs').rglob('events.out.tfevents.*'):
e=EventAccumulator(str(p),size_guidance={'scalars':0});e.Reload()
for tag in e.Tags()['scalars']:
for v in e.Scalars(tag): rows.append((tag,v.step,v.value,v.wall_time))
assert rows,'No training metrics'
assert all(math.isfinite(v) for t,s,v,w in rows if 'loss' in t),'Nonfinite loss'
with (art/'logs/metrics.csv').open('w') as f:
w=csv.writer(f);w.writerow(['tag','step','value','wall_time']);w.writerows(rows)
last={}
for tag,step,value,wall in rows:
if tag not in last or step>=last[tag]['step']:last[tag]={'step':step,'value':value}
summary['last_metrics']=last
(art/'config/training_summary.json').write_text(json.dumps(summary,indent=2))
# Retain source code necessary to reproduce preprocessing, launch and upload.
shutil.copytree(root/'scripts',art/'scripts',dirs_exist_ok=True)
(art/'README.md').write_text('''---
base_model: circlestone-labs/Anima
library_name: diffusers
tags:
- lora
- anima
- text-to-image
- style
---
# Nyako style — Anima base LoRA
Trigger: `@nyako` (training captions start with the exact bytes `@nyako, `).
Final weights: `output/nyako_style.safetensors`.
Final resume state: `output/nyako_style-state/` (model, AdamW optimizer, scheduler, random state, and trainer progress).
Trained from Anima base v1.0 using lora-scripts-next, rank 16 / alpha 16, AdamW, learning rate 1e-4, constant scheduler, 150 total epochs (resumed after epoch 50), batch size 2, BF16, resolution 1024 with aspect ratio buckets, seed 42. Gradient checkpointing is disabled. Buckets with an odd sample count have a smaller final batch.
The source dataset is `ACCC1380/Nyako` at revision `f1048ee38473bc253ebdc4b4eba3b0c2dcebacb3`, with 24 image/caption pairs. Captions were processed as opaque bytes: only the requested prefix was prepended, with the remaining bytes verified unchanged. The assistant did not inspect caption contents.
Contents:
- `output/`: epoch weights, final weights, recent recovery checkpoints and final resume state.
- `config/`: requested/effective training configuration, dataset definition and provenance, package versions, trainer commit, summary.
- `dataset/`: images and prefixed captions used for training.
- `logs/`: training log, TensorBoard events, and scalar metrics CSV (including loss).
- `scripts/`: preprocessing, launcher and upload scripts.
- `manifest.json`: SHA-256 hashes and sizes for backup verification.
Configuration paths reflect the original training machine. To resume elsewhere, download the artifacts, install the recorded environment and trainer commit, update local model/dataset/output paths, and pass `--resume /path/to/output/nyako_style-state` to the saved training command. Increase the epoch target when continuing beyond the completed 150 total epochs (resumed after epoch 50).
''')
excluded={'.npz','.npy'}
files=[p for p in art.rglob('*') if p.is_file() and p.suffix not in excluded and '.cache' not in p.parts and '__pycache__' not in p.parts and p.name!='manifest.json']
manifest=[]
for p in sorted(files):
h=hashlib.sha256()
with p.open('rb') as f:
for b in iter(lambda:f.read(8*1024*1024),b''):h.update(b)
manifest.append({'path':str(p.relative_to(art)),'size':p.stat().st_size,'sha256':h.hexdigest()})
(art/'manifest.json').write_text(json.dumps(manifest,indent=2))
api=HfApi();status('uploading',repo=repo)
for attempt in range(1,9):
try:
api.create_repo(repo,repo_type='model',private=False,exist_ok=True)
api.update_repo_settings(repo,repo_type='model',private=False)
info=api.upload_folder(repo_id=repo,repo_type='model',folder_path=str(art),ignore_patterns=['**/*.npz','**/*.npy','**/.cache/**','**/__pycache__/**'],commit_message='Anima base Nyako LoRA: rank16 alpha16, 150 total epochs (resumed after epoch 50), training artifacts and final resume state')
remote=api.model_info(repo,files_metadata=True);assert remote.private is False
remote_files={x.rfilename:x for x in remote.siblings}
for record in manifest:
item=remote_files[record['path']];assert item.size==record['size'],record['path']
if item.lfs: assert item.lfs.sha256==record['sha256'],record['path']
receipt={'repo':repo,'url':'https://huggingface.co/'+repo,'commit':remote.sha,'files':len(manifest)+1,'public':not remote.private,'verified':True,'summary':summary}
(root/'backup_receipt.json').write_text(json.dumps(receipt,indent=2));status('complete',**receipt);print('Backup verified:',receipt['url'],flush=True);break
except Exception as exc:
status('upload_retry',attempt=attempt,error_type=type(exc).__name__)
print('Upload retry',attempt,type(exc).__name__,flush=True)
if attempt==8:raise
time.sleep(min(30*attempt,60))
|