Spaces:
Running
on
Zero
Running
on
Zero
Commit
ยท
47e50c0
1
Parent(s):
467f36e
Add Korean localization and CLAUDE.md documentation
Browse files- Localize UI labels and example prompts to Korean
- Add CLAUDE.md with architecture overview and development guidance
- Translate all Gradio interface elements (title, labels, placeholders, buttons)
- Translate error messages to Korean
๐ค Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
CLAUDE.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CLAUDE.md
|
| 2 |
+
|
| 3 |
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
Z-Image-Turbo is a Gradio-based Hugging Face Space for image generation using the Z-Image diffusion transformer model. It provides a web interface for text-to-image generation with optional prompt enhancement via API.
|
| 8 |
+
|
| 9 |
+
## Running the Application
|
| 10 |
+
|
| 11 |
+
**Start the Gradio app:**
|
| 12 |
+
```bash
|
| 13 |
+
python app.py
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
The app will launch with MCP server support enabled and be accessible via the Gradio interface.
|
| 17 |
+
|
| 18 |
+
## Environment Variables
|
| 19 |
+
|
| 20 |
+
Required environment variables (set these before running):
|
| 21 |
+
|
| 22 |
+
- `MODEL_PATH`: Path or HF model ID (default: "Tongyi-MAI/Z-Image-Turbo")
|
| 23 |
+
- `HF_TOKEN`: Hugging Face token for model access
|
| 24 |
+
- `DASHSCOPE_API_KEY`: Optional, for prompt enhancement feature (currently disabled in UI)
|
| 25 |
+
- `ENABLE_COMPILE`: Enable torch.compile optimizations (default: "true")
|
| 26 |
+
- `ENABLE_WARMUP`: Warmup model on startup (default: "true")
|
| 27 |
+
- `ATTENTION_BACKEND`: Attention implementation (default: "flash_3")
|
| 28 |
+
|
| 29 |
+
## Architecture
|
| 30 |
+
|
| 31 |
+
### Core Components
|
| 32 |
+
|
| 33 |
+
**app.py** - Main application file containing:
|
| 34 |
+
- Model loading and initialization (`load_models`, `init_app`)
|
| 35 |
+
- Image generation pipeline using ZImagePipeline from diffusers
|
| 36 |
+
- Gradio UI with resolution presets and generation controls
|
| 37 |
+
- Optional prompt enhancement via DashScope API (currently disabled in UI)
|
| 38 |
+
- Zero GPU integration with AoTI (Ahead of Time Inductor) compilation
|
| 39 |
+
|
| 40 |
+
**pe.py** - Contains `prompt_template` for the prompt expander, a Chinese language system prompt that guides LLMs to transform user prompts into detailed visual descriptions suitable for image generation models.
|
| 41 |
+
|
| 42 |
+
### Key Functions
|
| 43 |
+
|
| 44 |
+
**`generate(prompt, resolution, seed, steps, shift, enhance, random_seed, gallery_images, progress)`** (app.py:366)
|
| 45 |
+
- Main generation function decorated with `@spaces.GPU`
|
| 46 |
+
- Processes prompt, applies settings, generates image
|
| 47 |
+
- Returns updated gallery, seed used
|
| 48 |
+
- The `enhance` parameter is currently disabled in the UI but functional in code
|
| 49 |
+
|
| 50 |
+
**`load_models(model_path, enable_compile, attention_backend)`** (app.py:100)
|
| 51 |
+
- Loads VAE, text encoder, tokenizer, and transformer
|
| 52 |
+
- Applies torch.compile optimizations if enabled
|
| 53 |
+
- Configures attention backend (native/flash_3)
|
| 54 |
+
|
| 55 |
+
**`warmup_model(pipe, resolutions)`** (app.py:205)
|
| 56 |
+
- Pre-warms model for all resolution configurations
|
| 57 |
+
- Reduces first-generation latency
|
| 58 |
+
|
| 59 |
+
### Resolution System
|
| 60 |
+
|
| 61 |
+
The app supports two resolution categories (1024 and 1280) with multiple aspect ratios:
|
| 62 |
+
- 1:1, 9:7, 7:9, 4:3, 3:4, 3:2, 2:3, 16:9, 9:16, 21:9, 9:21
|
| 63 |
+
- Resolutions are stored in `RES_CHOICES` dict and parsed via `get_resolution()`
|
| 64 |
+
|
| 65 |
+
### Prompt Enhancement (Currently Disabled)
|
| 66 |
+
|
| 67 |
+
The `PromptExpander` and `APIPromptExpander` classes provide optional prompt enhancement via DashScope API:
|
| 68 |
+
- Backend: OpenAI-compatible API at dashscope.aliyuncs.com
|
| 69 |
+
- Model: qwen3-max-preview
|
| 70 |
+
- System prompt from `pe.prompt_template` guides detailed visual description generation
|
| 71 |
+
- UI controls are commented out but underlying code is functional
|
| 72 |
+
|
| 73 |
+
## Dependencies
|
| 74 |
+
|
| 75 |
+
Install via:
|
| 76 |
+
```bash
|
| 77 |
+
pip install -r requirements.txt
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
Key dependencies:
|
| 81 |
+
- gradio (UI framework)
|
| 82 |
+
- torch, transformers, diffusers (ML models)
|
| 83 |
+
- spaces (Hugging Face Spaces integration)
|
| 84 |
+
- openai (for optional prompt enhancement)
|
| 85 |
+
- Custom diffusers fork from GitHub with Z-Image support
|
| 86 |
+
|
| 87 |
+
## Model Details
|
| 88 |
+
|
| 89 |
+
- Architecture: Single-stream diffusion transformer (Z-Image)
|
| 90 |
+
- Scheduler: FlowMatchEulerDiscreteScheduler with configurable shift parameter
|
| 91 |
+
- Precision: bfloat16
|
| 92 |
+
- Device: CUDA required
|
| 93 |
+
- Attention: Configurable backend (native or flash_3)
|
| 94 |
+
|
| 95 |
+
## Zero GPU Integration
|
| 96 |
+
|
| 97 |
+
The app uses Hugging Face Spaces Zero GPU features:
|
| 98 |
+
- `@spaces.GPU` decorator on generate function
|
| 99 |
+
- AoTI (Ahead of Time Inductor) compilation for transformer blocks (app.py:458-459)
|
| 100 |
+
- Pre-compiled blocks loaded from "zerogpu-aoti/Z-Image" with flash_attention_3 variant
|
app.py
CHANGED
|
@@ -68,24 +68,24 @@ for resolutions in RES_CHOICES.values():
|
|
| 68 |
RESOLUTION_SET.extend(resolutions)
|
| 69 |
|
| 70 |
EXAMPLE_PROMPTS = [
|
| 71 |
-
["
|
| 72 |
[
|
| 73 |
-
"
|
| 74 |
],
|
| 75 |
[
|
| 76 |
-
"
|
| 77 |
],
|
| 78 |
[
|
| 79 |
-
"
|
| 80 |
],
|
| 81 |
[
|
| 82 |
-
'''
|
| 83 |
],
|
| 84 |
[
|
| 85 |
-
"""
|
| 86 |
],
|
| 87 |
[
|
| 88 |
-
"""
|
| 89 |
],
|
| 90 |
]
|
| 91 |
|
|
@@ -348,19 +348,19 @@ def init_app():
|
|
| 348 |
|
| 349 |
def prompt_enhance(prompt, enable_enhance):
|
| 350 |
if not enable_enhance or not prompt_expander:
|
| 351 |
-
return prompt, "
|
| 352 |
|
| 353 |
if not prompt.strip():
|
| 354 |
-
return "", "
|
| 355 |
|
| 356 |
try:
|
| 357 |
result = prompt_expander(prompt)
|
| 358 |
if result.status:
|
| 359 |
return result.prompt, result.message
|
| 360 |
else:
|
| 361 |
-
return prompt, f"
|
| 362 |
except Exception as e:
|
| 363 |
-
return prompt, f"
|
| 364 |
|
| 365 |
|
| 366 |
@spaces.GPU
|
|
@@ -416,7 +416,7 @@ def generate(
|
|
| 416 |
- seed_int: Integer representation of the seed used for generation
|
| 417 |
"""
|
| 418 |
if pipe is None:
|
| 419 |
-
raise gr.Error("
|
| 420 |
|
| 421 |
final_prompt = prompt
|
| 422 |
|
|
@@ -458,53 +458,53 @@ init_app()
|
|
| 458 |
pipe.transformer.layers._repeated_blocks = ["ZImageTransformerBlock"]
|
| 459 |
spaces.aoti_blocks_load(pipe.transformer.layers, "zerogpu-aoti/Z-Image", variant="fa3")
|
| 460 |
|
| 461 |
-
with gr.Blocks(title="Z-Image
|
| 462 |
gr.Markdown(
|
| 463 |
"""<div align="center">
|
| 464 |
-
|
| 465 |
-
# Z-Image
|
| 466 |
|
| 467 |
[](https://github.com/Tongyi-MAI/Z-Image)
|
| 468 |
|
| 469 |
-
|
| 470 |
|
| 471 |
</div>"""
|
| 472 |
)
|
| 473 |
|
| 474 |
with gr.Row():
|
| 475 |
with gr.Column(scale=1):
|
| 476 |
-
prompt_input = gr.Textbox(label="
|
| 477 |
# PE components (Temporarily disabled)
|
| 478 |
# with gr.Row():
|
| 479 |
-
# enable_enhance = gr.Checkbox(label="
|
| 480 |
-
# enhance_btn = gr.Button("
|
| 481 |
|
| 482 |
with gr.Row():
|
| 483 |
choices = [int(k) for k in RES_CHOICES.keys()]
|
| 484 |
-
res_cat = gr.Dropdown(value=1024, choices=choices, label="
|
| 485 |
|
| 486 |
initial_res_choices = RES_CHOICES["1024"]
|
| 487 |
-
resolution = gr.Dropdown(value=initial_res_choices[0], choices=RESOLUTION_SET, label="
|
| 488 |
|
| 489 |
with gr.Row():
|
| 490 |
-
seed = gr.Number(label="
|
| 491 |
-
random_seed = gr.Checkbox(label="
|
| 492 |
|
| 493 |
with gr.Row():
|
| 494 |
-
steps = gr.Slider(label="
|
| 495 |
-
shift = gr.Slider(label="
|
| 496 |
|
| 497 |
-
generate_btn = gr.Button("
|
| 498 |
|
| 499 |
# Example prompts
|
| 500 |
-
gr.Markdown("### ๐
|
| 501 |
gr.Examples(examples=EXAMPLE_PROMPTS, inputs=prompt_input, label=None)
|
| 502 |
|
| 503 |
with gr.Column(scale=1):
|
| 504 |
output_gallery = gr.Gallery(
|
| 505 |
-
label="
|
| 506 |
)
|
| 507 |
-
used_seed = gr.Textbox(label="
|
| 508 |
|
| 509 |
def update_res_choices(_res_cat):
|
| 510 |
if str(_res_cat) in RES_CHOICES:
|
|
|
|
| 68 |
RESOLUTION_SET.extend(resolutions)
|
| 69 |
|
| 70 |
EXAMPLE_PROMPTS = [
|
| 71 |
+
["ํ ๋จ์ฑ๊ณผ ๊ทธ์ ํธ๋ค์ด ์ด์ธ๋ฆฌ๋ ์์์ ์
๊ณ ์ค๋ด ์กฐ๋ช
์๋ ๊ด๊ฐ๋ค์ด ์๋ ๋ฐฐ๊ฒฝ์์ ๊ฐ ์ผ์ ์ฐธ๊ฐํ๊ณ ์๋ ๋ชจ์ต."],
|
| 72 |
[
|
| 73 |
+
"๋ถ์๊ธฐ ์๋ ์ด๋์ด ํค์ ์ธ๋ฌผ ์ฌ์ง, ์ฐ์ํ ์ค๊ตญ ์ฌ์ฑ์ด ์ด๋์ด ๋ฐฉ์ ์๋ค. ๊ฐํ ๋น์ด ์
ํฐ๋ฅผ ํต๊ณผํด ๊ทธ๋
์ ์ผ๊ต์ ๋ฒ๊ฐ ๋ชจ์์ ์ ๋ช
ํ ๋น๊ณผ ๊ทธ๋ฆผ์๋ฅผ ํฌ์ฌํ๋ฉฐ ํ์ชฝ ๋๋ง์ ์ ํํ ๋น์ถ๋ค. ๋์ ๋๋น, ๋ช
์ ๊ฒฝ๊ณ๊ฐ ์ ๋ช
ํ๋ฉฐ, ์ ๋น๋ก์ด ๋๋, ๋ผ์ด์นด ์นด๋ฉ๋ผ ์์กฐ."
|
| 74 |
],
|
| 75 |
[
|
| 76 |
+
"๋ฐ๊ฒ ์กฐ๋ช
๋ ์๋ฆฌ๋ฒ ์ดํฐ ์์์ ๊ธด ๊ฒ์ ๋จธ๋ฆฌ๋ฅผ ํ ์ ์ ๋์์์ ์ฌ์ฑ์ด ๊ฑฐ์ธ์ ํฅํด ์
์นด๋ฅผ ์ฐ๋ ์ค๊ฐ ๊ฑฐ๋ฆฌ ์ค๋งํธํฐ ์
์นด ์ฌ์ง. ๊ทธ๋
๋ ํฐ์ ๊ฝ๋ฌด๋ฌ๊ฐ ์๋ ๊ฒ์์ ์คํ์๋ ํฌ๋กญํ๊ณผ ์ด๋์ด ์ฒญ๋ฐ์ง๋ฅผ ์
๊ณ ์๋ค. ๋จธ๋ฆฌ๋ฅผ ์ฝ๊ฐ ๊ธฐ์ธ์ด๊ณ ์
์ ์ ๋พฐ์กฑํ๊ฒ ๋ด๋ฐ์ด ํค์คํ๋ ๋ฏํ ํฌ์ฆ๋ก ๋งค์ฐ ๊ท์ฝ๊ณ ์ฅ๋์ค๋ฌ์ด ๋ชจ์ต์ด๋ค. ์ค๋ฅธ์์ ์ง์ ํ์ ์ค๋งํธํฐ์ ๋ค๊ณ ์ผ๊ตด ์ผ๋ถ๋ฅผ ๊ฐ๋ฆฌ๊ณ ์์ผ๋ฉฐ, ํ๋ฉด ์นด๋ฉ๋ผ ๋ ์ฆ๊ฐ ๊ฑฐ์ธ์ ํฅํ๊ณ ์๋ค."
|
| 77 |
],
|
| 78 |
[
|
| 79 |
+
"๋นจ๊ฐ ํํธ๋ฅผ ์
์ ์ ์ ์ค๊ตญ ์ฌ์ฑ, ์ ๊ตํ ์์. ์๋ฒฝํ ๋ฉ์ดํฌ์
, ๋ถ์ ๊ฝ๋ฌด๋ฌ ์ด๋ง ์ฅ์. ์ ๊ตํ ๋์ ์ชฝ์ง ๋จธ๋ฆฌ, ๊ธ๋น ๋ดํฉ ๋จธ๋ฆฌ ์ฅ์, ๋ถ์ ๊ฝ, ๊ตฌ์ฌ. ์ฌ์ธ๊ณผ ๋๋ฌด, ์๊ฐ ๊ทธ๋ ค์ง ๋ฅ๊ทผ ์ ์ด์ ๋ถ์ฑ๋ฅผ ๋ค๊ณ ์๋ค. ๋ค์จ ๋ฒ๊ฐ ๋ชจ์ ๋จํ (โก๏ธ), ๋ฐ์ ๋
ธ๋์ ๋น, ํผ์น ์ผ์ชฝ ์๋ฐ๋ฅ ์์. ๋ถ๋๋ฝ๊ฒ ์กฐ๋ช
๋ ์ผ์ธ ๋ฐค ๋ฐฐ๊ฒฝ, ์ค๋ฃจ์ฃ์ ๋ค์ธต ํ(์์ ๋์ํ), ํ๋ฆฟํ ์ปฌ๋ฌ ๋จผ ๋ถ๋น๋ค."
|
| 80 |
],
|
| 81 |
[
|
| 82 |
+
'''๊ณ ์ํ๊ณ ์ฅ์ํ ์ค๊ตญ ํ๊ฒฝ์ ๋ฌ์ฌํ ์ธ๋ก ํ์์ ๋์งํธ ์ผ๋ฌ์คํธ๋ ์ด์
์ผ๋ก, ์ ํต์ ์ธ ์ฐ์ํ ์คํ์ผ์ ํ๋์ ์ด๊ณ ๊น๋ํ ๋ฏธํ์ผ๋ก ์ฌํด์ํ๋ค. ์ฅ๋ฉด์ ์ค์ ๊ณ๊ณก์ ๋๋ฌ์ผ ๋ค์ํ ํ๋์๊ณผ ์ฒญ๋ก์ ์์์ ์ฐ๋ ์์ ๊ฐํ๋ฅธ ์ ๋ฒฝ์ด ์ง๋ฐฐํ๋ค. ๋ฉ๋ฆฌ ์ฐ๋ค์ด ์ธต์ธต์ด ์ฐํ ํ๋์๊ณผ ํฐ์ ์๊ฐ ์์ผ๋ก ์ฌ๋ผ์ง๋ฉฐ ๊ฐํ ๋๊ธฐ ์๊ทผ๊ฐ๊ณผ ๊น์ด๋ฅผ ๋ง๋ค์ด๋ธ๋ค. ๊ณ ์ํ ์ฒญ๋ก์ ๊ฐ์ด ๊ตฌ์ฑ์ ์ค์์ ๊ฐ๋ก์ง๋ฌ ํ๋ฅด๋ฉฐ, ์์ ์ ํต ์ค๊ตญ ๋ฐฐ, ์๋ง๋ ์ผํ์ด ๋ฌผ ์๋ฅผ ํญํดํ๊ณ ์๋ค. ๋ฐฐ๋ ๋ฐ์ ๋
ธ๋์ ์ฒ๋ง๊ณผ ๋ถ์ ์ ์ฒด๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ ๋ค์ ๋ถ๋๋ฌ์ด ๋ฌผ๊ฒฐ์ ๋จ๊ธด๋ค. ์ฌ๋ฌ ๋ช
์ ํฌ๋ฏธํ ์ธ๋ฌผ๋ค์ ํ์ฐ๊ณ ์๋ค. ๋
น์ ๋๋ฌด์ ์ผ๋ถ ๋งจ๊ฐ์ง ๋๋ฌด๋ฅผ ํฌํจํ ๋๋ฌธ๋๋ฌธํ ์์์ด ๋ฐ์ ์ ๋ฐ๊ณผ ๋ด์ฐ๋ฆฌ์ ๋ถ์ด ์๋ค. ์ ์ฒด ์กฐ๋ช
์ ๋ถ๋๋ฝ๊ณ ํ์ฐ๋์ด ์ ์ฒด ์ฅ๋ฉด์ ํ์จํ ๋น์ ๋๋ฆฌ์ด๋ค. ์ด๋ฏธ์ง ์ค์์ ํ
์คํธ๊ฐ ๊ฒน์ณ์ ธ ์๋ค. ํ
์คํธ ๋ธ๋ก ์๋จ์๋ ์์ํ๋ ๋ฌธ์๊ฐ ํฌํจ๋ ์๊ณ ๋นจ๊ฐ์์ ์ํ ๋์ฅ ๊ฐ์ ๋ก๊ณ ๊ฐ ์๋ค. ๊ทธ ์๋ ์์ ๊ฒ์์ ์ฐ์ธ๋ฆฌํ ๊ธ๊ผด๋ก 'Zao-Xiang * East Beauty & West Fashion * Z-Image'๋ผ๋ ๋จ์ด๊ฐ ์๋ค. ๊ทธ ๋ฐ๋ก ์๋ ๋ ํฐ ์ฐ์ํ ๊ฒ์์ ์ธ๋ฆฌํ ๊ธ๊ผด๋ก 'SHOW & SHARE CREATIVITY WITH THE WORLD'๋ผ๋ ๋จ์ด๊ฐ ์๋ค. ๊ทธ ์ค์๋ "SHOW & SHARE", "CREATIVITY", "WITH THE WORLD"๊ฐ ์๋ค.'''
|
| 83 |
],
|
| 84 |
[
|
| 85 |
+
"""๊ฐ์์ ์ํ ใํ์์ ๋งใ(The Taste of Memory)์ ์ํ ํฌ์คํฐ. ์ฅ๋ฉด์ ์๋ฐํ 19์ธ๊ธฐ ์คํ์ผ ์ฃผ๋ฐฉ์ ์ค์ ๋์ด ์๋ค. ํ๋ฉด ์ค์์ ์ ๊ฐ์ ๋จธ๋ฆฌ์ ์์ ์ฝง์์ผ์ ๊ฐ์ง ์ค๋
๋จ์ฑ(๋ฐฐ์ฐ ์์ ํํ ๋ฆฌ๊ฑด ์ฐ๊ธฐ)์ด ๋๋ฌด ํ
์ด๋ธ ๋ค์ ์ ์์ผ๋ฉฐ, ํฐ์ ์
์ธ , ๊ฒ์์ ์กฐ๋ผ, ๋ฒ ์ด์ง์ ์์น๋ง๋ฅผ ์
๊ณ ์๊ณ ํ ์ฌ์ฑ์ ๋ฐ๋ผ๋ณด๋ฉฐ ์์ ํฐ ๋ฉ์ด๋ฆฌ์ ์๊ณ ๊ธฐ๋ฅผ ๋ค๊ณ ์์ผ๋ฉฐ ์๋์๋ ๋๋ฌด ๋๋ง๊ฐ ์๋ค. ๊ทธ์ ์ค๋ฅธ์ชฝ์๋ ๋์ ์ชฝ์ง ๋จธ๋ฆฌ๋ฅผ ํ ๊ฒ์ ๋จธ๋ฆฌ ์ฌ์ฑ(๋ฐฐ์ฐ ์๋ฆฌ๋ ๋ฐด์ค ์ฐ๊ธฐ)์ด ํ
์ด๋ธ์ ๊ธฐ๋์ด ๊ทธ์๊ฒ ๋ถ๋๋ฝ๊ฒ ๋ฏธ์์ง๊ณ ์๋ค. ๊ทธ๋
๋ ์ฐํ ์ ์
์ธ ์ ์๋จ์ ํฐ์, ํ๋จ์ ํ๋์์ธ ๊ธด ์น๋ง๋ฅผ ์
๊ณ ์๋ค. ํ
์ด๋ธ ์์๋ ๋ค์ง ํ์ ์๋ฐฐ์ถ ์ฑ๊ฐ ์๋ ๋๋ง ์ธ์๋ ํฐ์ ๋์๊ธฐ ์ ์, ์ ์ ํ ํ๋ธ๊ฐ ์๊ณ , ์ผ์ชฝ ๋๋ฌด ์์ ์์๋ ์ง์ ์ ํฌ๋ ํ ์ก์ด๊ฐ ๋์ฌ ์๋ค. ๋ฐฐ๊ฒฝ์ ๊ฑฐ์น ๊ฒ ํ๋ฐฑ์์ผ๋ก ๋ฏธ์ฅ๋ ๋ฒฝ์ด๋ฉฐ ํ๊ฒฝํ ํ ์ ์ด ๊ฑธ๋ ค ์๋ค. ๊ฐ์ฅ ์ค๋ฅธ์ชฝ ์์
๋ ์์๋ ๋ณต๊ณ ํ ์ค์ผ ๋จํ๊ฐ ๋์ฌ ์๋ค. ํฌ์คํฐ์๋ ๋ง์ ํ
์คํธ ์ ๋ณด๊ฐ ์๋ค. ์ผ์ชฝ ์๋จ์๋ ํฐ์ ์ฐ์ธ๋ฆฌํ ๊ธ๊ผด๋ก "ARTISAN FILMS PRESENTS"๊ฐ ์๊ณ ๊ทธ ์๋์ "ELEANOR VANCE"์ "ACADEMY AWARDยฎ WINNER"๊ฐ ์๋ค. ์ค๋ฅธ์ชฝ ์๋จ์๋ "ARTHUR PENHALIGON"๊ณผ "GOLDEN GLOBEยฎ AWARD WINNER"๊ฐ ์ฐ์ฌ ์๋ค. ์๋จ ์ค์์๋ ์ ๋์ค ์ํ์ ์๊ณ๊ด ๋ก๊ณ ๊ฐ ์๊ณ ์๋์ "SUNDANCE FILM FESTIVAL GRAND JURY PRIZE 2024"๊ฐ ์ฐ์ฌ ์๋ค. ์ฃผ์ ์ ๋ชฉ "THE TASTE OF MEMORY"๋ ํฐ์์ ํฐ ์ธ๋ฆฌํ ๊ธ๊ผด๋ก ํ๋จ์ ๋์ ๋๊ฒ ํ์๋์ด ์๋ค. ์ ๋ชฉ ์๋์๋ "A FILM BY Tongyi Interaction Lab"์ด ๋ช
์๋์ด ์๋ค. ํ๋จ ์์ญ์๋ ํฐ์ ์์ ๊ธ์จ๋ก "SCREENPLAY BY ANNA REID", "CULINARY DIRECTION BY JAMES CARTER" ๋ฐ Artisan Films, Riverstone Pictures, Heritage Media ๋ฑ ์๋ง์ ์ ์์ฌ ๋ก๊ณ ๋ฅผ ํฌํจํ ์ ์ฒด ์ถ์ฐ์ง ๋ฐ ์ ์์ง ๋ช
๋จ์ด ๋์ด๋์ด ์๋ค. ์ ์ฒด์ ์ธ ์คํ์ผ์ ์ฌ์ค์ฃผ์๋ก ๋ฐ๋ปํ๊ณ ๋ถ๋๋ฌ์ด ์กฐ๋ช
๋ฐฉ์์ ์ฑํํ์ฌ ์น๋ฐํ ๋ถ์๊ธฐ๋ฅผ ์กฐ์ฑํ๋ค. ์์กฐ๋ ๊ฐ์, ๋ฒ ์ด์ง, ๋ถ๋๋ฌ์ด ๋
น์ ๋ฑ ๋์ง์ ํค์ด ์ฃผ๋ฅผ ์ด๋ฃฌ๋ค. ๋ ๋ฐฐ์ฐ์ ๋ชธ์ ๋ชจ๋ ํ๋ฆฌ์์ ์๋ ค ์๋ค."""
|
| 86 |
],
|
| 87 |
[
|
| 88 |
+
"""์ ์ฌ๊ฐํ ๊ตฌ๋์ ํด๋ก์ฆ์
์ฌ์ง์ผ๋ก, ๊ฑฐ๋ํ๊ณ ์ ๋ช
ํ ๋
น์ ์๋ฌผ ์์ด ์ฃผ์ ์ด๋ฉฐ ํ
์คํธ๊ฐ ๊ฒน์ณ์ ธ ํฌ์คํฐ๋ ์ก์ง ํ์ง ๊ฐ์ ์ธ๊ด์ ๊ฐ์ถ๊ณ ์๋ค. ์ฃผ์ ํผ์ฌ์ฒด๋ ์ผ์ชฝ ํ๋จ์์ ์ค๋ฅธ์ชฝ ์๋จ์ผ๋ก ๋๊ฐ์ ์ผ๋ก ๊ตฌ๋ถ๋ฌ์ ธ ํ๋ ์์ ๊ฐ๋ก์ง๋ฅด๋ ๋๊ป๊ณ ์์ค ๊ฐ์ ์ง๊ฐ์ ์์ด๋ค. ํ๋ฉด์ด ๋งค์ฐ ๋ฐ์ฌ์ ์ด์ด์ ๋ฐ์ ์ง์ฌ๊ด์์ ํฌ์ฐฉํ์ฌ ๋๋๋ฌ์ง ํ์ด๋ผ์ดํธ๋ฅผ ํ์ฑํ๊ณ ๋ฐ์ ๋ฉด ์๋ ํํํ ๋ฏธ์ธ ์๋งฅ์ด ๋๋ฌ๋๋ค. ๋ฐฐ๊ฒฝ์ ๋ค๋ฅธ ์ง์ ๋
น์ ์๋ค๋ก ๊ตฌ์ฑ๋์ด ์์ผ๋ฉฐ ์ฝ๊ฐ ์ด์ ์ด ํ๋ ค์ ธ ์์ ํผ์ฌ๊ณ ์ฌ๋ ํจ๊ณผ๋ฅผ ๋ง๋ค์ด ์ ๊ฒฝ์ ์ฃผ์ ์์ ๊ฐ์กฐํ๋ค. ์ ์ฒด์ ์ธ ์คํ์ผ์ ์ฌ์ค์ ์ธ ์ฌ์ง์ผ๋ก ๋ฐ์ ์๊ณผ ์ด๋์ด ๊ทธ๋ฆผ์ ๋ฐฐ๊ฒฝ ์ฌ์ด์ ๋์ ๋๋น๋ฅผ ํ์ฑํ๋ค. ์ด๋ฏธ์ง์๋ ์ฌ๋ฌ ๋ ๋๋ง๋ ํ
์คํธ๊ฐ ์๋ค. ์ผ์ชฝ ์๋จ์๋ ํฐ์ ์ธ๋ฆฌํ ๊ธ๊ผด๋ก "PIXEL-PEEPERS GUILD Presents"๋ผ๋ ํ
์คํธ๊ฐ ์๋ค. ์ค๋ฅธ์ชฝ ์๋จ์๋ ํฐ์ ์ธ๋ฆฌํ ๊ธ๊ผด๋ก "[Instant Noodle] ๆณก้ข่ฐๆๅ
"๋ผ๋ ํ
์คํธ๊ฐ ์๋ค. ์ผ์ชฝ์๋ ์์ง์ผ๋ก ๋ฐฐ์ด๋ ์ ๋ชฉ "Render Distance: Max"๊ฐ ํฐ์ ์ธ๋ฆฌํ ๊ธ๊ผด๋ก ๋์ด ์๋ค. ์ผ์ชฝ ํ๋จ์๋ ๋ค์ฏ ๊ฐ์ ๊ฑฐ๋ํ ํฐ์ ์ก์ฒด ํ์ "ๆพๅกๅจ...็็ง"๊ฐ ์๋ค. ์ค๋ฅธ์ชฝ ํ๋จ์๋ ์์ ํฐ์ ์ธ๋ฆฌํ ๊ธ๊ผด๋ก "Leica Glowโข Unobtanium X-1"์ด ์๊ณ , ๊ทธ ๋ฐ๋ก ์์๋ ํฐ์ ์ก์ฒด๋ก ์ฐ์ธ ์ด๋ฆ "่กๅ "๊ฐ ์๋ค. ์๋ณ๋ ํต์ฌ ๊ฐ์ฒด์๋ ๋ธ๋๋ ํฝ์
ํผํผ์ค ๊ธธ๋, ์ ํ ๋ผ์ธ ์ธ์คํดํธ ๋๋ค ์กฐ๋ฏธ๋ฃ ํจํค์ง, ์นด๋ฉ๋ผ ๋ชจ๋ธ Unobtaniumโข X-1 ๋ฐ ์ฌ์ง๊ฐ ์ด๋ฆ Zao-Xiang์ด ํฌํจ๋๋ค."""
|
| 89 |
],
|
| 90 |
]
|
| 91 |
|
|
|
|
| 348 |
|
| 349 |
def prompt_enhance(prompt, enable_enhance):
|
| 350 |
if not enable_enhance or not prompt_expander:
|
| 351 |
+
return prompt, "ํ๋กฌํํธ ํฅ์์ด ๋นํ์ฑํ๋์๊ฑฐ๋ ์ฌ์ฉํ ์ ์์ต๋๋ค."
|
| 352 |
|
| 353 |
if not prompt.strip():
|
| 354 |
+
return "", "ํ๋กฌํํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
| 355 |
|
| 356 |
try:
|
| 357 |
result = prompt_expander(prompt)
|
| 358 |
if result.status:
|
| 359 |
return result.prompt, result.message
|
| 360 |
else:
|
| 361 |
+
return prompt, f"ํฅ์ ์คํจ: {result.message}"
|
| 362 |
except Exception as e:
|
| 363 |
+
return prompt, f"์ค๋ฅ: {str(e)}"
|
| 364 |
|
| 365 |
|
| 366 |
@spaces.GPU
|
|
|
|
| 416 |
- seed_int: Integer representation of the seed used for generation
|
| 417 |
"""
|
| 418 |
if pipe is None:
|
| 419 |
+
raise gr.Error("๋ชจ๋ธ์ด ๋ก๋๋์ง ์์์ต๋๋ค.")
|
| 420 |
|
| 421 |
final_prompt = prompt
|
| 422 |
|
|
|
|
| 458 |
pipe.transformer.layers._repeated_blocks = ["ZImageTransformerBlock"]
|
| 459 |
spaces.aoti_blocks_load(pipe.transformer.layers, "zerogpu-aoti/Z-Image", variant="fa3")
|
| 460 |
|
| 461 |
+
with gr.Blocks(title="Z-Image ๋ฐ๋ชจ") as demo:
|
| 462 |
gr.Markdown(
|
| 463 |
"""<div align="center">
|
| 464 |
+
|
| 465 |
+
# Z-Image ์ด๋ฏธ์ง ์์ฑ ๋ฐ๋ชจ
|
| 466 |
|
| 467 |
[](https://github.com/Tongyi-MAI/Z-Image)
|
| 468 |
|
| 469 |
+
*๋จ์ผ ์คํธ๋ฆผ ๋ํจ์ ํธ๋์คํฌ๋จธ๋ฅผ ์ฌ์ฉํ ํจ์จ์ ์ธ ์ด๋ฏธ์ง ์์ฑ ๊ธฐ๋ฐ ๋ชจ๋ธ*
|
| 470 |
|
| 471 |
</div>"""
|
| 472 |
)
|
| 473 |
|
| 474 |
with gr.Row():
|
| 475 |
with gr.Column(scale=1):
|
| 476 |
+
prompt_input = gr.Textbox(label="ํ๋กฌํํธ", lines=3, placeholder="ํ๋กฌํํธ๋ฅผ ์
๋ ฅํ์ธ์...")
|
| 477 |
# PE components (Temporarily disabled)
|
| 478 |
# with gr.Row():
|
| 479 |
+
# enable_enhance = gr.Checkbox(label="ํ๋กฌํํธ ํฅ์ (DashScope)", value=False)
|
| 480 |
+
# enhance_btn = gr.Button("ํฅ์๋ง ์คํ")
|
| 481 |
|
| 482 |
with gr.Row():
|
| 483 |
choices = [int(k) for k in RES_CHOICES.keys()]
|
| 484 |
+
res_cat = gr.Dropdown(value=1024, choices=choices, label="ํด์๋ ์นดํ
๊ณ ๋ฆฌ")
|
| 485 |
|
| 486 |
initial_res_choices = RES_CHOICES["1024"]
|
| 487 |
+
resolution = gr.Dropdown(value=initial_res_choices[0], choices=RESOLUTION_SET, label="๋๋น x ๋์ด (๋น์จ)")
|
| 488 |
|
| 489 |
with gr.Row():
|
| 490 |
+
seed = gr.Number(label="์๋", value=42, precision=0)
|
| 491 |
+
random_seed = gr.Checkbox(label="๋๋ค ์๋", value=True)
|
| 492 |
|
| 493 |
with gr.Row():
|
| 494 |
+
steps = gr.Slider(label="์คํ
์", minimum=1, maximum=100, value=8, step=1, interactive=False)
|
| 495 |
+
shift = gr.Slider(label="์๊ฐ ์ด๋", minimum=1.0, maximum=10.0, value=3.0, step=0.1)
|
| 496 |
|
| 497 |
+
generate_btn = gr.Button("์์ฑ", variant="primary")
|
| 498 |
|
| 499 |
# Example prompts
|
| 500 |
+
gr.Markdown("### ๐ ์์ ํ๋กฌํํธ")
|
| 501 |
gr.Examples(examples=EXAMPLE_PROMPTS, inputs=prompt_input, label=None)
|
| 502 |
|
| 503 |
with gr.Column(scale=1):
|
| 504 |
output_gallery = gr.Gallery(
|
| 505 |
+
label="์์ฑ๋ ์ด๋ฏธ์ง", columns=2, rows=2, height=600, object_fit="contain", format="png", interactive=False
|
| 506 |
)
|
| 507 |
+
used_seed = gr.Textbox(label="์ฌ์ฉ๋ ์๋", interactive=False)
|
| 508 |
|
| 509 |
def update_res_choices(_res_cat):
|
| 510 |
if str(_res_cat) in RES_CHOICES:
|