Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
-
from diffusers import StableDiffusionPipeline
|
| 5 |
import random
|
| 6 |
|
| 7 |
print("๐ฎ Loading Game Character Generator...")
|
|
@@ -15,7 +15,8 @@ pipe = StableDiffusionPipeline.from_pretrained(
|
|
| 15 |
torch_dtype=torch.float16 if DEVICE == "cuda" else torch.float32,
|
| 16 |
safety_checker=None,
|
| 17 |
)
|
| 18 |
-
|
|
|
|
| 19 |
pipe.to(DEVICE)
|
| 20 |
|
| 21 |
if DEVICE == "cuda":
|
|
@@ -195,15 +196,13 @@ with gr.Blocks(
|
|
| 195 |
### ๐ก Tips for Best Results
|
| 196 |
|
| 197 |
โ
**Do:**
|
| 198 |
-
- Be specific
|
| 199 |
-
- Mention colors
|
| 200 |
- Try different game styles
|
| 201 |
-
- Use portrait for faces
|
| 202 |
|
| 203 |
โ **Avoid:**
|
| 204 |
- Vague descriptions
|
| 205 |
-
- Too many details
|
| 206 |
-
- Multiple characters in one image
|
| 207 |
""")
|
| 208 |
|
| 209 |
# Right column - Output
|
|
@@ -217,57 +216,16 @@ with gr.Blocks(
|
|
| 217 |
)
|
| 218 |
|
| 219 |
# Examples
|
| 220 |
-
gr.Markdown("### ๐จ Example Characters
|
| 221 |
|
| 222 |
gr.Examples(
|
| 223 |
examples=[
|
| 224 |
-
[
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
"holding sword, heroic pose",
|
| 229 |
-
512, 768, 30, 7.5, 42
|
| 230 |
-
],
|
| 231 |
-
[
|
| 232 |
-
"cute anime girl with twin tails and pink hair",
|
| 233 |
-
"Anime JRPG",
|
| 234 |
-
"character portrait",
|
| 235 |
-
"school uniform, smiling, cheerful",
|
| 236 |
-
512, 512, 30, 8.0, 123
|
| 237 |
-
],
|
| 238 |
-
[
|
| 239 |
-
"cyberpunk hacker with neon visor",
|
| 240 |
-
"Cyberpunk",
|
| 241 |
-
"full body character",
|
| 242 |
-
"tech gear, standing pose, glowing",
|
| 243 |
-
512, 768, 30, 7.5, 456
|
| 244 |
-
],
|
| 245 |
-
[
|
| 246 |
-
"dwarf warrior with battle axe",
|
| 247 |
-
"RPG Fantasy",
|
| 248 |
-
"full body character",
|
| 249 |
-
"red beard, heavy armor, tough",
|
| 250 |
-
512, 768, 30, 7.5, 789
|
| 251 |
-
],
|
| 252 |
-
[
|
| 253 |
-
"space marine in power armor",
|
| 254 |
-
"3D Realistic",
|
| 255 |
-
"full body character",
|
| 256 |
-
"futuristic, detailed, epic",
|
| 257 |
-
512, 768, 35, 7.5, 999
|
| 258 |
-
],
|
| 259 |
-
],
|
| 260 |
-
inputs=[
|
| 261 |
-
character_desc,
|
| 262 |
-
game_style,
|
| 263 |
-
character_type,
|
| 264 |
-
custom_prompt,
|
| 265 |
-
width,
|
| 266 |
-
height,
|
| 267 |
-
steps,
|
| 268 |
-
guidance,
|
| 269 |
-
seed
|
| 270 |
],
|
|
|
|
| 271 |
outputs=[output_image, output_info],
|
| 272 |
fn=generate_character,
|
| 273 |
cache_examples=False
|
|
@@ -276,62 +234,26 @@ with gr.Blocks(
|
|
| 276 |
# Event handler
|
| 277 |
generate_btn.click(
|
| 278 |
fn=generate_character,
|
| 279 |
-
inputs=[
|
| 280 |
-
character_desc,
|
| 281 |
-
game_style,
|
| 282 |
-
character_type,
|
| 283 |
-
custom_prompt,
|
| 284 |
-
width,
|
| 285 |
-
height,
|
| 286 |
-
steps,
|
| 287 |
-
guidance,
|
| 288 |
-
seed
|
| 289 |
-
],
|
| 290 |
outputs=[output_image, output_info]
|
| 291 |
)
|
| 292 |
|
| 293 |
-
# Footer
|
| 294 |
gr.Markdown("""
|
| 295 |
---
|
| 296 |
-
### ๐ฎ Game
|
| 297 |
-
|
| 298 |
-
| Style | Best For | Description |
|
| 299 |
-
|-------|----------|-------------|
|
| 300 |
-
| **RPG Fantasy** | D&D, Medieval | Classic fantasy with armor and weapons |
|
| 301 |
-
| **Anime JRPG** | Japanese RPG | Colorful anime aesthetic, vibrant |
|
| 302 |
-
| **Pixel Art Retro** | Indie Games | 8-bit/16-bit nostalgic style |
|
| 303 |
-
| **3D Realistic** | AAA Games | Photorealistic, detailed renders |
|
| 304 |
-
| **Cartoon Mobile** | Casual Games | Cute, simple, friendly characters |
|
| 305 |
-
| **Dark Souls** | Action RPG | Gothic, dark fantasy, dramatic |
|
| 306 |
-
| **Cyberpunk** | Sci-Fi | Neon, futuristic, high-tech |
|
| 307 |
-
| **Platformer** | Action Games | Mascot-style, fun and dynamic |
|
| 308 |
-
|
| 309 |
-
### ๐ Character View Types
|
| 310 |
|
| 311 |
-
- **
|
| 312 |
-
- **
|
| 313 |
-
- **
|
| 314 |
-
- **
|
| 315 |
-
- **
|
| 316 |
-
- **
|
| 317 |
-
- **
|
| 318 |
-
|
| 319 |
-
### ๐ฏ Performance Tips
|
| 320 |
-
|
| 321 |
-
- **CPU Mode**: Use 512x768, 20-25 steps (~2-3 min)
|
| 322 |
-
- **GPU Mode**: Use 512x768, 30-35 steps (~30 sec)
|
| 323 |
-
- **High Quality**: 768x1024, 40 steps (slow but best)
|
| 324 |
|
| 325 |
---
|
| 326 |
|
| 327 |
-
**Model:** DreamShaper 8 | **Framework:** Diffusers
|
| 328 |
-
|
| 329 |
-
Perfect for game developers, concept artists, and indie creators! ๐ฎโจ
|
| 330 |
""")
|
| 331 |
|
| 332 |
-
|
| 333 |
-
demo.queue(max_size=20).launch(
|
| 334 |
-
server_name="0.0.0.0",
|
| 335 |
-
port=7860,
|
| 336 |
-
share=False
|
| 337 |
-
)
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
+
from diffusers import StableDiffusionPipeline
|
| 5 |
import random
|
| 6 |
|
| 7 |
print("๐ฎ Loading Game Character Generator...")
|
|
|
|
| 15 |
torch_dtype=torch.float16 if DEVICE == "cuda" else torch.float32,
|
| 16 |
safety_checker=None,
|
| 17 |
)
|
| 18 |
+
|
| 19 |
+
# Usa lo scheduler di default del modello (no cambio necessario)
|
| 20 |
pipe.to(DEVICE)
|
| 21 |
|
| 22 |
if DEVICE == "cuda":
|
|
|
|
| 196 |
### ๐ก Tips for Best Results
|
| 197 |
|
| 198 |
โ
**Do:**
|
| 199 |
+
- Be specific about appearance
|
| 200 |
+
- Mention colors and clothing
|
| 201 |
- Try different game styles
|
|
|
|
| 202 |
|
| 203 |
โ **Avoid:**
|
| 204 |
- Vague descriptions
|
| 205 |
+
- Too many details
|
|
|
|
| 206 |
""")
|
| 207 |
|
| 208 |
# Right column - Output
|
|
|
|
| 216 |
)
|
| 217 |
|
| 218 |
# Examples
|
| 219 |
+
gr.Markdown("### ๐จ Example Characters")
|
| 220 |
|
| 221 |
gr.Examples(
|
| 222 |
examples=[
|
| 223 |
+
["knight with silver armor and red cape", "RPG Fantasy", "full body character", "holding sword, heroic", 512, 768, 30, 7.5, 42],
|
| 224 |
+
["cute anime girl with pink hair", "Anime JRPG", "character portrait", "smiling, cheerful", 512, 512, 30, 8.0, 123],
|
| 225 |
+
["cyberpunk hacker with neon visor", "Cyberpunk", "full body character", "tech gear, glowing", 512, 768, 30, 7.5, 456],
|
| 226 |
+
["dwarf warrior with battle axe", "RPG Fantasy", "full body character", "red beard, armor", 512, 768, 30, 7.5, 789],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
],
|
| 228 |
+
inputs=[character_desc, game_style, character_type, custom_prompt, width, height, steps, guidance, seed],
|
| 229 |
outputs=[output_image, output_info],
|
| 230 |
fn=generate_character,
|
| 231 |
cache_examples=False
|
|
|
|
| 234 |
# Event handler
|
| 235 |
generate_btn.click(
|
| 236 |
fn=generate_character,
|
| 237 |
+
inputs=[character_desc, game_style, character_type, custom_prompt, width, height, steps, guidance, seed],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
outputs=[output_image, output_info]
|
| 239 |
)
|
| 240 |
|
|
|
|
| 241 |
gr.Markdown("""
|
| 242 |
---
|
| 243 |
+
### ๐ฎ Supported Game Styles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
+
- **RPG Fantasy**: Medieval, D&D style
|
| 246 |
+
- **Anime JRPG**: Japanese RPG aesthetic
|
| 247 |
+
- **Pixel Art**: Retro 8-bit/16-bit
|
| 248 |
+
- **3D Realistic**: AAA game quality
|
| 249 |
+
- **Cartoon Mobile**: Casual games
|
| 250 |
+
- **Dark Souls**: Gothic fantasy
|
| 251 |
+
- **Cyberpunk**: Futuristic sci-fi
|
| 252 |
+
- **Platformer**: Action game mascots
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
---
|
| 255 |
|
| 256 |
+
**Model:** DreamShaper 8 | **Framework:** Diffusers
|
|
|
|
|
|
|
| 257 |
""")
|
| 258 |
|
| 259 |
+
demo.queue(max_size=20).launch(server_name="0.0.0.0", port=7860, share=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|