goumsss Claude Opus 4.8 commited on
Commit
38bba68
·
1 Parent(s): 18bda20

Switch dataset model to Qwen-Image + add 54-image training set (LFS)

Browse files

scripts/generate_dataset.py:
- Use Qwen/Qwen-Image (fal-ai provider) — beat FLUX.1-dev on multi-animal
accuracy in side-by-side tests; FLUX.2-dev is edit-only so unusable for t2i
- Add a 4-attempt retry loop for transient fal-ai 504 timeouts
- Drop the --provider flag (single model now)

training/:
- 54 generated images + caption .txt files, tracked via Git LFS
- All 12 app animals solo, all 10 places, plus 2–3 animal and 2–3 place combos
- Captions share the app's exact build_subject prefix + NUMZOO_STYLE suffix

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ training/*.jpg filter=lfs diff=lfs merge=lfs -text
scripts/generate_dataset.py CHANGED
@@ -1,8 +1,9 @@
1
  """
2
  NumZoo training dataset generator.
3
 
4
- Generates LoRA training images matching the NumZoo aesthetic using FLUX.2-dev
5
  via the HuggingFace Inference API (fal-ai provider, billed to your HF Pro credits).
 
6
 
7
  Alignment with the live app is guaranteed by construction:
8
  - The "A cute {animals} {places}" prefix is built with image_generator.build_subject
@@ -18,10 +19,9 @@ Requirements:
18
  ~/miniforge3/bin/pip install huggingface_hub pillow python-dotenv
19
 
20
  Setup (HF Pro — just your existing token):
21
- 1. Accept the FLUX.2-dev license: https://huggingface.co/black-forest-labs/FLUX.2-dev
22
- 2. Get an HF token (fine-grained, "Make calls to Inference Providers" permission)
23
- https://huggingface.co/settings/tokens
24
- 3. Add to .env: HF_TOKEN=hf_...
25
 
26
  Usage:
27
  ~/miniforge3/bin/python3 scripts/generate_dataset.py # all scenes
@@ -141,40 +141,43 @@ PROMPTS: list[tuple[str, str]] = [
141
  ]
142
 
143
  # ---------------------------------------------------------------------------
144
- # Generator using FLUX.2-dev via HuggingFace Inference API
145
  # ---------------------------------------------------------------------------
 
 
 
 
 
146
 
147
- # Provider → model routing:
148
- # fal-ai → FLUX.2-dev (best quality; billed to HF Pro credits)
149
- # hf-inference → FLUX.1-schnell (HF native fallback, lower quality)
150
- PROVIDERS = {
151
- "fal-ai": "black-forest-labs/FLUX.2-dev",
152
- "hf-inference": "black-forest-labs/FLUX.1-schnell",
153
- }
154
 
155
- def generate_image(prompt: str, provider: str = "fal-ai") -> "PIL.Image.Image":
 
156
  from huggingface_hub import InferenceClient
157
 
158
- # HF Pro token covers all providers no separate provider key needed
 
159
  hf_token = os.environ.get("HF_TOKEN")
160
- model = PROVIDERS.get(provider, PROVIDERS["fal-ai"])
161
- client = InferenceClient(provider=provider, api_key=hf_token)
162
-
163
- image = client.text_to_image(
164
- prompt,
165
- model=model,
166
- width=1024,
167
- height=1024,
168
- )
169
- return image # InferenceClient already returns a PIL Image
 
170
 
171
 
172
  def main():
173
  parser = argparse.ArgumentParser()
174
- parser.add_argument("--start", type=int, default=1, help="Resume from image N (1-based)")
175
- parser.add_argument("--count", type=int, default=None, help="Generate at most N images then stop")
176
- parser.add_argument("--provider", type=str, default="fal-ai", help="Inference provider: fal-ai | hf-inference")
177
- parser.add_argument("--dry-run", action="store_true", help="Print prompts without generating")
178
  args = parser.parse_args()
179
 
180
  if not args.dry_run:
@@ -217,7 +220,7 @@ def main():
217
  continue
218
 
219
  try:
220
- image = generate_image(prompt, provider=args.provider)
221
  image.save(img_path, "JPEG", quality=95)
222
  txt_path.write_text(prompt)
223
  generated_this_run += 1
 
1
  """
2
  NumZoo training dataset generator.
3
 
4
+ Generates LoRA training images matching the NumZoo aesthetic using Qwen-Image
5
  via the HuggingFace Inference API (fal-ai provider, billed to your HF Pro credits).
6
+ (Qwen-Image beat FLUX.1-dev on multi-animal accuracy; FLUX.2-dev is edit-only.)
7
 
8
  Alignment with the live app is guaranteed by construction:
9
  - The "A cute {animals} {places}" prefix is built with image_generator.build_subject
 
19
  ~/miniforge3/bin/pip install huggingface_hub pillow python-dotenv
20
 
21
  Setup (HF Pro — just your existing token):
22
+ 1. Get an HF token (fine-grained, "Make calls to Inference Providers" permission)
23
+ https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained
24
+ 2. Add to .env: HF_TOKEN=hf_...
 
25
 
26
  Usage:
27
  ~/miniforge3/bin/python3 scripts/generate_dataset.py # all scenes
 
141
  ]
142
 
143
  # ---------------------------------------------------------------------------
144
+ # Generator using Qwen-Image via HuggingFace Inference API (fal-ai provider)
145
  # ---------------------------------------------------------------------------
146
+ # Qwen-Image chosen over FLUX.1-dev: far better at rendering DISTINCT animals in
147
+ # multi-animal scenes (critical — the app lets players pick up to 3), and a
148
+ # softer painterly storybook style closer to the NumZoo references.
149
+ # Note: FLUX.2-dev is edit-only (image-to-image) on every HF provider, so it
150
+ # cannot be used for text-to-image dataset generation.
151
 
152
+ MODEL = "Qwen/Qwen-Image"
153
+ PROVIDER = "fal-ai"
154
+ RETRIES = 4 # fal-ai occasionally returns transient 504s
 
 
 
 
155
 
156
+
157
+ def generate_image(prompt: str) -> "PIL.Image.Image":
158
  from huggingface_hub import InferenceClient
159
 
160
+ # HF Pro token (with "Make calls to Inference Providers" permission) covers
161
+ # all providers — no separate provider key needed.
162
  hf_token = os.environ.get("HF_TOKEN")
163
+ last_err = None
164
+ for attempt in range(1, RETRIES + 1):
165
+ try:
166
+ client = InferenceClient(provider=PROVIDER, api_key=hf_token)
167
+ return client.text_to_image(prompt, model=MODEL, width=1024, height=1024)
168
+ except Exception as e:
169
+ last_err = e
170
+ if attempt < RETRIES:
171
+ print(f" ⚠️ attempt {attempt}/{RETRIES} failed ({str(e)[:60]}) — retrying")
172
+ time.sleep(4)
173
+ raise last_err # exhausted retries
174
 
175
 
176
  def main():
177
  parser = argparse.ArgumentParser()
178
+ parser.add_argument("--start", type=int, default=1, help="Resume from image N (1-based)")
179
+ parser.add_argument("--count", type=int, default=None, help="Generate at most N images then stop")
180
+ parser.add_argument("--dry-run", action="store_true", help="Print prompts without generating")
 
181
  args = parser.parse_args()
182
 
183
  if not args.dry_run:
 
220
  continue
221
 
222
  try:
223
+ image = generate_image(prompt)
224
  image.save(img_path, "JPEG", quality=95)
225
  txt_path.write_text(prompt)
226
  generated_this_run += 1
training/image_001.jpg ADDED

Git LFS Details

  • SHA256: c3e2e73d454adb3607df6af31a31eab52f488a8268d8dc628110c8f4793ed0db
  • Pointer size: 131 Bytes
  • Size of remote file: 219 kB
training/image_001.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute bunny in an enchanted mushroom forest, sitting on a polka-dot toadstool, fireflies and floating spores drifting around, soft lantern glow, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_002.jpg ADDED

Git LFS Details

  • SHA256: 42fc5618d24e4cf2b0bae82ac0d3a50f8b88e02ecd6f80c31e279a2541366ad5
  • Pointer size: 131 Bytes
  • Size of remote file: 206 kB
training/image_002.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute kitten on a sunny beach with ocean waves, building a tiny sandcastle with a bucket and shells, gentle waves lapping, warm sunset sky, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_003.jpg ADDED

Git LFS Details

  • SHA256: 32094d6bc1793c4ac852e05dc512ec9ae523433ed8180f861d6591e48997a94e
  • Pointer size: 131 Bytes
  • Size of remote file: 247 kB
training/image_003.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute puppy in a cosy cottage garden, napping in a flower-filled wheelbarrow, watering can and butterflies nearby, golden afternoon light, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_004.jpg ADDED

Git LFS Details

  • SHA256: 2f12fc7efe88f5dfeea2db3071fc64e33daaf03e1d216c122ceb8423cc8cf9d9
  • Pointer size: 131 Bytes
  • Size of remote file: 199 kB
training/image_004.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby fox surrounded by sparkling stars, curled up on a fluffy cloud cradling a tiny glowing star, glittering night sky, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_005.jpg ADDED

Git LFS Details

  • SHA256: b012294a3a9df51845822150e91268e519e5085746e6ab9008a5e1e09afef2ca
  • Pointer size: 131 Bytes
  • Size of remote file: 205 kB
training/image_005.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby panda in a cherry blossom garden, nibbling a dango skewer as petals fall, paper lanterns strung above, soft pink light, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_006.jpg ADDED

Git LFS Details

  • SHA256: 1410826a9d4dcccec9870a174aa232bf80a42145f25d8cf778e24592db22d27c
  • Pointer size: 131 Bytes
  • Size of remote file: 229 kB
training/image_006.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby koala on a tropical island, hugging a palm trunk with a coconut drink, striped hammock and a parrot, turquoise sea behind, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_007.jpg ADDED

Git LFS Details

  • SHA256: ed85d60fff8407e66f1a57e13466de4805fe5d37ad88fa9a395f896ef25c24b5
  • Pointer size: 131 Bytes
  • Size of remote file: 200 kB
training/image_007.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby lion under a rainbow, wearing a tiny crown at the end of a rainbow, pastel clouds and floating sparkles, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_008.jpg ADDED

Git LFS Details

  • SHA256: b6ef0ae624a2e33b8e9e4ad0b0917f826a3c660b91c8e076a11c8d152e594e58
  • Pointer size: 131 Bytes
  • Size of remote file: 212 kB
training/image_008.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby tiger on a snowy mountain top, bundled in a knitted scarf on a snowy peak planting a tiny flag, sparkling snow and faint aurora, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_009.jpg ADDED

Git LFS Details

  • SHA256: 1762132a86e682349bcb84152d60f9640eb8a534ad1daf07679ea206f4749af6
  • Pointer size: 131 Bytes
  • Size of remote file: 227 kB
training/image_009.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby frog in a field of tropical flowers, perched on a giant hibiscus bloom, dewdrops glistening, big tropical leaves and warm bokeh, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_010.jpg ADDED

Git LFS Details

  • SHA256: fcb7d1b5eca9e2308a1fe9295ce616e6aff25bfdfa108a7ffc4879f4e7269446
  • Pointer size: 131 Bytes
  • Size of remote file: 184 kB
training/image_010.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby penguin on a glowing crescent moon, sitting on the curve of a glowing crescent moon in a knitted hat, scattered twinkling stars, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_011.jpg ADDED

Git LFS Details

  • SHA256: 83e5c7ddeb8a36609795298c7e1dfd1c4b0b5e45f1e2fb872077fedffc00acde
  • Pointer size: 131 Bytes
  • Size of remote file: 224 kB
training/image_011.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute butterfly in a cherry blossom garden, fluttering through cherry blossoms trailing sparkles, pastel petals swirling in the breeze, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_012.jpg ADDED

Git LFS Details

  • SHA256: ad87594149f95b7a5ee044e2014e8fdadc3b77ae56f4f4c6ce76e103dd51a38c
  • Pointer size: 131 Bytes
  • Size of remote file: 217 kB
training/image_012.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute unicorn surrounded by sparkling stars, galloping across a starry sky, rainbow mane glowing, a trail of sparkles behind, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_013.jpg ADDED

Git LFS Details

  • SHA256: d3690c0ccb7e7d190a172460178452ebd482ff19136bfb490dff802418439145
  • Pointer size: 131 Bytes
  • Size of remote file: 240 kB
training/image_013.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute puppy in an enchanted mushroom forest, exploring beneath a giant mushroom with a tiny lantern, glowing toadstools and soft moss, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_014.jpg ADDED

Git LFS Details

  • SHA256: 6c1f97644fa88900bf9c284a86b9d1aeaa01e91a7bf50e5a51bfcc31fb350bda
  • Pointer size: 131 Bytes
  • Size of remote file: 190 kB
training/image_014.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute kitten on a glowing crescent moon, curled asleep on a crescent moon wearing a nightcap, twinkling stars all around, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_015.jpg ADDED

Git LFS Details

  • SHA256: 1649be360211600b93b960f228f6487d80ef02dc08589a741f0a94933e573ceb
  • Pointer size: 131 Bytes
  • Size of remote file: 201 kB
training/image_015.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute bunny on a sunny beach with ocean waves, splashing in shallow waves beside a starfish friend, beach pail and spade, pink sunset, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_016.jpg ADDED

Git LFS Details

  • SHA256: 4f655ce816ed53d91f5fc32e52f86248ecc3934ed9ad173e501d3455d824f928
  • Pointer size: 131 Bytes
  • Size of remote file: 249 kB
training/image_016.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby panda in a cosy cottage garden, tending a vegetable patch in a straw hat, bees and tall sunflowers, warm sun, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_017.jpg ADDED

Git LFS Details

  • SHA256: aeba54470897c1f4ed5f5ed226183c2a202b2a6f971c540726fed78fd9c8616f
  • Pointer size: 131 Bytes
  • Size of remote file: 200 kB
training/image_017.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby penguin on a snowy mountain top, sliding down a snowy slope on its belly, scarf flying, sparkling powder snow, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_018.jpg ADDED

Git LFS Details

  • SHA256: 8abd7ba8f2ce02b0cf96d5da733d96ddfdd90d7f1944245c5cbb836190959e29
  • Pointer size: 131 Bytes
  • Size of remote file: 233 kB
training/image_018.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby fox on a tropical island, lounging in a hammock between two palms with sunglasses, coconuts and calm ocean, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_019.jpg ADDED

Git LFS Details

  • SHA256: f00b2d3bc196d3fa816509f6c4c4873e9e95dca8168806fc603fdeadd83e001c
  • Pointer size: 131 Bytes
  • Size of remote file: 247 kB
training/image_019.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby lion in a field of tropical flowers, snoozing in a field of tropical flowers, a butterfly on its nose, dappled golden light, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_020.jpg ADDED

Git LFS Details

  • SHA256: 27716328058abab2d7b27d5013d9fe97157ed26782188a88d0167dda06e6cd9d
  • Pointer size: 131 Bytes
  • Size of remote file: 231 kB
training/image_020.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby tiger in a cherry blossom garden, chasing falling cherry petals, paper lanterns above, soft pink and lilac tones, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_021.jpg ADDED

Git LFS Details

  • SHA256: 64a861ec18c0e433f2ad44081e1328d95fd4b79cc70be16217a21203847e5572
  • Pointer size: 131 Bytes
  • Size of remote file: 238 kB
training/image_021.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute baby frog in an enchanted mushroom forest, playing a tiny flute on a lily pad among glowing mushrooms, fireflies and reeds, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_022.jpg ADDED

Git LFS Details

  • SHA256: 8d973619137e4885b431d3e61a0742492d18c183364a0fe7e654047921d24162
  • Pointer size: 131 Bytes
  • Size of remote file: 198 kB
training/image_022.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute unicorn under a rainbow, standing proudly under a rainbow, flower garland around its neck, pastel clouds, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_023.jpg ADDED

Git LFS Details

  • SHA256: 34348f89d8b2b5b31653eb40ea7c801cd8ca12006526937fdc2d03c51c18d3bf
  • Pointer size: 131 Bytes
  • Size of remote file: 239 kB
training/image_023.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute bunny and kitten in an enchanted mushroom forest, roasting marshmallows over a tiny campfire, fireflies and glowing mushrooms, cozy night, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text
training/image_024.jpg ADDED

Git LFS Details

  • SHA256: f48a265f3f035f8851d29a717d892a87d5cd13a67d12b061a788436fb3705375
  • Pointer size: 131 Bytes
  • Size of remote file: 198 kB
training/image_024.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ A cute puppy and baby fox on a sunny beach with ocean waves, building a sandcastle together with shell flags, gentle waves at golden hour, kawaii children's book illustration, pastel anime art style, soft painterly lighting, detailed rich background with warm fairy lights, cozy magical atmosphere, cute chibi character with big sparkling eyes, soft pastel color palette, highly detailed scene, no text