Update app.py
Browse files
app.py
CHANGED
|
@@ -1,94 +1,324 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
def generate(prompt, neg="", w=1024, h=1024, steps=20, cfg=7.0, seed=-1):
|
| 14 |
-
import requests
|
| 15 |
-
|
| 16 |
if not prompt.strip():
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
import gradio as gr
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
with gr.Row():
|
| 78 |
-
with gr.Column(scale=2):
|
| 79 |
-
prompt = gr.Textbox(label="Prompt", lines=3, value="a red fox in snow, detailed, 8k")
|
| 80 |
-
neg = gr.Textbox(label="Negative", lines=2)
|
| 81 |
-
with gr.Column():
|
| 82 |
-
w = gr.Slider(512, 1024, 1024, 64, label="Width")
|
| 83 |
-
h = gr.Slider(512, 1024, 1024, 64, label="Height")
|
| 84 |
-
steps = gr.Slider(1, 50, 20, 1, label="Steps")
|
| 85 |
-
cfg = gr.Slider(1, 20, 7.0, 0.5, label="CFG")
|
| 86 |
-
seed = gr.Number(-1, label="Seed")
|
| 87 |
-
|
| 88 |
-
gen = gr.Button("Generate", variant="primary")
|
| 89 |
-
img = gr.Image(label="Output")
|
| 90 |
-
status = gr.Textbox(label="Status")
|
| 91 |
-
|
| 92 |
-
gen.click(generate, [prompt, neg, w, h, steps, cfg, seed], [img, status])
|
| 93 |
-
|
| 94 |
-
demo.launch(server_name="0.0.0.0", port=7860)
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
FLUX.2-klein-4B GGUF โ CPU-only Inference Space
|
| 3 |
+
็กฌไปถ็บฆๆ๏ผๆ GPU ยท CPU ยท 18 GB RAM
|
| 4 |
+
"""
|
| 5 |
|
| 6 |
+
import os
|
| 7 |
+
import time
|
| 8 |
+
import torch
|
| 9 |
+
import gradio as gr
|
| 10 |
+
from diffusers import FluxPipeline
|
| 11 |
+
|
| 12 |
+
# โโ ็ฏๅข้
็ฝฎ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 13 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 14 |
+
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 15 |
+
torch.set_num_threads(os.cpu_count() or 4)
|
| 16 |
+
|
| 17 |
+
MODEL_ID = "unsloth/FLUX-2-klein-4B-GGUF"
|
| 18 |
+
|
| 19 |
+
# โโ ๅ ่ฝฝๆจกๅ๏ผๅฏๅจๆถๆง่กไธๆฌก๏ผ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 20 |
+
print("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ")
|
| 21 |
+
print("โ FLUX.2-klein-4B GGUF โ CPU Inference โ")
|
| 22 |
+
print("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ")
|
| 23 |
+
print(f" Model : {MODEL_ID}")
|
| 24 |
+
print(f" Threads : {torch.get_num_threads()}")
|
| 25 |
+
print(f" PyTorch : {torch.__version__}")
|
| 26 |
+
print(" Loading...")
|
| 27 |
+
|
| 28 |
+
pipe = FluxPipeline.from_pretrained(
|
| 29 |
+
MODEL_ID,
|
| 30 |
+
torch_dtype=torch.float32, # CPU ไธๅฟ
้กป็จ float32
|
| 31 |
+
)
|
| 32 |
+
pipe = pipe.to("cpu")
|
| 33 |
+
|
| 34 |
+
# ๅฆๆ diffusers ๆฏๆ GGUF ๅ็ๅ ่ฝฝๅคฑ่ดฅ๏ผๅๆถไธๆนๆณจ้ไฝฟ็จๅค็จๆนๆก
|
| 35 |
+
# ๅค็จๆนๆก๏ผไปๅๅงๆจกๅๅ ่ฝฝ pipeline ้ชจๆถ๏ผๅๆฟๆข transformer ไธบ GGUF ๆ้
|
| 36 |
+
#
|
| 37 |
+
# from diffusers import FluxPipeline
|
| 38 |
+
# BASE_ID = "black-forest-labs/FLUX.2-klein-4B" # ๅๅง้้ๅๆจกๅ
|
| 39 |
+
# pipe = FluxPipeline.from_pretrained(BASE_ID, torch_dtype=torch.float32)
|
| 40 |
+
# # ็ถๅ็จ gguf ๅ
ๆๅจๅ ่ฝฝ้ๅๆ้ๆฟๆข pipe.transformer
|
| 41 |
|
| 42 |
+
print(" โ Model loaded successfully!\n")
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# โโ ๆจ็ๅฝๆฐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 46 |
+
@torch.no_grad()
|
| 47 |
+
def generate(
|
| 48 |
+
prompt: str,
|
| 49 |
+
negative_prompt: str,
|
| 50 |
+
width: int,
|
| 51 |
+
height: int,
|
| 52 |
+
steps: int,
|
| 53 |
+
guidance: float,
|
| 54 |
+
seed: int,
|
| 55 |
+
progress=gr.Progress(track_tqdm=True),
|
| 56 |
+
):
|
| 57 |
+
"""ๆๆฌ็ๆๅพๅ"""
|
| 58 |
|
|
|
|
|
|
|
|
|
|
| 59 |
if not prompt.strip():
|
| 60 |
+
raise gr.Error("่ฏท่พๅ
ฅๆ็คบ่ฏ")
|
| 61 |
+
|
| 62 |
+
# ็งๅญๅค็
|
| 63 |
+
seed = seed if seed >= 0 else int(time.time() * 1000) % (2**32)
|
| 64 |
+
generator = torch.Generator("cpu").manual_seed(seed)
|
| 65 |
+
|
| 66 |
+
t0 = time.time()
|
| 67 |
+
|
| 68 |
+
result = pipe(
|
| 69 |
+
prompt=prompt,
|
| 70 |
+
negative_prompt=negative_prompt if negative_prompt.strip() else None,
|
| 71 |
+
width=width,
|
| 72 |
+
height=height,
|
| 73 |
+
num_inference_steps=steps,
|
| 74 |
+
guidance_scale=guidance,
|
| 75 |
+
generator=generator,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
dt = time.time() - t0
|
| 79 |
+
img = result.images[0]
|
| 80 |
+
|
| 81 |
+
return img, seed, f"ๅฎๆ ยท ่ๆถ {dt:.1f}s ยท seed {seed}"
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
# โโ ๆ ทๅผ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 85 |
+
CSS = """
|
| 86 |
+
:root {
|
| 87 |
+
--bg: #0a0a0f;
|
| 88 |
+
--card: #13131a;
|
| 89 |
+
--card-hover: #1a1a24;
|
| 90 |
+
--border: #23233a;
|
| 91 |
+
--fg: #e4e4ec;
|
| 92 |
+
--muted: #6b6b80;
|
| 93 |
+
--accent: #7c5cfc;
|
| 94 |
+
--accent-glow: rgba(124, 92, 252, .25);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/* ๅ
จๅฑ่ๆฏ */
|
| 98 |
+
.gradio-container {
|
| 99 |
+
background: var(--bg) !important;
|
| 100 |
+
color: var(--fg) !important;
|
| 101 |
+
max-width: 1080px !important;
|
| 102 |
+
padding-top: 1rem !important;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/* ๅก็ */
|
| 106 |
+
.gr-block, .gr-panel {
|
| 107 |
+
background: var(--card) !important;
|
| 108 |
+
border: 1px solid var(--border) !important;
|
| 109 |
+
border-radius: 14px !important;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/* ่พๅ
ฅๆก */
|
| 113 |
+
.gr-input, .gr-text-input, textarea.gr-textbox,
|
| 114 |
+
input[type=number].gr-number {
|
| 115 |
+
background: #0e0e16 !important;
|
| 116 |
+
border: 1px solid var(--border) !important;
|
| 117 |
+
color: var(--fg) !important;
|
| 118 |
+
border-radius: 10px !important;
|
| 119 |
+
font-size: .92rem !important;
|
| 120 |
+
}
|
| 121 |
+
textarea.gr-textbox { resize: vertical !important; }
|
| 122 |
+
|
| 123 |
+
/* ๆ ็ญพ */
|
| 124 |
+
.gr-label {
|
| 125 |
+
color: var(--muted) !important;
|
| 126 |
+
font-size: .78rem !important;
|
| 127 |
+
text-transform: uppercase !important;
|
| 128 |
+
letter-spacing: .06em !important;
|
| 129 |
+
font-weight: 600 !important;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/* ๆ้ฎ */
|
| 133 |
+
.gr-button-primary {
|
| 134 |
+
background: linear-gradient(135deg, #7c5cfc, #a78bfa) !important;
|
| 135 |
+
border: none !important;
|
| 136 |
+
font-weight: 700 !important;
|
| 137 |
+
font-size: 1rem !important;
|
| 138 |
+
border-radius: 10px !important;
|
| 139 |
+
padding: .7rem 1.5rem !important;
|
| 140 |
+
box-shadow: 0 4px 24px var(--accent-glow) !important;
|
| 141 |
+
transition: all .2s ease !important;
|
| 142 |
+
}
|
| 143 |
+
.gr-button-primary:hover {
|
| 144 |
+
transform: translateY(-1px) !important;
|
| 145 |
+
box-shadow: 0 6px 32px var(--accent-glow) !important;
|
| 146 |
+
filter: brightness(1.1) !important;
|
| 147 |
+
}
|
| 148 |
+
.gr-button-primary:active {
|
| 149 |
+
transform: translateY(0) !important;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/* ๆปๅ */
|
| 153 |
+
.gr-slider input[type=range] { accent-color: var(--accent) !important; }
|
| 154 |
+
|
| 155 |
+
/* ๅพ็่พๅบ */
|
| 156 |
+
.gr-image { border-radius: 12px !important; overflow: hidden !important; }
|
| 157 |
+
.gr-image img { border-radius: 12px !important; }
|
| 158 |
+
|
| 159 |
+
/* Examples */
|
| 160 |
+
.gr-examples { border-radius: 12px !important; }
|
| 161 |
+
|
| 162 |
+
/* ้่ footer */
|
| 163 |
+
footer { display: none !important; }
|
| 164 |
+
|
| 165 |
+
/* ๆปๅจๆก */
|
| 166 |
+
::-webkit-scrollbar { width: 6px; }
|
| 167 |
+
::-webkit-scrollbar-track { background: transparent; }
|
| 168 |
+
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
|
| 169 |
+
|
| 170 |
+
/* ่ญฆๅๆก */
|
| 171 |
+
.warn-bar {
|
| 172 |
+
background: linear-gradient(90deg, #1c1a2e, #1a1428);
|
| 173 |
+
border: 1px solid #2e2848;
|
| 174 |
+
border-radius: 10px;
|
| 175 |
+
padding: .7rem 1rem;
|
| 176 |
+
margin-bottom: 1.2rem;
|
| 177 |
+
font-size: .82rem;
|
| 178 |
+
color: #a0a0b8;
|
| 179 |
+
line-height: 1.5;
|
| 180 |
+
}
|
| 181 |
+
.warn-bar strong { color: #c4b5fd; }
|
| 182 |
+
|
| 183 |
+
/* ไฟกๆฏๆ */
|
| 184 |
+
.info-bar {
|
| 185 |
+
background: #0e0e16;
|
| 186 |
+
border: 1px solid var(--border);
|
| 187 |
+
border-radius: 8px;
|
| 188 |
+
padding: .5rem .8rem;
|
| 189 |
+
font-size: .82rem;
|
| 190 |
+
color: var(--muted);
|
| 191 |
+
font-family: 'SF Mono', 'Fira Code', monospace;
|
| 192 |
+
}
|
| 193 |
+
"""
|
| 194 |
+
|
| 195 |
+
# โโ ๆๅปบ็้ข โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 196 |
+
with gr.Blocks(
|
| 197 |
+
title="FLUX.2-klein-4B GGUF",
|
| 198 |
+
css=CSS,
|
| 199 |
+
theme=gr.themes.Soft(primary_hue="violet"),
|
| 200 |
+
) as demo:
|
| 201 |
+
|
| 202 |
+
# โโ ้กถ้จๆ ้ข โโ
|
| 203 |
+
gr.HTML("""
|
| 204 |
+
<div style="text-align:center; padding:2rem 0 .6rem">
|
| 205 |
+
<h1 style="font-size:2.4rem; font-weight:800; letter-spacing:-.03em;
|
| 206 |
+
background:linear-gradient(135deg,#7c5cfc 0%,#c084fc 50%,#f0abfc 100%);
|
| 207 |
+
-webkit-background-clip:text; -webkit-text-fill-color:transparent;
|
| 208 |
+
margin:0; line-height:1.2">
|
| 209 |
+
FLUX.2-klein-4B
|
| 210 |
+
</h1>
|
| 211 |
+
<p style="color:#555; font-size:.88rem; margin-top:.5rem; font-weight:500;
|
| 212 |
+
letter-spacing:.08em; text-transform:uppercase">
|
| 213 |
+
GGUF Quantized ยท CPU Inference ยท 4B Parameters
|
| 214 |
+
</p>
|
| 215 |
+
</div>
|
| 216 |
+
""")
|
| 217 |
+
|
| 218 |
+
# โโ ่ญฆๅ โโ
|
| 219 |
+
gr.HTML("""
|
| 220 |
+
<div class="warn-bar">
|
| 221 |
+
⚠ ็บฏ CPU ๆจ็๏ฟฝ๏ฟฝ๏ฟฝ้ๅบฆ่พๆ
ขใๅปบ่ฎฎ <strong>512ร512</strong> ไปฅไธๅ่พจ็ +
|
| 222 |
+
<strong>8~12 ๆญฅ</strong>๏ผ้ฆๆฌก็ๆไผๅ JIT ็ผ่ฏๆดๆ
ข๏ผๅ็ปญไผๅ ้ใ
|
| 223 |
+
ๅฆๆ่ถ
ๆถ๏ผ่ฏท่ฟไธๆญฅ้ไฝๅ่พจ็ๆๆญฅๆฐใ
|
| 224 |
+
</div>
|
| 225 |
+
""")
|
| 226 |
+
|
| 227 |
+
with gr.Row(equal_height=False):
|
| 228 |
+
|
| 229 |
+
# โโ ๅทฆๆ ๏ผๆงๅถ้ขๆฟ โโ
|
| 230 |
+
with gr.Column(scale=3):
|
| 231 |
+
|
| 232 |
+
prompt = gr.Textbox(
|
| 233 |
+
label="Prompt",
|
| 234 |
+
placeholder="A cyberpunk city at night with neon signs reflecting in rain-soaked streets, cinematic lighting...",
|
| 235 |
+
lines=3,
|
| 236 |
+
show_label=True,
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
negative_prompt = gr.Textbox(
|
| 240 |
+
label="Negative Prompt",
|
| 241 |
+
placeholder="blurry, low quality, distorted, watermark...",
|
| 242 |
+
lines=1,
|
| 243 |
+
show_label=True,
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
with gr.Row():
|
| 247 |
+
w = gr.Slider(256, 768, value=512, step=64, label="Width")
|
| 248 |
+
h = gr.Slider(256, 768, value=512, step=64, label="Height")
|
| 249 |
+
|
| 250 |
+
with gr.Row():
|
| 251 |
+
steps = gr.Slider(4, 30, value=10, step=1, label="Steps")
|
| 252 |
+
guidance = gr.Slider(1.0, 10.0, value=3.5, step=0.5, label="Guidance Scale")
|
| 253 |
+
|
| 254 |
+
seed = gr.Number(label="Seed๏ผ-1 ้ๆบ๏ผ", value=-1, precision=0)
|
| 255 |
+
|
| 256 |
+
btn = gr.Button("โฆ Generate", variant="primary", size="lg")
|
| 257 |
+
|
| 258 |
+
# ็คบไพๆ็คบ่ฏ
|
| 259 |
+
gr.Examples(
|
| 260 |
+
examples=[
|
| 261 |
+
[
|
| 262 |
+
"A serene Japanese garden with cherry blossoms falling over a stone bridge, koi pond below, golden hour lighting, 4K",
|
| 263 |
+
""
|
| 264 |
+
],
|
| 265 |
+
[
|
| 266 |
+
"Futuristic space station interior, holographic star maps floating in zero gravity, bioluminescent plants, cinematic wide shot",
|
| 267 |
+
""
|
| 268 |
+
],
|
| 269 |
+
[
|
| 270 |
+
"Oil painting of a cozy wooden cabin in snowy mountains, warm orange light from windows, smoke from chimney, impressionist style",
|
| 271 |
+
""
|
| 272 |
+
],
|
| 273 |
+
[
|
| 274 |
+
"Macro photograph of a dewdrop on a spider web at sunrise, prismatic light refraction, extreme shallow depth of field",
|
| 275 |
+
""
|
| 276 |
+
],
|
| 277 |
+
[
|
| 278 |
+
"A whimsical treehouse library at twilight, floating books with glowing pages, warm lanterns, fairy tale atmosphere",
|
| 279 |
+
"blurry, low quality"
|
| 280 |
+
],
|
| 281 |
+
[
|
| 282 |
+
"Underwater coral reef city with bioluminescent architecture, schools of tropical fish, volumetric god rays, wide angle",
|
| 283 |
+
""
|
| 284 |
+
],
|
| 285 |
+
],
|
| 286 |
+
inputs=[prompt, negative_prompt],
|
| 287 |
+
label="Quick Examples",
|
| 288 |
+
)
|
| 289 |
+
|
| 290 |
+
# โโ ๅณๆ ๏ผ่พๅบ โโ
|
| 291 |
+
with gr.Column(scale=4):
|
| 292 |
+
output_img = gr.Image(
|
| 293 |
+
label="Output",
|
| 294 |
+
show_label=False,
|
| 295 |
+
height=540,
|
| 296 |
+
elem_classes="output-image",
|
| 297 |
+
)
|
| 298 |
+
info_text = gr.Textbox(
|
| 299 |
+
label="Status",
|
| 300 |
+
interactive=False,
|
| 301 |
+
show_label=True,
|
| 302 |
+
max_lines=1,
|
| 303 |
+
elem_classes="info-bar",
|
| 304 |
+
value="Ready โ enter a prompt and click Generate",
|
| 305 |
+
)
|
| 306 |
+
|
| 307 |
+
# โโ ็ปๅฎไบไปถ โโ
|
| 308 |
+
btn.click(
|
| 309 |
+
fn=generate,
|
| 310 |
+
inputs=[prompt, negative_prompt, w, h, steps, guidance, seed],
|
| 311 |
+
outputs=[output_img, seed, info_text],
|
| 312 |
+
)
|
| 313 |
+
|
| 314 |
+
# ๅ่ฝฆไน่ฝ่งฆๅ
|
| 315 |
+
prompt.submit(
|
| 316 |
+
fn=generate,
|
| 317 |
+
inputs=[prompt, negative_prompt, w, h, steps, guidance, seed],
|
| 318 |
+
outputs=[output_img, seed, info_text],
|
| 319 |
+
)
|
| 320 |
|
|
|
|
| 321 |
|
| 322 |
+
# โโ ๅฏๅจ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๏ฟฝ๏ฟฝโโ
|
| 323 |
+
if __name__ == "__main__":
|
| 324 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|