Tarul commited on
Commit
b5b3b02
·
verified ·
1 Parent(s): 61735f0

Upload TUTORIAL.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. TUTORIAL.md +113 -0
TUTORIAL.md ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🎨 PXG-Tiny — 5-Minute Tutorial
2
+
3
+ Turn plain English into 16×16 pixel-art sprites, fully offline.
4
+ *By Chowdhury Tarul Ahsan — tarulahsan@gmail.com*
5
+
6
+ ---
7
+
8
+ ## 1. Install (30 seconds)
9
+
10
+ ```bash
11
+ # Python 3.9+ — only two libraries, no torch, no GPU
12
+ pip install numpy pillow
13
+ ```
14
+
15
+ Unzip the release anywhere. You get this layout:
16
+
17
+ ```
18
+ pxg-tiny/
19
+ ├── cli.py ← command-line app
20
+ ├── weights/ ← the trained model (~1 MB)
21
+ ├── src/pxg_tiny/ ← inference library (pure NumPy)
22
+ ├── samples/gallery/ ← sprites made by the final model
23
+ └── tests/ ← pytest suite
24
+ ```
25
+
26
+ ## 2. Your first sprite (10 seconds)
27
+
28
+ ```bash
29
+ python3 cli.py "a golden sword, glowing" -o sword.png
30
+ ```
31
+
32
+ Done — `sword.png` is a crisp 128×128 sprite (16×16 pixels at 8× zoom,
33
+ transparent background).
34
+
35
+ ## 3. What can I ask for?
36
+
37
+ **Objects (23 families):** sword · dagger · shield · staff · potion · vial ·
38
+ chest · coin · gem · key · apple · bread · oak tree · pine tree · bush ·
39
+ rock · grass/stone/water tile · fireball · house
40
+
41
+ **Attributes that actually change pixels:**
42
+
43
+ | Say | Effect |
44
+ |---|---|
45
+ | `golden / iron / crystal / ruby / emerald / wooden / copper` | recolors the material |
46
+ | `upright` / `lying sideways` | rotates key/key/sword orientation |
47
+ | `glowing` | adds white specular shine |
48
+ | `with moss` / `with berries` / `autumn` | adds the detail |
49
+ | `big` / `small` | scales fireballs |
50
+ | `slate roof` / `terracotta roof` | house roof color |
51
+
52
+ Free phrasing is fine — *“one sword of the crystal kind”*, *“a sword made of
53
+ pure iron”*, *“cottage with terracotta roof”* all work.
54
+
55
+ ## 4. Variations & sprite sheets
56
+
57
+ ```bash
58
+ python3 cli.py "an iron chest" --variations 4 --sheet variants.png
59
+ ```
60
+
61
+ One PNG containing 4 sampled takes on your prompt — perfect for picking a
62
+ favorite or filling a tileset row.
63
+
64
+ ## 5. Ask-first mode (chatbot style)
65
+
66
+ ```bash
67
+ python3 cli.py --ask "can you animate a walking cycle?"
68
+ # → refusal: "i only make 16x16 pixel-art sprites ... no photos, 3d,
69
+ # animation files, logos or other resolutions."
70
+
71
+ python3 cli.py --ask "draw a blorp"
72
+ # → clarify: "i don't know that object yet. i can draw: sword, dagger, ..."
73
+ ```
74
+
75
+ The model knows what it doesn't know — it asks instead of hallucinating.
76
+
77
+ ## 6. Python API
78
+
79
+ ```python
80
+ from pxg_tiny.pipeline import PXGPipeline
81
+
82
+ pipe = PXGPipeline() # loads ./weights
83
+
84
+ grid, meta = pipe.generate_pixels("a ruby potion that glows", seed=7)
85
+ print(meta) # {'gate': 'accept', 'attempt': 0, ...}
86
+
87
+ # raw 16x16 palette-index grid if you want the pixels yourself:
88
+ # grid[y][x] == 0 → transparent, 1..31 → palette color
89
+
90
+ msg = PXGPipeline.ask("a 4k photo of a cat") # → refusal message string
91
+ ```
92
+
93
+ Deterministic: same prompt + same seed ⇒ same sprite, forever, on any machine.
94
+
95
+ ## 7. Batch generation
96
+
97
+ ```bash
98
+ cat prompts.txt
99
+ # golden dagger, upright
100
+ # slim vial of the slime kind
101
+ python3 cli.py --sheet-from-prompts prompts.txt --outdir sprites/
102
+ ```
103
+
104
+ ## 8. Troubleshooting
105
+
106
+ | Symptom | Meaning | Fix |
107
+ |---|---|---|
108
+ | `"gate": "clarify"` | object/attribute unknown | pick from the list it gives you |
109
+ | `"gate": "refuse"` | out of scope (3D/photo/animation/other sizes) | rephrase as a 16×16 sprite |
110
+ | `"gate": "accept_degraded"` | sprite returned but a check stayed red after 8 tries | usually still usable; try another seed |
111
+ | wrong material color | rare sampling drift | retry, or bump `--seed` |
112
+
113
+ *Everything runs 100% locally — no network, no accounts, no API keys.*