ASTRALK commited on
Commit
0b0f08c
Β·
verified Β·
1 Parent(s): 72a3f03

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +48 -194
README.md CHANGED
@@ -26,230 +26,84 @@ models:
26
  datasets: []
27
  ---
28
 
29
- <!--
30
- AI Comic Studio β€” Build Small Hackathon 2026
31
- Thousand Token Wood track Β· Best Use of Modal Β· Off Brand badge
32
- -->
33
 
34
- <div align="center">
35
 
36
- # 🎬 AI Comic Studio
37
 
38
- ### *Type an idea. Get a full comic book β€” written and illustrated live.*
39
-
40
- **A two-model AI pipeline that generates a complete 25-page, 50-panel comic book in about a minute β€” Gemma 4 writes the story, FLUX.2 paints every panel, and you watch it happen in real time.**
41
-
42
- </div>
43
-
44
- ---
45
-
46
- ## The Idea
47
-
48
- Most AI image generators spit out one panel. AI Comic Studio generates an entire comic book β€” story bible, fixed cast with consistent character designs, 25 pages of narrative arc, and 50 illustrated panels β€” from a single sentence. The whole thing runs live on screen with a ticking stopwatch so you can see exactly how fast two small models can work together.
49
-
50
- ---
51
-
52
- ## What It Does
53
-
54
- 1. **You type a story idea** β€” "A lighthouse keeper guards a secret" or "Space-pirate noodle shop"
55
- 2. **Gemma 4 26B-A4B** (the writer) does three things in sequence:
56
- - **Safety gate** β€” refuses only genuinely harmful requests; fictional adventure, action, mystery, horror are all allowed
57
- - **Story bible** β€” title, logline, a fixed cast with detailed visual descriptions (reused in every panel for consistency), art style, palette, and a 25-page synopsis
58
- - **Panel script** β€” 5 batches of 5 pages each, each batch fed a recap of the story so far for continuity
59
- 3. **FLUX.2 Klein 9B** (the artist) renders every panel β€” character appearance text from the bible is injected into every prompt to keep Elias and his lantern looking the same from panel 1 to panel 50
60
- 4. **The Gradio reader** shows the finished comic β€” two image+caption panels per page, with ← β†’ navigation
61
-
62
- ---
63
-
64
- ## The Two-Model Pipeline
65
 
66
  ```
67
- "Type an idea"
68
- β”‚
69
- β–Ό
70
- Gemma 4 26B-A4B (Writer) FLUX.2 Klein 9B (Artist)
71
- β”œβ”€ Safety gate β”œβ”€ Character injection
72
- β”œβ”€ Story bible (title, cast, β”œβ”€ Deterministic seeds
73
- β”‚ art style, 25-page synopsis) β”œβ”€ 832Γ—576 landscape panels
74
- └─ 50 panels in 5 batches └─ Batched GPU renders
75
- β”‚ β”‚
76
- β–Ό β–Ό
77
- 25-page comic book reader
78
- (Gradio Β· live timer Β· page nav)
79
  ```
80
 
81
- Both models run on **Modal** (H100 GPUs, scale-to-zero with `min_containers=1` for live demos). The Gradio frontend runs on Hugging Face Spaces (CPU).
82
 
83
- ---
84
-
85
- ## Model Details
86
 
87
- | Model | Role | Parameters | Runtime |
88
- |-------|------|-----------|---------|
89
- | `google/gemma-4-26B-A4B-it` | Writer (text only) | 26B total (4B active MoE) | vLLM on Modal H100 |
90
- | `black-forest-labs/FLUX.2-klein-9B` | Artist (images only) | 9B | Diffusers on Modal H100 |
 
91
 
92
- Both models are under the 32B parameter cap. Gemma handles ALL text; FLUX handles ALL images. Neither model does the other's job.
93
 
94
- ---
 
 
 
95
 
96
- ## Character Consistency
97
 
98
- The hard part of a 50-panel comic is keeping characters looking the same. AI Comic Studio solves this with **verbatim appearance injection**: each character gets a detailed visual description in the story bible (species/build, age, hair, face, signature clothing, colors, props β€” ~30 words), and that exact text is injected into every FLUX prompt where the character appears. Combined with deterministic seeds per panel, this keeps the art consistent across the full comic.
99
 
100
- ---
 
 
101
 
102
  ## Custom UI
103
 
