Offexb commited on
Commit
3b58151
·
verified ·
1 Parent(s): 70b73cd

Delete prepare_dataset.py

Browse files
Files changed (1) hide show
  1. prepare_dataset.py +0 -45
prepare_dataset.py DELETED
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Prepare the bundled character images for SDXL style LoRA training.
3
-
4
- This script validates the reference set, creates captions/metadata, and can
5
- optionally create a resized training cache. It never claims that training has
6
- already happened; it prepares the real dataset used by the trainer.
7
- """
8
- from pathlib import Path
9
- from PIL import Image
10
- import json, hashlib
11
-
12
- ROOT = Path(__file__).parent
13
- SRC = ROOT / "training_data"
14
- OUT = ROOT / "dataset"
15
- OUT.mkdir(exist_ok=True)
16
-
17
- TRIGGER = "offex3dstyle"
18
- BASE_CAPTION = (
19
- f"{TRIGGER}, high quality stylized 3D cartoon character, full body character art, "
20
- "exaggerated expressive face, large readable eyes, detailed hands and clothing, "
21
- "bold clean shapes, polished 3D render, smooth sculpted forms, strong silhouette, "
22
- "centered isolated character, professional game/animation character asset"
23
- )
24
-
25
- images = sorted([p for p in SRC.iterdir() if p.suffix.lower() in {'.png','.jpg','.jpeg','.webp'}])
26
- if not images:
27
- raise SystemExit("No training images found in training_data/")
28
-
29
- rows=[]
30
- for p in images:
31
- try:
32
- with Image.open(p) as im:
33
- im.verify()
34
- with Image.open(p) as im:
35
- w,h=im.size
36
- except Exception as e:
37
- raise SystemExit(f"Invalid image {p.name}: {e}")
38
- digest=hashlib.sha256(p.read_bytes()).hexdigest()
39
- cap=OUT/(p.stem+'.txt')
40
- cap.write_text(BASE_CAPTION, encoding='utf-8')
41
- rows.append({"file_name": str(Path('..')/'training_data'/p.name), "caption": BASE_CAPTION, "width": w, "height": h, "sha256": digest})
42
-
43
- (OUT/'metadata.jsonl').write_text('\n'.join(json.dumps(x,ensure_ascii=False) for x in rows)+'\n', encoding='utf-8')
44
- (OUT/'dataset_info.json').write_text(json.dumps({"trigger":TRIGGER,"count":len(rows),"caption":BASE_CAPTION,"images":rows},indent=2),encoding='utf-8')
45
- print(f"Prepared {len(rows)} images. Trigger token: {TRIGGER}")