104
- This is not a stock Gradio app. Every element is hand-crafted:
105
-
106
- - **Comic book landing page** β€” halftone dot background, Anton typography, hard ink shadows, paper texture
107
- - **Live ticking stopwatch** β€” `gr.Timer` at 100ms intervals, red while generating, green when done
108
- - **Panel-by-panel streaming** β€” each finished panel appears as a live thumbnail during generation
109
- - **Full comic reader** β€” two image+caption panels per page, page navigation, title card with logline
110
- - **Comic sticker buttons** β€” example chips and nav buttons with 3D press effects
111
-
112
- No `gr.Chatbot`, no `gr.Markdown` in the main flow β€” everything is `gr.HTML` with handwritten CSS.
113
-
114
- ---
115
-
116
- ## Modal β€” Where the GPUs Live
117
-
118
- Modal powers both model backends:
119
-
120
- | Component | Modal Config | Purpose |
121
- |-----------|-------------|---------|
122
- | `comic-gemma` | vLLM, H100, `min_containers=1` | Gemma 4 writer endpoint |
123
- | `comic-flux` | Diffusers, H100, `min_containers=1` | FLUX.2 Klein renderer |
124
-
125
- **Why Modal:**
126
- - Scale-to-zero when not in use (no idle GPU costs)
127
- - `min_containers=1` keeps one container hot for live demos (no cold boot mid-recording)
128
- - H100 GPUs for fast inference (~1-2s per panel when warm)
129
- - `scaledown_window=5min` survives between generation steps
130
 
131
- **Cost guard:** `modal app stop comic-gemma && modal app stop comic-flux` when done.
132
-
133
- ---
134
-
135
- ## Running Locally
136
 
137
  ```bash
138
- git clone https://huggingface.co/spaces/ASTRALK/comic-book-generator
139
- cd comic-book-generator
140
  pip install -r requirements.txt
141
-
142
- # Mock mode (no GPU, offline, full UI):
143
- COMIC_BACKEND=mock python app.py
144
-
145
- # Live mode (requires Modal deployment):
146
- COMIC_BACKEND=modal python app.py
147
  ```
148
 
149
- ### Deploying the Modal backends
150
 
151
- ```bash
152
- pip install modal
153
-
154
- # Cache Gemma weights (one-time, ~52GB):
155
- PYTHONIOENCODING=utf-8 modal run serve/serve_gemma.py::download
156
-
157
- # Deploy both backends:
158
- PYTHONIOENCODING=utf-8 modal deploy serve/serve_gemma.py
159
- PYTHONIOENCODING=utf-8 modal deploy serve/serve_flux.py
160
-
161
- # Set environment:
162
- export COMIC_BACKEND=modal
163
- export COMIC_GEMMA_URL=https://<your-workspace>--comic-gemma-serve.modal.run/v1
164
- export COMIC_GEMMA_MODEL=gemma-comic
165
- ```
166
-
167
- ---
168
-
169
- ## Architecture
170
-
171
- ```
172
- HF Space (CPU, Gradio)
173
- β”‚
174
- β”‚ OpenAI client β†’ /v1/chat/completions
175
- β–Ό
176
- Modal: comic-gemma (H100)
177
- β”‚ vLLM Β· Gemma 4 26B-A4B Β· text only
178
- β–Ό
179
- Panel scripts (scene + caption)
180
- β”‚
181
- β”‚ modal.Cls β†’ render_batch()
182
- β–Ό
183
- Modal: comic-flux (H100)
184
- β”‚ Diffusers Β· FLUX.2 Klein 9B Β· images only
185
- β–Ό
186
- 50 JPEG panels β†’ Gradio comic reader
187
- ```
188
-
189
- ---
190
-
191
- ## Tech Stack
192
-
193
- | Layer | Technology |
194
- |-------|-----------|
195
- | Writer model | Google Gemma 4 26B-A4B (MoE, 4B active) |
196
- | Artist model | Black Forest Labs FLUX.2 Klein 9B |
197
- | Writer runtime | vLLM on Modal (H100) |
198
- | Artist runtime | Diffusers on Modal (H100) |
199
- | Frontend | Gradio 6 β€” fully custom HTML/CSS/JS |
200
- | Character consistency | Verbatim appearance injection + deterministic seeds |
201
- | JSON parsing | Robust extractor (strips thinking, fences, prose) |
202
-
203
- ---
204
-
205
- ## Badges Claimed
206
-
207
- | Badge | Why |
208
- |-------|-----|
209
- | 🎨 **Off Brand** | Fully custom UI β€” no default Gradio chrome in the main interface. Halftone dots, paper texture, Anton typography, comic sticker buttons, 3D press effects. |
210
- | πŸ€– **Best Agent** | Multi-step pipeline: safety gate β†’ story bible β†’ 5-batch panel scripting β†’ 50 image renders, all with continuity tracking and character consistency. |
211
- | 🎬 **Best Demo** | Live timer, panel-by-panel streaming, full comic reader with page nav. *(Demo video coming soon)* |
212
- | ⚑ **Modal** | Both model backends run on Modal β€” vLLM for Gemma, Diffusers for FLUX, scale-to-zero with min_containers=1 for live demos. |
213
- | πŸ“‘ **Sharing is Caring** | Agent trace published alongside the Space. *(Trace coming soon)* |
214
- | πŸ““ **Field Notes** | Blog post about building a 50-panel comic pipeline with two small models. *(Write-up coming soon)* |
215
-
216
- ---
217
 
218
  ## Demo Video
219
 
220
- > πŸ“Ή *Demo video coming soon*
221
-
222
- The demo will show:
223
- 1. Typing a story idea
224
- 2. Gemma writing the story bible live
225
- 3. FLUX rendering panels one by one
226
- 4. The live stopwatch ticking
227
- 5. The finished 25-page comic with page navigation
228
-
229
- ---
230
 
231
  ## Social Post
232
 
233
- > 🐦 *Social post link coming soon*
234
-
235
- ---
236
-
237
- ## Run Time
238
-
239
- A warm generation (both GPUs pre-warmed) takes approximately **60-90 seconds** for the full 25-page, 50-panel comic. Cold start adds ~1-3 minutes for container spin-up.
240
 
241
  ---
242
 
243
- ## License
244
-
245
- Apache 2.0
246
-
247
- ---
248
-
249
- <div align="center">
250
-
251
- **AI Comic Studio Β· Build Small Hackathon 2026 Β· Thousand Token Wood**
252
-
253
- *Gemma 4 26B Β· FLUX.2 Klein 9B Β· Modal Β· Gradio Β· 25 Pages Β· 50 Panels*
254
-
255
- </div>
 
26
  datasets: []
27
  ---
28
 
29
+ # AI Comic Studio
 
 
 
30
 
31
+ A two-model pipeline that generates a complete **25-page, 50-panel comic book** from a single sentence β€” written by **Gemma 4**, illustrated by **FLUX.2**, served live on **Modal**.
32
 
33
+ Type an idea β†’ Gemma writes the story, casts characters with fixed visual descriptions β†’ FLUX renders every panel with consistent art β†’ a Gradio reader presents the finished comic with page navigation.
34
 
35
+ ## Pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  ```
38
+ Story idea
39
+ β”‚
40
+ β–Ό
41
+ Gemma 4 26B-A4B FLUX.2 Klein 9B
42
+ Safety gate Character injection
43
+ Story bible Deterministic seeds
44
+ 50 panels (5 batches) Batched GPU renders
45
+ β”‚ β”‚
46
+ β–Ό β–Ό
47
+ 25-page comic reader
48
+ (live timer Β· page nav)
 
49
  ```
50
 
51
+ Gemma handles all text. FLUX handles all images. Both models stay under 32B params.
52
 
53
+ ## How It Works
 
 
54
 
55
+ 1. **Safety gate** β€” Gemma approves or refuses the idea
56
+ 2. **Story bible** β€” title, logline, fixed cast with verbatim visual descriptions, art style, palette, 25-page synopsis
57
+ 3. **Panel script** β€” 5 batches of 5 pages, each fed a recap for continuity
58
+ 4. **Image render** β€” FLUX draws each panel using character descriptions injected into every prompt for consistency
59
+ 5. **Reader** β€” two panels per page, ← β†’ navigation, live generation timer
60
 
61
+ ## Models
62
 
63
+ | Model | Role | Params | Runtime |
64
+ |-------|------|--------|---------|
65
+ | `google/gemma-4-26B-A4B-it` | Writer | 26B (4B active MoE) | vLLM on Modal H100 |
66
+ | `black-forest-labs/FLUX.2-klein-9B` | Artist | 9B | Diffusers on Modal H100 |
67
 
68
+ ## Modal
69
 
70
+ Both backends run on Modal with `min_containers=1` β€” no cold boot during demos. Scale-to-zero when idle.
71
 
72
+ ```bash
73
+ modal app stop comic-gemma && modal app stop comic-flux # cost guard
74
+ ```
75
 
76
  ## Custom UI
77
 
78
+ No stock Gradio components in the main flow. Everything is `gr.HTML` with handwritten CSS β€” halftone dot background, Anton typography, comic sticker buttons, live ticking stopwatch, panel-by-panel streaming.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ ## Run Locally
 
 
 
 
81
 
82
  ```bash
 
 
83
  pip install -r requirements.txt
84
+ COMIC_BACKEND=mock python app.py # offline, no GPU
85
+ COMIC_BACKEND=modal python app.py # live (requires Modal deploy)
 
 
 
 
86
  ```
87
 
88
+ ## Badges
89
 
90
+ | Badge | Claim |
91
+ |-------|-------|
92
+ | 🎨 Off Brand | Custom UI β€” no default Gradio chrome |
93
+ | πŸ€– Best Agent | Multi-step pipeline with continuity tracking |
94
+ | 🎬 Best Demo | Live timer + panel streaming + comic reader |
95
+ | ⚑ Modal | vLLM + Diffusers on Modal H100s |
96
+ | πŸ“‘ Sharing is Caring | Agent trace published |
97
+ | πŸ““ Field Notes | Build write-up |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  ## Demo Video
100
 
101
+ > πŸ“Ή *[Video link coming soon]*
 
 
 
 
 
 
 
 
 
102
 
103
  ## Social Post
104
 
105
+ > 🐦 *[Post link coming soon]*
 
 
 
 
 
 
106
 
107
  ---
108
 
109
+ **Build Small Hackathon 2026 Β· Thousand Token Wood Β· Modal**