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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gc
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from gradio import Server
|
| 5 |
+
from fastapi.responses import HTMLResponse
|
| 6 |
+
import numpy as np
|
| 7 |
+
import spaces
|
| 8 |
+
import torch
|
| 9 |
+
import random
|
| 10 |
+
import base64
|
| 11 |
+
import json
|
| 12 |
+
from io import BytesIO
|
| 13 |
+
from PIL import Image
|
| 14 |
+
|
| 15 |
+
MAX_SEED = np.iinfo(np.int32).max
|
| 16 |
+
LANCZOS = getattr(Image, "Resampling", Image).LANCZOS
|
| 17 |
+
|
| 18 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 19 |
+
|
| 20 |
+
print("CUDA_VISIBLE_DEVICES=", os.environ.get("CUDA_VISIBLE_DEVICES"))
|
| 21 |
+
print("torch.__version__ =", torch.__version__)
|
| 22 |
+
print("torch.version.cuda =", torch.version.cuda)
|
| 23 |
+
print("cuda available:", torch.cuda.is_available())
|
| 24 |
+
print("cuda device count:", torch.cuda.device_count())
|
| 25 |
+
if torch.cuda.is_available():
|
| 26 |
+
print("current device:", torch.cuda.current_device())
|
| 27 |
+
print("device name:", torch.cuda.get_device_name(torch.cuda.current_device()))
|
| 28 |
+
|
| 29 |
+
print("Using device:", device)
|
| 30 |
+
|
| 31 |
+
from diffusers import FlowMatchEulerDiscreteScheduler
|
| 32 |
+
from qwenimage.pipeline_qwenimage_edit_plus import QwenImageEditPlusPipeline
|
| 33 |
+
from qwenimage.transformer_qwenimage import QwenImageTransformer2DModel
|
| 34 |
+
from qwenimage.qwen_fa3_processor import QwenDoubleStreamAttnProcessorFA3
|
| 35 |
+
|
| 36 |
+
dtype = torch.bfloat16
|
| 37 |
+
|
| 38 |
+
pipe = QwenImageEditPlusPipeline.from_pretrained(
|
| 39 |
+
"Qwen/Qwen-Image-Edit-2511",
|
| 40 |
+
transformer=QwenImageTransformer2DModel.from_pretrained(
|
| 41 |
+
"prithivMLmods/Qwen-Image-Edit-Rapid-AIO-V19",
|
| 42 |
+
torch_dtype=dtype,
|
| 43 |
+
device_map="cuda",
|
| 44 |
+
),
|
| 45 |
+
torch_dtype=dtype,
|
| 46 |
+
).to(device)
|
| 47 |
+
|
| 48 |
+
try:
|
| 49 |
+
pipe.transformer.set_attn_processor(QwenDoubleStreamAttnProcessorFA3())
|
| 50 |
+
print("Flash Attention 3 Processor set successfully.")
|
| 51 |
+
except Exception as e:
|
| 52 |
+
print(f"Warning: Could not set FA3 processor: {e}")
|
| 53 |
+
|
| 54 |
+
ADAPTER_SPECS = {
|
| 55 |
+
"Multiple-Angles": {
|
| 56 |
+
"repo": "dx8152/Qwen-Edit-2509-Multiple-angles",
|
| 57 |
+
"weights": "镜头转换.safetensors",
|
| 58 |
+
"adapter_name": "multiple-angles",
|
| 59 |
+
},
|
| 60 |
+
"Photo-to-Anime": {
|
| 61 |
+
"repo": "autoweeb/Qwen-Image-Edit-2509-Photo-to-Anime",
|
| 62 |
+
"weights": "Qwen-Image-Edit-2509-Photo-to-Anime_000001000.safetensors",
|
| 63 |
+
"adapter_name": "photo-to-anime",
|
| 64 |
+
},
|
| 65 |
+
"Anime-V2": {
|
| 66 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Anime",
|
| 67 |
+
"weights": "Qwen-Image-Edit-2511-Anime-2000.safetensors",
|
| 68 |
+
"adapter_name": "anime-v2",
|
| 69 |
+
},
|
| 70 |
+
"Light-Migration": {
|
| 71 |
+
"repo": "dx8152/Qwen-Edit-2509-Light-Migration",
|
| 72 |
+
"weights": "参考色调.safetensors",
|
| 73 |
+
"adapter_name": "light-migration",
|
| 74 |
+
},
|
| 75 |
+
"Upscaler": {
|
| 76 |
+
"repo": "starsfriday/Qwen-Image-Edit-2511-Upscale2K",
|
| 77 |
+
"weights": "qwen_image_edit_2511_upscale.safetensors",
|
| 78 |
+
"adapter_name": "upscale-2k",
|
| 79 |
+
},
|
| 80 |
+
"Style-Transfer": {
|
| 81 |
+
"repo": "zooeyy/Style-Transfer",
|
| 82 |
+
"weights": "Style Transfer-Alpha-V0.1.safetensors",
|
| 83 |
+
"adapter_name": "style-transfer",
|
| 84 |
+
},
|
| 85 |
+
"Manga-Tone": {
|
| 86 |
+
"repo": "nappa114514/Qwen-Image-Edit-2509-Manga-Tone",
|
| 87 |
+
"weights": "tone001.safetensors",
|
| 88 |
+
"adapter_name": "manga-tone",
|
| 89 |
+
},
|
| 90 |
+
"Anything2Real": {
|
| 91 |
+
"repo": "lrzjason/Anything2Real_2601",
|
| 92 |
+
"weights": "anything2real_2601.safetensors",
|
| 93 |
+
"adapter_name": "anything2real",
|
| 94 |
+
},
|
| 95 |
+
"Fal-Multiple-Angles": {
|
| 96 |
+
"repo": "fal/Qwen-Image-Edit-2511-Multiple-Angles-LoRA",
|
| 97 |
+
"weights": "qwen-image-edit-2511-multiple-angles-lora.safetensors",
|
| 98 |
+
"adapter_name": "fal-multiple-angles",
|
| 99 |
+
},
|
| 100 |
+
"Polaroid-Photo": {
|
| 101 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Polaroid-Photo",
|
| 102 |
+
"weights": "Qwen-Image-Edit-2511-Polaroid-Photo.safetensors",
|
| 103 |
+
"adapter_name": "polaroid-photo",
|
| 104 |
+
},
|
| 105 |
+
"Unblur-Anything": {
|
| 106 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Unblur-Upscale",
|
| 107 |
+
"weights": "Qwen-Image-Edit-Unblur-Upscale_15.safetensors",
|
| 108 |
+
"adapter_name": "unblur-anything",
|
| 109 |
+
},
|
| 110 |
+
"Midnight-Noir-Eyes-Spotlight": {
|
| 111 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Midnight-Noir-Eyes-Spotlight",
|
| 112 |
+
"weights": "Qwen-Image-Edit-2511-Midnight-Noir-Eyes-Spotlight.safetensors",
|
| 113 |
+
"adapter_name": "midnight-noir-eyes-spotlight",
|
| 114 |
+
},
|
| 115 |
+
"Hyper-Realistic-Portrait": {
|
| 116 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Hyper-Realistic-Portrait",
|
| 117 |
+
"weights": "HRP_20.safetensors",
|
| 118 |
+
"adapter_name": "hyper-realistic-portrait",
|
| 119 |
+
},
|
| 120 |
+
"Ultra-Realistic-Portrait": {
|
| 121 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Ultra-Realistic-Portrait",
|
| 122 |
+
"weights": "URP_20.safetensors",
|
| 123 |
+
"adapter_name": "ultra-realistic-portrait",
|
| 124 |
+
},
|
| 125 |
+
"Pixar-Inspired-3D": {
|
| 126 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Pixar-Inspired-3D",
|
| 127 |
+
"weights": "PI3_20.safetensors",
|
| 128 |
+
"adapter_name": "pi3",
|
| 129 |
+
},
|
| 130 |
+
"Noir-Comic-Book": {
|
| 131 |
+
"repo": "prithivMLmods/Qwen-Image-Edit-2511-Noir-Comic-Book-Panel",
|
| 132 |
+
"weights": "Noir-Comic-Book-Panel_20.safetensors",
|
| 133 |
+
"adapter_name": "ncb",
|
| 134 |
+
},
|
| 135 |
+
"Any-light": {
|
| 136 |
+
"repo": "lilylilith/QIE-2511-MP-AnyLight",
|
| 137 |
+
"weights": "QIE-2511-AnyLight_.safetensors",
|
| 138 |
+
"adapter_name": "any-light",
|
| 139 |
+
},
|
| 140 |
+
"Studio-DeLight": {
|
| 141 |
+
"repo": "prithivMLmods/QIE-2511-Studio-DeLight",
|
| 142 |
+
"weights": "QIE-2511-Studio-DeLight-5000.safetensors",
|
| 143 |
+
"adapter_name": "studio-delight",
|
| 144 |
+
},
|
| 145 |
+
"Cinematic-FlatLog": {
|
| 146 |
+
"repo": "prithivMLmods/QIE-2511-Cinematic-FlatLog-Control",
|
| 147 |
+
"weights": "QIE-2511-Cinematic-FlatLog-Control-3200.safetensors",
|
| 148 |
+
"adapter_name": "flat-log",
|
| 149 |
+
},
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
LOADED_ADAPTERS: set = set()
|
| 153 |
+
ADAPTER_NAMES = list(ADAPTER_SPECS.keys())
|
| 154 |
+
|
| 155 |
+
EXAMPLES_CONFIG = [
|
| 156 |
+
{"images": ["examples/B.jpg"], "prompt": "Transform into anime.", "lora": "Photo-to-Anime"},
|
| 157 |
+
{"images": ["examples/HRP.jpg"], "prompt": "Transform into a hyper-realistic face portrait.", "lora": "Hyper-Realistic-Portrait"},
|
| 158 |
+
{"images": ["examples/A.jpeg"], "prompt": "Rotate the camera 45 degrees to the right.", "lora": "Multiple-Angles"},
|
| 159 |
+
{"images": ["examples/U.jpg"], "prompt": "Upscale this picture to 4K resolution.", "lora": "Upscaler"},
|
| 160 |
+
{"images": ["examples/L1.jpg", "examples/L2.jpg"], "prompt": "Apply the lighting from image 2 to image 1.", "lora": "Any-light"},
|
| 161 |
+
{"images": ["examples/PP1.jpg"], "prompt": "cinematic polaroid with soft grain subtle vignette gentle lighting white frame handwritten photographed preserving realistic texture and details.", "lora": "Polaroid-Photo"},
|
| 162 |
+
{"images": ["examples/Z1.jpg"], "prompt": "Front-right quarter view.", "lora": "Fal-Multiple-Angles"},
|
| 163 |
+
{"images": ["examples/URP.jpg"], "prompt": "Transform into a cinematic flat log.", "lora": "Cinematic-FlatLog"},
|
| 164 |
+
{"images": ["examples/SL.jpg"], "prompt": "Neutral uniform lighting. Preserve identity and composition.", "lora": "Studio-DeLight"},
|
| 165 |
+
{"images": ["examples/PI.jpg"], "prompt": "Transform it into Pixar-inspired 3D.", "lora": "Pixar-Inspired-3D"},
|
| 166 |
+
{"images": ["examples/MT.jpg"], "prompt": "Paint with manga tone.", "lora": "Manga-Tone"},
|
| 167 |
+
{"images": ["examples/NCB.jpg"], "prompt": "Transform into a noir comic book style.", "lora": "Noir-Comic-Book"},
|
| 168 |
+
{"images": ["examples/URP.jpg"], "prompt": "Ultra-realistic portrait.", "lora": "Ultra-Realistic-Portrait"},
|
| 169 |
+
{"images": ["examples/MN.jpg"], "prompt": "Transform into Midnight Noir Eyes Spotlight.", "lora": "Midnight-Noir-Eyes-Spotlight"},
|
| 170 |
+
{"images": ["examples/ST1.jpg", "examples/ST2.jpg"], "prompt": "Convert Image 1 to the style of Image 2.", "lora": "Style-Transfer"},
|
| 171 |
+
{"images": ["examples/R1.jpg"], "prompt": "Change the picture to realistic photograph.", "lora": "Anything2Real"},
|
| 172 |
+
{"images": ["examples/UA.jpeg"], "prompt": "Unblur and upscale.", "lora": "Unblur-Anything"},
|
| 173 |
+
{"images": ["examples/L1.jpg", "examples/L2.jpg"], "prompt": "Refer to the color tone, remove the original lighting from Image 1, and relight Image 1 based on the lighting and color tone of Image 2.", "lora": "Light-Migration"},
|
| 174 |
+
{"images": ["examples/P1.jpg"], "prompt": "Transform into anime (while preserving the background and remaining elements maintaining realism and original details.)", "lora": "Anime-V2"},
|
| 175 |
+
]
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def make_thumb_b64(path, max_dim=220):
|
| 179 |
+
if not os.path.exists(path):
|
| 180 |
+
return ""
|
| 181 |
+
try:
|
| 182 |
+
img = Image.open(path).convert("RGB")
|
| 183 |
+
img.thumbnail((max_dim, max_dim), LANCZOS)
|
| 184 |
+
buf = BytesIO()
|
| 185 |
+
img.save(buf, format="JPEG", quality=65)
|
| 186 |
+
return f"data:image/jpeg;base64,{base64.b64encode(buf.getvalue()).decode()}"
|
| 187 |
+
except Exception as e:
|
| 188 |
+
print(f"Thumbnail error for {path}: {e}")
|
| 189 |
+
return ""
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
def encode_full_image(path):
|
| 193 |
+
if not os.path.exists(path):
|
| 194 |
+
return ""
|
| 195 |
+
try:
|
| 196 |
+
with open(path, "rb") as f:
|
| 197 |
+
data = f.read()
|
| 198 |
+
ext = path.rsplit(".", 1)[-1].lower()
|
| 199 |
+
mime = {"jpg": "image/jpeg", "jpeg": "image/jpeg", "png": "image/png", "webp": "image/webp"}.get(ext, "image/jpeg")
|
| 200 |
+
return f"data:{mime};base64,{base64.b64encode(data).decode()}"
|
| 201 |
+
except Exception as e:
|
| 202 |
+
print(f"Encode error for {path}: {e}")
|
| 203 |
+
return ""
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def build_client_config():
|
| 207 |
+
"""Static config consumed by the frontend: LoRA list + example cards."""
|
| 208 |
+
examples = []
|
| 209 |
+
for i, ex in enumerate(EXAMPLES_CONFIG):
|
| 210 |
+
examples.append({
|
| 211 |
+
"idx": i,
|
| 212 |
+
"thumbs": [make_thumb_b64(p) for p in ex["images"]],
|
| 213 |
+
"n_images": len(ex["images"]),
|
| 214 |
+
"lora": ex["lora"],
|
| 215 |
+
"prompt": ex["prompt"],
|
| 216 |
+
})
|
| 217 |
+
return {
|
| 218 |
+
"loras": ADAPTER_NAMES,
|
| 219 |
+
"default_lora": "Photo-to-Anime",
|
| 220 |
+
"examples": examples,
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
print("Building client config (example thumbnails)…")
|
| 225 |
+
CLIENT_CONFIG = build_client_config()
|
| 226 |
+
print(f"Built config with {len(EXAMPLES_CONFIG)} examples and {len(ADAPTER_NAMES)} LoRAs.")
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
def b64_to_pil_list(b64_json_str):
|
| 230 |
+
if not b64_json_str or b64_json_str.strip() in ("", "[]"):
|
| 231 |
+
return []
|
| 232 |
+
try:
|
| 233 |
+
b64_list = json.loads(b64_json_str)
|
| 234 |
+
except Exception:
|
| 235 |
+
return []
|
| 236 |
+
pil_images = []
|
| 237 |
+
for b64_str in b64_list:
|
| 238 |
+
if not b64_str or not isinstance(b64_str, str):
|
| 239 |
+
continue
|
| 240 |
+
try:
|
| 241 |
+
if b64_str.startswith("data:image"):
|
| 242 |
+
_, data = b64_str.split(",", 1)
|
| 243 |
+
else:
|
| 244 |
+
data = b64_str
|
| 245 |
+
image_data = base64.b64decode(data)
|
| 246 |
+
pil_images.append(Image.open(BytesIO(image_data)).convert("RGB"))
|
| 247 |
+
except Exception as e:
|
| 248 |
+
print(f"Error decoding image: {e}")
|
| 249 |
+
return pil_images
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def pil_to_b64_png(image: Image.Image) -> str:
|
| 253 |
+
buf = BytesIO()
|
| 254 |
+
image.save(buf, format="PNG")
|
| 255 |
+
return f"data:image/png;base64,{base64.b64encode(buf.getvalue()).decode()}"
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def update_dimensions_on_upload(image):
|
| 259 |
+
if image is None:
|
| 260 |
+
return 1024, 1024
|
| 261 |
+
w, h = image.size
|
| 262 |
+
if w > h:
|
| 263 |
+
nw = 1024
|
| 264 |
+
nh = int(nw * h / w)
|
| 265 |
+
else:
|
| 266 |
+
nh = 1024
|
| 267 |
+
nw = int(nh * w / h)
|
| 268 |
+
return (nw // 8) * 8, (nh // 8) * 8
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
# ── Gradio Server (Server mode): FastAPI + Gradio queue/API engine ────────────
|
| 272 |
+
app = Server(title="Qwen-Image-Edit-2511-LoRAs-Fast")
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
@app.mcp.tool(name="edit_image")
|
| 276 |
+
@app.api(name="edit_image")
|
| 277 |
+
@spaces.GPU(size="xlarge")
|
| 278 |
+
def infer(
|
| 279 |
+
images_b64_json: str,
|
| 280 |
+
prompt: str,
|
| 281 |
+
lora_adapter: str,
|
| 282 |
+
seed: int,
|
| 283 |
+
randomize_seed: bool,
|
| 284 |
+
guidance_scale: float,
|
| 285 |
+
steps: int,
|
| 286 |
+
) -> dict:
|
| 287 |
+
"""Edit one or more images with Qwen-Image-Edit-2511 + a lazily-loaded LoRA.
|
| 288 |
+
|
| 289 |
+
Returns {"image": <base64 PNG data URL>, "seed": <seed used>}.
|
| 290 |
+
"""
|
| 291 |
+
gc.collect()
|
| 292 |
+
torch.cuda.empty_cache()
|
| 293 |
+
|
| 294 |
+
pil_images = b64_to_pil_list(images_b64_json)
|
| 295 |
+
if not pil_images:
|
| 296 |
+
raise gr.Error("Please upload at least one image to edit.")
|
| 297 |
+
if not prompt or prompt.strip() == "":
|
| 298 |
+
raise gr.Error("Please enter an edit prompt.")
|
| 299 |
+
|
| 300 |
+
spec = ADAPTER_SPECS.get(lora_adapter)
|
| 301 |
+
if not spec:
|
| 302 |
+
raise gr.Error(f"Configuration not found for: {lora_adapter}")
|
| 303 |
+
|
| 304 |
+
adapter_name = spec["adapter_name"]
|
| 305 |
+
if adapter_name not in LOADED_ADAPTERS:
|
| 306 |
+
print(f"--- Downloading and Loading Adapter: {lora_adapter} ---")
|
| 307 |
+
try:
|
| 308 |
+
pipe.load_lora_weights(spec["repo"], weight_name=spec["weights"], adapter_name=adapter_name)
|
| 309 |
+
LOADED_ADAPTERS.add(adapter_name)
|
| 310 |
+
except Exception as e:
|
| 311 |
+
raise gr.Error(f"Failed to load adapter {lora_adapter}: {e}")
|
| 312 |
+
else:
|
| 313 |
+
print(f"--- Adapter {lora_adapter} already loaded. ---")
|
| 314 |
+
|
| 315 |
+
pipe.set_adapters([adapter_name], adapter_weights=[1.0])
|
| 316 |
+
|
| 317 |
+
if randomize_seed:
|
| 318 |
+
seed = random.randint(0, MAX_SEED)
|
| 319 |
+
|
| 320 |
+
generator = torch.Generator(device=device).manual_seed(seed)
|
| 321 |
+
negative_prompt = (
|
| 322 |
+
"worst quality, low quality, bad anatomy, bad hands, text, error, missing fingers, "
|
| 323 |
+
"extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, blurry"
|
| 324 |
+
)
|
| 325 |
+
width, height = update_dimensions_on_upload(pil_images[0])
|
| 326 |
+
|
| 327 |
+
try:
|
| 328 |
+
result_image = pipe(
|
| 329 |
+
image=pil_images,
|
| 330 |
+
prompt=prompt,
|
| 331 |
+
negative_prompt=negative_prompt,
|
| 332 |
+
height=height,
|
| 333 |
+
width=width,
|
| 334 |
+
num_inference_steps=steps,
|
| 335 |
+
generator=generator,
|
| 336 |
+
true_cfg_scale=guidance_scale,
|
| 337 |
+
).images[0]
|
| 338 |
+
return {"image": pil_to_b64_png(result_image), "seed": seed}
|
| 339 |
+
except Exception as e:
|
| 340 |
+
raise e
|
| 341 |
+
finally:
|
| 342 |
+
gc.collect()
|
| 343 |
+
torch.cuda.empty_cache()
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
@app.api(name="load_example", queue=False)
|
| 347 |
+
def load_example(idx: float) -> dict:
|
| 348 |
+
"""Return base64-encoded example images + prompt + LoRA for a given example index."""
|
| 349 |
+
try:
|
| 350 |
+
i = int(idx)
|
| 351 |
+
except (ValueError, TypeError):
|
| 352 |
+
i = -1
|
| 353 |
+
if i < 0 or i >= len(EXAMPLES_CONFIG):
|
| 354 |
+
return {"images": [], "prompt": "", "lora": "", "names": [], "status": "error"}
|
| 355 |
+
ex = EXAMPLES_CONFIG[i]
|
| 356 |
+
b64_list, names = [], []
|
| 357 |
+
for path in ex["images"]:
|
| 358 |
+
b64 = encode_full_image(path)
|
| 359 |
+
if b64:
|
| 360 |
+
b64_list.append(b64)
|
| 361 |
+
names.append(os.path.basename(path))
|
| 362 |
+
return {"images": b64_list, "prompt": ex["prompt"], "lora": ex["lora"], "names": names, "status": "ok"}
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
@app.get("/api/config")
|
| 366 |
+
def client_config():
|
| 367 |
+
"""Plain FastAPI route: LoRA choices + example card data for the frontend."""
|
| 368 |
+
return CLIENT_CONFIG
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
@app.get("/", response_class=HTMLResponse)
|
| 372 |
+
async def homepage():
|
| 373 |
+
html_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "index.html")
|
| 374 |
+
with open(html_path, "r", encoding="utf-8") as f:
|
| 375 |
+
return f.read()
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
if __name__ == "__main__":
|
| 379 |
+
app.launch(show_error=True, mcp_server=True)
|
index.html
ADDED
|
@@ -0,0 +1,1358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Qwen Studio · Qwen-Image-Edit 2511</title>
|
| 7 |
+
<style>
|
| 8 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
|
| 9 |
+
*{box-sizing:border-box;margin:0;padding:0}
|
| 10 |
+
:root{
|
| 11 |
+
--bg:#0a0a0c;--panel:#131316;--panel2:#0e0e11;--canvas:#08080a;
|
| 12 |
+
--border:#232328;--border2:#33333a;
|
| 13 |
+
--text:#e4e4e7;--muted:#a1a1aa;--dim:#6b6b75;--faint:#4a4a52;
|
| 14 |
+
--accent:#1E90FF;--accent2:#47A3FF;--accent3:#7CB8FF;
|
| 15 |
+
--menubar-h:48px;--statusbar-h:30px;--rail-w:52px;--inspector-w:360px;--filmstrip-h:132px;
|
| 16 |
+
}
|
| 17 |
+
html,body{height:100%}
|
| 18 |
+
body{
|
| 19 |
+
background:var(--bg);font-family:'Inter',system-ui,-apple-system,sans-serif;
|
| 20 |
+
font-size:13px;color:var(--text);overflow:hidden;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/* ══ Layout grid ══ */
|
| 24 |
+
.studio{
|
| 25 |
+
display:grid;height:100vh;
|
| 26 |
+
grid-template-rows:var(--menubar-h) 1fr var(--statusbar-h);
|
| 27 |
+
grid-template-columns:var(--rail-w) 1fr var(--inspector-w);
|
| 28 |
+
grid-template-areas:
|
| 29 |
+
"menubar menubar menubar"
|
| 30 |
+
"rail workspace inspector"
|
| 31 |
+
"statusbar statusbar statusbar";
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/* ══ Menu bar ══ */
|
| 35 |
+
.menubar{
|
| 36 |
+
grid-area:menubar;display:flex;align-items:center;gap:14px;
|
| 37 |
+
background:var(--panel);border-bottom:1px solid var(--border);
|
| 38 |
+
padding:0 16px;z-index:50;
|
| 39 |
+
}
|
| 40 |
+
.menubar-logo{
|
| 41 |
+
width:28px;height:28px;background:linear-gradient(135deg,#1E90FF,#47A3FF,#7CB8FF);
|
| 42 |
+
border-radius:8px;display:flex;align-items:center;justify-content:center;
|
| 43 |
+
box-shadow:0 2px 8px rgba(30,144,255,.35);flex-shrink:0;
|
| 44 |
+
}
|
| 45 |
+
.menubar-logo svg{width:15px;height:15px;fill:#fff}
|
| 46 |
+
.menubar-title{font-size:14px;font-weight:700;letter-spacing:-.2px;white-space:nowrap}
|
| 47 |
+
.menubar-title span{color:var(--dim);font-weight:500}
|
| 48 |
+
.menubar-badge{
|
| 49 |
+
font-size:10px;font-weight:700;padding:2px 8px;border-radius:12px;
|
| 50 |
+
background:rgba(30,144,255,.14);color:var(--accent2);border:1px solid rgba(30,144,255,.25);
|
| 51 |
+
letter-spacing:.4px;white-space:nowrap;
|
| 52 |
+
}
|
| 53 |
+
.menubar-badge.fast{background:rgba(34,197,94,.12);color:#4ade80;border-color:rgba(34,197,94,.25)}
|
| 54 |
+
.menubar-spacer{flex:1}
|
| 55 |
+
.menubar-status{
|
| 56 |
+
display:flex;align-items:center;gap:7px;font-family:'JetBrains Mono',monospace;
|
| 57 |
+
font-size:11px;color:var(--dim);
|
| 58 |
+
}
|
| 59 |
+
.menubar-status .dot{width:7px;height:7px;border-radius:50%;background:#4ade80;box-shadow:0 0 6px rgba(74,222,128,.6)}
|
| 60 |
+
.menubar-status .dot.off{background:#f87171;box-shadow:0 0 6px rgba(248,113,113,.5)}
|
| 61 |
+
.gh-btn{
|
| 62 |
+
display:inline-flex;align-items:center;gap:6px;
|
| 63 |
+
padding:5px 13px;border-radius:7px;text-decoration:none;
|
| 64 |
+
font-size:12px;font-weight:600;background:var(--accent);color:#fff;
|
| 65 |
+
border:1px solid rgba(255,255,255,.15);
|
| 66 |
+
transition:all .15s ease;flex-shrink:0;
|
| 67 |
+
}
|
| 68 |
+
.gh-btn:hover{background:var(--accent2)}
|
| 69 |
+
.gh-btn svg{fill:#fff;width:13px;height:13px}
|
| 70 |
+
|
| 71 |
+
/* ══ Left icon rail ══ */
|
| 72 |
+
.rail{
|
| 73 |
+
grid-area:rail;background:var(--panel);border-right:1px solid var(--border);
|
| 74 |
+
display:flex;flex-direction:column;align-items:center;padding:10px 0;gap:4px;
|
| 75 |
+
overflow-y:auto;z-index:40;
|
| 76 |
+
}
|
| 77 |
+
.rail-btn{
|
| 78 |
+
width:38px;height:38px;border-radius:9px;border:1px solid transparent;
|
| 79 |
+
background:transparent;color:var(--dim);cursor:pointer;
|
| 80 |
+
display:flex;align-items:center;justify-content:center;
|
| 81 |
+
transition:all .15s ease;position:relative;
|
| 82 |
+
}
|
| 83 |
+
.rail-btn:hover:not(:disabled){background:rgba(30,144,255,.12);color:var(--accent3);border-color:rgba(30,144,255,.25)}
|
| 84 |
+
.rail-btn.active{background:rgba(30,144,255,.2);color:var(--accent2);border-color:rgba(30,144,255,.4)}
|
| 85 |
+
.rail-btn:disabled{opacity:.3;cursor:not-allowed}
|
| 86 |
+
.rail-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
| 87 |
+
.rail-btn svg.fill{fill:currentColor;stroke:none}
|
| 88 |
+
.rail-sep{width:24px;height:1px;background:var(--border);margin:6px 0}
|
| 89 |
+
.rail-label{
|
| 90 |
+
font-size:8px;font-weight:700;color:var(--faint);letter-spacing:1px;
|
| 91 |
+
text-transform:uppercase;margin:8px 0 2px;user-select:none;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/* ══ Workspace (canvas + filmstrip) ══ */
|
| 95 |
+
.workspace{
|
| 96 |
+
grid-area:workspace;display:flex;flex-direction:column;min-width:0;min-height:0;
|
| 97 |
+
background:var(--canvas);
|
| 98 |
+
}
|
| 99 |
+
.canvas-head{
|
| 100 |
+
display:flex;align-items:center;gap:10px;padding:8px 16px;
|
| 101 |
+
border-bottom:1px solid var(--border);background:var(--panel2);flex-shrink:0;
|
| 102 |
+
}
|
| 103 |
+
.seg-control{
|
| 104 |
+
display:inline-flex;background:var(--panel);border:1px solid var(--border);
|
| 105 |
+
border-radius:8px;padding:2px;gap:2px;
|
| 106 |
+
}
|
| 107 |
+
.seg-btn{
|
| 108 |
+
padding:4px 14px;font-size:11px;font-weight:600;color:var(--dim);
|
| 109 |
+
background:transparent;border:none;border-radius:6px;cursor:pointer;
|
| 110 |
+
font-family:'Inter',sans-serif;transition:all .15s;letter-spacing:.2px;
|
| 111 |
+
}
|
| 112 |
+
.seg-btn:hover:not(.active){color:var(--muted)}
|
| 113 |
+
.seg-btn.active{background:rgba(30,144,255,.18);color:var(--accent2)}
|
| 114 |
+
.canvas-meta{
|
| 115 |
+
font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--faint);
|
| 116 |
+
overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;
|
| 117 |
+
}
|
| 118 |
+
.canvas-actions{display:flex;align-items:center;gap:6px}
|
| 119 |
+
.canvas-action-btn{
|
| 120 |
+
display:none;align-items:center;gap:5px;background:rgba(30,144,255,.1);
|
| 121 |
+
border:1px solid rgba(30,144,255,.2);border-radius:6px;cursor:pointer;padding:4px 11px;
|
| 122 |
+
font-size:11px;font-weight:500;color:var(--accent3);height:26px;transition:all .15s;
|
| 123 |
+
font-family:'Inter',sans-serif;white-space:nowrap;
|
| 124 |
+
}
|
| 125 |
+
.canvas-action-btn:hover{background:rgba(30,144,255,.2);border-color:rgba(30,144,255,.35);color:#fff}
|
| 126 |
+
.canvas-action-btn.visible{display:inline-flex}
|
| 127 |
+
.canvas-action-btn.active{background:rgba(30,144,255,.3);border-color:var(--accent);color:#fff}
|
| 128 |
+
.canvas-action-btn svg{width:12px;height:12px;fill:currentColor}
|
| 129 |
+
.out-seed-chip{
|
| 130 |
+
display:none;font-family:'JetBrains Mono',monospace;font-size:10px;font-weight:500;
|
| 131 |
+
color:var(--dim);background:var(--panel);border:1px solid var(--border);
|
| 132 |
+
border-radius:6px;padding:4px 9px;cursor:pointer;transition:all .15s;
|
| 133 |
+
}
|
| 134 |
+
.out-seed-chip.visible{display:inline-flex}
|
| 135 |
+
.out-seed-chip:hover{color:var(--accent3);border-color:rgba(30,144,255,.35)}
|
| 136 |
+
|
| 137 |
+
.canvas-stage{
|
| 138 |
+
flex:1;position:relative;overflow:hidden;min-height:0;
|
| 139 |
+
display:flex;align-items:center;justify-content:center;
|
| 140 |
+
background:
|
| 141 |
+
repeating-conic-gradient(#0c0c0f 0% 25%, #08080a 0% 50%) 0 0/24px 24px;
|
| 142 |
+
}
|
| 143 |
+
.canvas-stage img.modern-out-img{
|
| 144 |
+
max-width:calc(100% - 48px);max-height:calc(100% - 48px);
|
| 145 |
+
box-shadow:0 12px 48px rgba(0,0,0,.7),0 0 0 1px var(--border);
|
| 146 |
+
border-radius:4px;cursor:zoom-in;image-rendering:auto;
|
| 147 |
+
animation:canvasIn .3s ease;
|
| 148 |
+
}
|
| 149 |
+
@keyframes canvasIn{from{opacity:0;transform:scale(.985)}to{opacity:1;transform:scale(1)}}
|
| 150 |
+
.canvas-placeholder{
|
| 151 |
+
text-align:center;color:var(--faint);user-select:none;
|
| 152 |
+
display:flex;flex-direction:column;align-items:center;gap:14px;padding:24px;
|
| 153 |
+
}
|
| 154 |
+
.canvas-placeholder svg{width:72px;height:72px;opacity:.5}
|
| 155 |
+
.canvas-placeholder .cp-title{font-size:15px;font-weight:600;color:var(--dim)}
|
| 156 |
+
.canvas-placeholder .cp-sub{font-size:12px;line-height:1.7;max-width:340px}
|
| 157 |
+
.canvas-placeholder kbd{
|
| 158 |
+
padding:1px 6px;background:var(--panel);border:1px solid var(--border2);
|
| 159 |
+
border-radius:4px;font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--muted);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/* Compare slider */
|
| 163 |
+
.compare-wrap{
|
| 164 |
+
position:relative;max-width:calc(100% - 48px);max-height:calc(100% - 48px);overflow:hidden;
|
| 165 |
+
display:none;user-select:none;touch-action:none;cursor:ew-resize;
|
| 166 |
+
box-shadow:0 12px 48px rgba(0,0,0,.7),0 0 0 1px var(--border);border-radius:4px;
|
| 167 |
+
}
|
| 168 |
+
.compare-wrap.visible{display:block}
|
| 169 |
+
.compare-wrap img{display:block;max-width:100%;max-height:100%;pointer-events:none}
|
| 170 |
+
.compare-top{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden}
|
| 171 |
+
.compare-top img{position:absolute;top:0;left:0;height:100%;width:auto;max-width:none!important;max-height:none!important}
|
| 172 |
+
.compare-divider{position:absolute;top:0;bottom:0;width:2px;background:#fff;box-shadow:0 0 8px rgba(0,0,0,.6);pointer-events:none}
|
| 173 |
+
.compare-handle{
|
| 174 |
+
position:absolute;top:50%;transform:translate(-50%,-50%);
|
| 175 |
+
width:32px;height:32px;border-radius:50%;background:#fff;
|
| 176 |
+
display:flex;align-items:center;justify-content:center;
|
| 177 |
+
box-shadow:0 2px 8px rgba(0,0,0,.5);color:#111;font-size:13px;font-weight:800;
|
| 178 |
+
}
|
| 179 |
+
.compare-label{
|
| 180 |
+
position:absolute;top:8px;padding:2px 8px;border-radius:4px;
|
| 181 |
+
background:rgba(0,0,0,.65);color:#fff;font-size:10px;font-weight:600;
|
| 182 |
+
font-family:'JetBrains Mono',monospace;pointer-events:none;
|
| 183 |
+
}
|
| 184 |
+
.compare-label.before{left:8px}
|
| 185 |
+
.compare-label.after{right:8px}
|
| 186 |
+
|
| 187 |
+
/* Loader */
|
| 188 |
+
.modern-loader{
|
| 189 |
+
display:none;position:absolute;inset:0;background:rgba(8,8,10,.9);
|
| 190 |
+
z-index:15;flex-direction:column;align-items:center;justify-content:center;gap:16px;backdrop-filter:blur(5px);
|
| 191 |
+
}
|
| 192 |
+
.modern-loader.active{display:flex}
|
| 193 |
+
.loader-spinner{
|
| 194 |
+
width:38px;height:38px;border:3px solid var(--border);border-top-color:var(--accent);
|
| 195 |
+
border-radius:50%;animation:spin .8s linear infinite;
|
| 196 |
+
}
|
| 197 |
+
@keyframes spin{to{transform:rotate(360deg)}}
|
| 198 |
+
.loader-text{font-size:13px;color:var(--muted);font-weight:500;text-align:center;padding:0 16px}
|
| 199 |
+
.loader-bar-track{width:220px;height:4px;background:var(--border);border-radius:2px;overflow:hidden}
|
| 200 |
+
.loader-bar-fill{
|
| 201 |
+
height:100%;width:100%;background:linear-gradient(90deg,#1E90FF,#47A3FF,#1E90FF);
|
| 202 |
+
background-size:200% 100%;animation:shimmer 1.5s ease-in-out infinite;border-radius:2px;
|
| 203 |
+
transition:width .3s ease;
|
| 204 |
+
}
|
| 205 |
+
.loader-bar-fill.determinate{animation:none;background:var(--accent)}
|
| 206 |
+
@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
| 207 |
+
|
| 208 |
+
/* ══ Filmstrip ══ */
|
| 209 |
+
.filmstrip{
|
| 210 |
+
height:var(--filmstrip-h);flex-shrink:0;background:var(--panel);
|
| 211 |
+
border-top:1px solid var(--border);display:flex;min-height:0;overflow:hidden;
|
| 212 |
+
}
|
| 213 |
+
.filmstrip-section{
|
| 214 |
+
display:flex;flex-direction:column;min-width:0;padding:8px 0 8px 14px;
|
| 215 |
+
}
|
| 216 |
+
.filmstrip-section.inputs{flex:1.2;border-right:1px solid var(--border)}
|
| 217 |
+
.filmstrip-section.history{flex:1}
|
| 218 |
+
.filmstrip-label{
|
| 219 |
+
font-size:9px;font-weight:700;color:var(--faint);letter-spacing:1.2px;
|
| 220 |
+
text-transform:uppercase;margin-bottom:6px;display:flex;align-items:center;gap:8px;
|
| 221 |
+
user-select:none;flex-shrink:0;
|
| 222 |
+
}
|
| 223 |
+
.filmstrip-label .count{
|
| 224 |
+
font-family:'JetBrains Mono',monospace;font-weight:500;color:var(--dim);
|
| 225 |
+
background:var(--panel2);border:1px solid var(--border);border-radius:4px;padding:0 5px;font-size:9px;
|
| 226 |
+
}
|
| 227 |
+
.filmstrip-row{
|
| 228 |
+
display:flex;gap:8px;overflow-x:auto;overflow-y:hidden;flex:1;
|
| 229 |
+
align-items:flex-start;padding-bottom:4px;padding-right:14px;
|
| 230 |
+
}
|
| 231 |
+
.filmstrip-row::-webkit-scrollbar{height:5px}
|
| 232 |
+
.filmstrip-row::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
|
| 233 |
+
.fs-thumb{
|
| 234 |
+
position:relative;flex-shrink:0;width:76px;height:76px;border-radius:8px;overflow:hidden;
|
| 235 |
+
border:2px solid var(--border);cursor:pointer;transition:all .15s;background:var(--panel2);
|
| 236 |
+
animation:thumbIn .25s ease;
|
| 237 |
+
}
|
| 238 |
+
@keyframes thumbIn{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:scale(1)}}
|
| 239 |
+
.fs-thumb:hover{border-color:var(--border2);transform:translateY(-2px)}
|
| 240 |
+
.fs-thumb.selected{border-color:var(--accent);box-shadow:0 0 0 2px rgba(30,144,255,.25)}
|
| 241 |
+
.fs-thumb img{width:100%;height:100%;object-fit:cover}
|
| 242 |
+
.fs-badge{
|
| 243 |
+
position:absolute;bottom:4px;left:4px;background:rgba(0,0,0,.75);color:#fff;
|
| 244 |
+
padding:1px 6px;border-radius:4px;font-family:'JetBrains Mono',monospace;font-size:9px;font-weight:600;
|
| 245 |
+
}
|
| 246 |
+
.fs-remove{
|
| 247 |
+
position:absolute;top:4px;right:4px;width:20px;height:20px;background:rgba(0,0,0,.8);
|
| 248 |
+
color:#fff;border:1px solid rgba(255,255,255,.2);border-radius:50%;cursor:pointer;
|
| 249 |
+
display:none;align-items:center;justify-content:center;font-size:10px;transition:all .15s;line-height:1;
|
| 250 |
+
}
|
| 251 |
+
.fs-thumb:hover .fs-remove{display:flex}
|
| 252 |
+
.fs-remove:hover{background:#ef4444;border-color:#ef4444}
|
| 253 |
+
.fs-add{
|
| 254 |
+
flex-shrink:0;width:76px;height:76px;border-radius:8px;border:2px dashed var(--border2);
|
| 255 |
+
display:flex;flex-direction:column;align-items:center;justify-content:center;
|
| 256 |
+
cursor:pointer;transition:all .2s;background:rgba(30,144,255,.03);gap:3px;
|
| 257 |
+
}
|
| 258 |
+
.fs-add:hover{border-color:var(--accent);background:rgba(30,144,255,.08)}
|
| 259 |
+
.fs-add .add-icon{font-size:22px;color:var(--dim);font-weight:300}
|
| 260 |
+
.fs-add .add-text{font-size:9px;color:var(--dim);font-weight:600;text-transform:uppercase;letter-spacing:.5px}
|
| 261 |
+
.fs-empty{
|
| 262 |
+
flex-shrink:0;display:flex;align-items:center;height:76px;
|
| 263 |
+
color:var(--faint);font-size:11px;font-style:italic;padding-right:12px;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
/* ══ Inspector (right panel) ══ */
|
| 267 |
+
.inspector{
|
| 268 |
+
grid-area:inspector;background:var(--panel);border-left:1px solid var(--border);
|
| 269 |
+
display:flex;flex-direction:column;min-height:0;z-index:40;
|
| 270 |
+
}
|
| 271 |
+
.inspector-tabs{
|
| 272 |
+
display:flex;border-bottom:1px solid var(--border);flex-shrink:0;
|
| 273 |
+
}
|
| 274 |
+
.insp-tab{
|
| 275 |
+
flex:1;padding:11px 8px;font-size:11px;font-weight:700;color:var(--dim);
|
| 276 |
+
background:transparent;border:none;border-bottom:2px solid transparent;
|
| 277 |
+
cursor:pointer;font-family:'Inter',sans-serif;text-transform:uppercase;letter-spacing:.8px;
|
| 278 |
+
transition:all .15s;
|
| 279 |
+
}
|
| 280 |
+
.insp-tab:hover:not(.active){color:var(--muted)}
|
| 281 |
+
.insp-tab.active{color:var(--accent2);border-bottom-color:var(--accent)}
|
| 282 |
+
.insp-page{display:none;flex:1;overflow-y:auto;min-height:0;flex-direction:column}
|
| 283 |
+
.insp-page.active{display:flex}
|
| 284 |
+
|
| 285 |
+
.insp-section{border-bottom:1px solid var(--border);padding:14px 18px}
|
| 286 |
+
.insp-section-title{
|
| 287 |
+
font-size:10px;font-weight:700;color:var(--dim);text-transform:uppercase;
|
| 288 |
+
letter-spacing:1px;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;
|
| 289 |
+
}
|
| 290 |
+
.char-count{font-size:9px;font-weight:500;color:var(--faint);font-family:'JetBrains Mono',monospace;text-transform:none;letter-spacing:0}
|
| 291 |
+
.modern-textarea{
|
| 292 |
+
width:100%;background:var(--panel2);border:1px solid var(--border);border-radius:8px;
|
| 293 |
+
padding:10px 13px;font-family:'Inter',sans-serif;font-size:13px;color:var(--text);
|
| 294 |
+
resize:vertical;outline:none;min-height:64px;transition:border-color .2s;line-height:1.55;
|
| 295 |
+
}
|
| 296 |
+
.modern-textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(30,144,255,.15)}
|
| 297 |
+
.modern-textarea::placeholder{color:var(--faint)}
|
| 298 |
+
.modern-textarea.error-flash{
|
| 299 |
+
border-color:#ef4444!important;box-shadow:0 0 0 3px rgba(239,68,68,.2)!important;animation:shake .4s ease;
|
| 300 |
+
}
|
| 301 |
+
@keyframes shake{0%,100%{transform:translateX(0)}20%,60%{transform:translateX(-4px)}40%,80%{transform:translateX(4px)}}
|
| 302 |
+
|
| 303 |
+
.suggestions-wrap{display:flex;flex-wrap:wrap;gap:5px}
|
| 304 |
+
.suggestion-chip{
|
| 305 |
+
display:inline-flex;align-items:center;padding:4px 11px;
|
| 306 |
+
background:rgba(30,144,255,.07);border:1px solid rgba(30,144,255,.18);border-radius:14px;
|
| 307 |
+
color:var(--accent3);font-size:11px;font-weight:500;font-family:'Inter',sans-serif;
|
| 308 |
+
cursor:pointer;transition:all .15s;white-space:nowrap;
|
| 309 |
+
}
|
| 310 |
+
.suggestion-chip:hover{background:rgba(30,144,255,.15);border-color:rgba(30,144,255,.35);color:var(--accent2)}
|
| 311 |
+
.suggestion-chip.active{background:rgba(30,144,255,.25);border-color:var(--accent);color:#fff}
|
| 312 |
+
|
| 313 |
+
.lora-native-select{
|
| 314 |
+
width:100%;background:var(--panel2);
|
| 315 |
+
border:1px solid var(--border2);border-radius:8px;
|
| 316 |
+
padding:9px 34px 9px 13px;
|
| 317 |
+
font-family:'Inter',sans-serif;font-size:12px;font-weight:600;color:var(--text);
|
| 318 |
+
outline:none;appearance:none;-webkit-appearance:none;
|
| 319 |
+
background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231E90FF' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
|
| 320 |
+
background-repeat:no-repeat;background-position:right 11px center;
|
| 321 |
+
cursor:pointer;transition:border-color .2s;color-scheme:dark;
|
| 322 |
+
}
|
| 323 |
+
.lora-native-select:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(30,144,255,.15)}
|
| 324 |
+
.lora-native-select option{background:var(--panel);color:var(--text)}
|
| 325 |
+
|
| 326 |
+
.btn-run{
|
| 327 |
+
display:flex;align-items:center;justify-content:center;gap:8px;width:100%;
|
| 328 |
+
background:linear-gradient(135deg,#1E90FF,#1873CC);border:none;border-radius:9px;
|
| 329 |
+
padding:12px 24px;cursor:pointer;font-size:14px;font-weight:700;font-family:'Inter',sans-serif;
|
| 330 |
+
color:#fff;transition:all .2s ease;letter-spacing:-.2px;
|
| 331 |
+
box-shadow:0 4px 16px rgba(30,144,255,.3),inset 0 1px 0 rgba(255,255,255,.1);
|
| 332 |
+
}
|
| 333 |
+
.btn-run:hover:not(:disabled){
|
| 334 |
+
background:linear-gradient(135deg,#47A3FF,#1E90FF);transform:translateY(-1px);
|
| 335 |
+
box-shadow:0 6px 24px rgba(30,144,255,.45),inset 0 1px 0 rgba(255,255,255,.15);
|
| 336 |
+
}
|
| 337 |
+
.btn-run:active:not(:disabled){transform:translateY(0)}
|
| 338 |
+
.btn-run:disabled{opacity:.55;cursor:not-allowed}
|
| 339 |
+
.btn-run svg{width:16px;height:16px;fill:#fff}
|
| 340 |
+
.btn-cancel{
|
| 341 |
+
display:flex;align-items:center;justify-content:center;gap:6px;width:100%;
|
| 342 |
+
margin-top:8px;background:transparent;border:1px solid var(--border2);border-radius:9px;
|
| 343 |
+
padding:8px 24px;cursor:pointer;font-size:12px;font-weight:600;font-family:'Inter',sans-serif;
|
| 344 |
+
color:var(--muted);transition:all .15s;
|
| 345 |
+
}
|
| 346 |
+
.btn-cancel:hover{border-color:#ef4444;color:#ef4444;background:rgba(239,68,68,.08)}
|
| 347 |
+
.run-hint{
|
| 348 |
+
text-align:center;font-size:10px;color:var(--faint);margin-top:8px;
|
| 349 |
+
font-family:'JetBrains Mono',monospace;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
.slider-row{display:flex;align-items:center;gap:9px;min-height:26px;margin-bottom:10px}
|
| 353 |
+
.slider-row:last-child{margin-bottom:0}
|
| 354 |
+
.slider-row label{font-size:12px;font-weight:500;color:var(--muted);min-width:64px;flex-shrink:0}
|
| 355 |
+
.slider-row input[type="range"]{
|
| 356 |
+
flex:1;-webkit-appearance:none;appearance:none;height:5px;background:var(--border);
|
| 357 |
+
border-radius:3px;outline:none;min-width:0;
|
| 358 |
+
}
|
| 359 |
+
.slider-row input[type="range"]::-webkit-slider-thumb{
|
| 360 |
+
-webkit-appearance:none;width:14px;height:14px;background:linear-gradient(135deg,#1E90FF,#1873CC);
|
| 361 |
+
border-radius:50%;cursor:pointer;box-shadow:0 2px 6px rgba(30,144,255,.4);transition:transform .15s;
|
| 362 |
+
}
|
| 363 |
+
.slider-row input[type="range"]::-webkit-slider-thumb:hover{transform:scale(1.2)}
|
| 364 |
+
.slider-row input[type="range"]::-moz-range-thumb{
|
| 365 |
+
width:14px;height:14px;background:linear-gradient(135deg,#1E90FF,#1873CC);
|
| 366 |
+
border-radius:50%;cursor:pointer;border:none;box-shadow:0 2px 6px rgba(30,144,255,.4);
|
| 367 |
+
}
|
| 368 |
+
.slider-val{
|
| 369 |
+
min-width:48px;text-align:right;font-family:'JetBrains Mono',monospace;font-size:11px;
|
| 370 |
+
font-weight:500;padding:2px 7px;background:var(--panel2);border:1px solid var(--border);
|
| 371 |
+
border-radius:5px;color:var(--muted);flex-shrink:0;
|
| 372 |
+
}
|
| 373 |
+
.dice-btn{
|
| 374 |
+
display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;
|
| 375 |
+
background:var(--panel2);border:1px solid var(--border);border-radius:5px;cursor:pointer;
|
| 376 |
+
color:var(--dim);transition:all .15s;flex-shrink:0;padding:0;
|
| 377 |
+
}
|
| 378 |
+
.dice-btn:hover{border-color:var(--accent);color:var(--accent3)}
|
| 379 |
+
.dice-btn svg{width:13px;height:13px;fill:currentColor}
|
| 380 |
+
.checkbox-row{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted);margin-bottom:10px}
|
| 381 |
+
.checkbox-row input[type="checkbox"]{accent-color:var(--accent);width:15px;height:15px;cursor:pointer}
|
| 382 |
+
.checkbox-row label{color:var(--muted);font-size:12px;cursor:pointer}
|
| 383 |
+
|
| 384 |
+
/* Examples page */
|
| 385 |
+
.examples-list{padding:12px 14px;display:flex;flex-direction:column;gap:10px}
|
| 386 |
+
.example-card{
|
| 387 |
+
background:var(--panel2);border:1px solid var(--border);
|
| 388 |
+
border-radius:10px;overflow:hidden;cursor:pointer;transition:all .2s ease;flex-shrink:0;
|
| 389 |
+
}
|
| 390 |
+
.example-card:hover{border-color:var(--accent);box-shadow:0 4px 14px rgba(30,144,255,.15)}
|
| 391 |
+
.example-card.loading{opacity:.5;pointer-events:none}
|
| 392 |
+
.example-thumbs{display:flex;height:96px;overflow:hidden;background:var(--panel)}
|
| 393 |
+
.example-thumbs img{flex:1;object-fit:cover;min-width:0;border-bottom:1px solid var(--border)}
|
| 394 |
+
.example-thumb-placeholder{
|
| 395 |
+
flex:1;display:flex;align-items:center;justify-content:center;
|
| 396 |
+
background:var(--panel);color:var(--border2);font-size:10px;min-width:0;
|
| 397 |
+
}
|
| 398 |
+
.example-meta{padding:6px 10px 2px;display:flex;align-items:center;gap:5px;flex-wrap:wrap}
|
| 399 |
+
.example-badge{
|
| 400 |
+
display:inline-flex;padding:2px 7px;background:rgba(30,144,255,.1);border-radius:4px;
|
| 401 |
+
font-size:9px;font-weight:600;color:var(--accent2);font-family:'JetBrains Mono',monospace;white-space:nowrap;
|
| 402 |
+
}
|
| 403 |
+
.example-lora-badge{
|
| 404 |
+
display:inline-flex;padding:2px 7px;background:rgba(255,255,255,.05);border-radius:4px;
|
| 405 |
+
font-size:9px;font-weight:600;color:var(--muted);font-family:'JetBrains Mono',monospace;
|
| 406 |
+
white-space:nowrap;border:1px solid var(--border);max-width:150px;overflow:hidden;text-overflow:ellipsis;
|
| 407 |
+
}
|
| 408 |
+
.example-prompt-text{
|
| 409 |
+
padding:4px 10px 9px;font-size:11px;color:var(--muted);line-height:1.45;
|
| 410 |
+
display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
/* ══ Status bar ══ */
|
| 414 |
+
.statusbar{
|
| 415 |
+
grid-area:statusbar;background:var(--panel);border-top:1px solid var(--border);
|
| 416 |
+
display:flex;align-items:center;gap:4px;padding:0 14px;font-size:11px;z-index:50;
|
| 417 |
+
}
|
| 418 |
+
.statusbar .sb-section{
|
| 419 |
+
padding:0 10px;display:flex;align-items:center;font-family:'JetBrains Mono',monospace;
|
| 420 |
+
font-size:11px;color:var(--faint);overflow:hidden;white-space:nowrap;gap:6px;
|
| 421 |
+
}
|
| 422 |
+
.statusbar .sb-right{margin-left:auto;display:flex;align-items:center;gap:10px}
|
| 423 |
+
.sb-pill{
|
| 424 |
+
padding:2px 12px;border-radius:5px;font-weight:600;font-size:10px;
|
| 425 |
+
background:rgba(30,144,255,.1);color:var(--accent2);
|
| 426 |
+
}
|
| 427 |
+
.sb-pill.error{background:rgba(239,68,68,.12);color:#f87171}
|
| 428 |
+
.sb-pill.done{background:rgba(34,197,94,.12);color:#4ade80}
|
| 429 |
+
.sb-link{color:var(--faint);text-decoration:none;font-family:'JetBrains Mono',monospace;font-size:10px}
|
| 430 |
+
.sb-link:hover{color:var(--accent3)}
|
| 431 |
+
|
| 432 |
+
/* ══ Toast ══ */
|
| 433 |
+
.toast-notification{
|
| 434 |
+
position:fixed;top:60px;left:50%;transform:translateX(-50%) translateY(-140%);
|
| 435 |
+
z-index:9999;padding:10px 22px;border-radius:9px;font-family:'Inter',sans-serif;
|
| 436 |
+
font-size:13px;font-weight:600;display:flex;align-items:center;gap:8px;
|
| 437 |
+
box-shadow:0 8px 24px rgba(0,0,0,.5);
|
| 438 |
+
transition:transform .35s cubic-bezier(.34,1.56,.64,1),opacity .35s ease;opacity:0;pointer-events:none;
|
| 439 |
+
}
|
| 440 |
+
.toast-notification.visible{transform:translateX(-50%) translateY(0);opacity:1;pointer-events:auto}
|
| 441 |
+
.toast-notification.error{background:linear-gradient(135deg,#dc2626,#b91c1c);color:#fff;border:1px solid rgba(255,255,255,.15)}
|
| 442 |
+
.toast-notification.warning{background:linear-gradient(135deg,#d97706,#b45309);color:#fff;border:1px solid rgba(255,255,255,.15)}
|
| 443 |
+
.toast-notification.info{background:linear-gradient(135deg,#2563eb,#1d4ed8);color:#fff;border:1px solid rgba(255,255,255,.15)}
|
| 444 |
+
.toast-notification .toast-icon{font-size:15px;line-height:1}
|
| 445 |
+
|
| 446 |
+
/* ══ Lightbox ══ */
|
| 447 |
+
.lightbox{
|
| 448 |
+
position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:10000;
|
| 449 |
+
display:none;align-items:center;justify-content:center;cursor:zoom-out;
|
| 450 |
+
backdrop-filter:blur(6px);animation:fadeIn .2s ease;
|
| 451 |
+
}
|
| 452 |
+
.lightbox.visible{display:flex}
|
| 453 |
+
.lightbox img{max-width:94vw;max-height:94vh;border-radius:6px;box-shadow:0 20px 60px rgba(0,0,0,.8)}
|
| 454 |
+
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
|
| 455 |
+
|
| 456 |
+
/* ══ Drop overlay ══ */
|
| 457 |
+
.drop-overlay{
|
| 458 |
+
position:fixed;inset:0;z-index:9000;background:rgba(8,8,10,.85);
|
| 459 |
+
display:none;align-items:center;justify-content:center;pointer-events:none;
|
| 460 |
+
backdrop-filter:blur(3px);
|
| 461 |
+
}
|
| 462 |
+
.drop-overlay.visible{display:flex}
|
| 463 |
+
.drop-overlay-inner{
|
| 464 |
+
border:3px dashed var(--accent);border-radius:22px;padding:56px 76px;
|
| 465 |
+
font-size:19px;font-weight:700;color:var(--accent2);background:rgba(30,144,255,.06);
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/* ══ Scrollbars ══ */
|
| 469 |
+
::-webkit-scrollbar{width:8px;height:8px}
|
| 470 |
+
::-webkit-scrollbar-track{background:transparent}
|
| 471 |
+
::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}
|
| 472 |
+
::-webkit-scrollbar-thumb:hover{background:var(--border2)}
|
| 473 |
+
|
| 474 |
+
/* ══ Responsive ══ */
|
| 475 |
+
@media(max-width:960px){
|
| 476 |
+
body{overflow:auto}
|
| 477 |
+
.studio{
|
| 478 |
+
height:auto;min-height:100vh;
|
| 479 |
+
grid-template-rows:var(--menubar-h) auto auto auto var(--statusbar-h);
|
| 480 |
+
grid-template-columns:1fr;
|
| 481 |
+
grid-template-areas:"menubar" "rail" "workspace" "inspector" "statusbar";
|
| 482 |
+
}
|
| 483 |
+
.rail{flex-direction:row;justify-content:center;border-right:none;border-bottom:1px solid var(--border);padding:6px}
|
| 484 |
+
.rail-sep{width:1px;height:24px;margin:0 6px}
|
| 485 |
+
.rail-label{display:none}
|
| 486 |
+
.workspace{min-height:60vh}
|
| 487 |
+
.inspector{border-left:none;border-top:1px solid var(--border)}
|
| 488 |
+
}
|
| 489 |
+
</style>
|
| 490 |
+
</head>
|
| 491 |
+
<body>
|
| 492 |
+
<div class="studio">
|
| 493 |
+
|
| 494 |
+
<!-- ══ Menu bar ══ -->
|
| 495 |
+
<div class="menubar">
|
| 496 |
+
<div class="menubar-logo">
|
| 497 |
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 23c-3.6 0-8-2.69-8-7.5 0-3.5 3-6.5 4.5-8 .27-.27.75-.08.75.28v2.44c0 .42.5.63.72.28C12.28 7.5 13 3 13 1c0-.42.48-.64.8-.35C18 4.5 20 9 20 12c0 5.5-3.5 11-8 11z"/></svg>
|
| 498 |
+
</div>
|
| 499 |
+
<div class="menubar-title">Qwen Studio <span>/ Image-Edit 2511</span></div>
|
| 500 |
+
<span class="menubar-badge">2511</span>
|
| 501 |
+
<span class="menubar-badge fast">4-STEP FAST</span>
|
| 502 |
+
<div class="menubar-spacer"></div>
|
| 503 |
+
<div class="menubar-status"><span class="dot" id="conn-dot"></span><span id="conn-text">connecting…</span></div>
|
| 504 |
+
<a href="https://github.com/PRITHIVSAKTHIUR/Qwen-Image-Edit-2511-LoRAs-Fast-Lazy-Load"
|
| 505 |
+
target="_blank" rel="noopener" class="gh-btn">
|
| 506 |
+
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
|
| 507 |
+
<span>GitHub</span>
|
| 508 |
+
</a>
|
| 509 |
+
</div>
|
| 510 |
+
|
| 511 |
+
<!-- ══ Left icon rail ══ -->
|
| 512 |
+
<div class="rail">
|
| 513 |
+
<div class="rail-label">Input</div>
|
| 514 |
+
<button class="rail-btn" id="tb-upload" title="Upload images">
|
| 515 |
+
<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
|
| 516 |
+
</button>
|
| 517 |
+
<button class="rail-btn" id="tb-remove" title="Remove selected image">
|
| 518 |
+
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
|
| 519 |
+
</button>
|
| 520 |
+
<button class="rail-btn" id="tb-clear" title="Clear all images">
|
| 521 |
+
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>
|
| 522 |
+
</button>
|
| 523 |
+
<div class="rail-sep"></div>
|
| 524 |
+
<div class="rail-label">Result</div>
|
| 525 |
+
<button class="rail-btn" id="compare-btn" title="Compare before / after" disabled>
|
| 526 |
+
<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/></svg>
|
| 527 |
+
</button>
|
| 528 |
+
<button class="rail-btn" id="use-as-input-btn" title="Use result as input (chain edits)" disabled>
|
| 529 |
+
<svg viewBox="0 0 24 24"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 014-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 01-4 4H3"/></svg>
|
| 530 |
+
</button>
|
| 531 |
+
<button class="rail-btn" id="dl-btn-output" title="Download result" disabled>
|
| 532 |
+
<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
|
| 533 |
+
</button>
|
| 534 |
+
<button class="rail-btn" id="zoom-btn" title="Zoom result" disabled>
|
| 535 |
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
|
| 536 |
+
</button>
|
| 537 |
+
</div>
|
| 538 |
+
|
| 539 |
+
<!-- ══ Workspace ══ -->
|
| 540 |
+
<div class="workspace">
|
| 541 |
+
<div class="canvas-head">
|
| 542 |
+
<div class="seg-control">
|
| 543 |
+
<button class="seg-btn active" id="seg-result">Result</button>
|
| 544 |
+
<button class="seg-btn" id="seg-input">Input</button>
|
| 545 |
+
</div>
|
| 546 |
+
<div class="canvas-meta" id="canvas-meta">No image loaded</div>
|
| 547 |
+
<div class="canvas-actions">
|
| 548 |
+
<span id="out-seed-chip" class="out-seed-chip" title="Click to copy seed"></span>
|
| 549 |
+
</div>
|
| 550 |
+
</div>
|
| 551 |
+
|
| 552 |
+
<div class="canvas-stage" id="output-image-container">
|
| 553 |
+
<div class="modern-loader" id="output-loader">
|
| 554 |
+
<div class="loader-spinner"></div>
|
| 555 |
+
<div class="loader-text" id="loader-text">Processing image…</div>
|
| 556 |
+
<div class="loader-bar-track"><div class="loader-bar-fill" id="loader-bar-fill"></div></div>
|
| 557 |
+
</div>
|
| 558 |
+
|
| 559 |
+
<div class="canvas-placeholder" id="output-placeholder">
|
| 560 |
+
<svg viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 561 |
+
<rect x="8" y="14" width="64" height="52" rx="6" fill="none" stroke="#33333a" stroke-width="2" stroke-dasharray="4 3"/>
|
| 562 |
+
<polygon points="12,62 30,40 42,50 54,34 68,62" fill="rgba(30,144,255,0.1)" stroke="#33333a" stroke-width="1.5"/>
|
| 563 |
+
<circle cx="28" cy="30" r="6" fill="rgba(30,144,255,0.12)" stroke="#33333a" stroke-width="1.5"/>
|
| 564 |
+
</svg>
|
| 565 |
+
<div class="cp-title">Canvas is empty</div>
|
| 566 |
+
<div class="cp-sub">
|
| 567 |
+
Drop images anywhere, paste with <kbd>⌘/Ctrl+V</kbd>, or use the rail to upload.
|
| 568 |
+
Then write an instruction and press <kbd>⌘/Ctrl</kbd>+<kbd>↵</kbd>.
|
| 569 |
+
</div>
|
| 570 |
+
</div>
|
| 571 |
+
|
| 572 |
+
<div class="compare-wrap" id="compare-wrap">
|
| 573 |
+
<img id="compare-after-img" alt="after">
|
| 574 |
+
<div class="compare-top" id="compare-top"><img id="compare-before-img" alt="before"></div>
|
| 575 |
+
<div class="compare-divider" id="compare-divider"><div class="compare-handle">⇄</div></div>
|
| 576 |
+
<span class="compare-label before">Before</span>
|
| 577 |
+
<span class="compare-label after">After</span>
|
| 578 |
+
</div>
|
| 579 |
+
</div>
|
| 580 |
+
|
| 581 |
+
<!-- Filmstrip -->
|
| 582 |
+
<div class="filmstrip">
|
| 583 |
+
<div class="filmstrip-section inputs">
|
| 584 |
+
<div class="filmstrip-label">Inputs <span class="count" id="tb-image-count">0</span></div>
|
| 585 |
+
<div class="filmstrip-row" id="image-gallery-grid"></div>
|
| 586 |
+
</div>
|
| 587 |
+
<div class="filmstrip-section history">
|
| 588 |
+
<div class="filmstrip-label">History <span class="count" id="history-count">0</span></div>
|
| 589 |
+
<div class="filmstrip-row" id="history-strip"></div>
|
| 590 |
+
</div>
|
| 591 |
+
</div>
|
| 592 |
+
</div>
|
| 593 |
+
|
| 594 |
+
<!-- ══ Inspector ══ -->
|
| 595 |
+
<div class="inspector">
|
| 596 |
+
<div class="inspector-tabs">
|
| 597 |
+
<button class="insp-tab active" id="tab-edit">Edit</button>
|
| 598 |
+
<button class="insp-tab" id="tab-examples">Examples</button>
|
| 599 |
+
</div>
|
| 600 |
+
|
| 601 |
+
<!-- Edit page -->
|
| 602 |
+
<div class="insp-page active" id="page-edit">
|
| 603 |
+
<div class="insp-section">
|
| 604 |
+
<div class="insp-section-title"><span>Instruction</span><span class="char-count" id="char-count">0</span></div>
|
| 605 |
+
<textarea id="custom-prompt-input" class="modern-textarea" rows="3"
|
| 606 |
+
placeholder="e.g., transform into anime, upscale, change lighting…"></textarea>
|
| 607 |
+
</div>
|
| 608 |
+
|
| 609 |
+
<div class="insp-section">
|
| 610 |
+
<div class="insp-section-title"><span>Quick Prompts</span></div>
|
| 611 |
+
<div class="suggestions-wrap" id="suggestions-wrap"></div>
|
| 612 |
+
</div>
|
| 613 |
+
|
| 614 |
+
<div class="insp-section">
|
| 615 |
+
<div class="insp-section-title"><span>Style / LoRA</span></div>
|
| 616 |
+
<select id="custom-lora-select" class="lora-native-select"></select>
|
| 617 |
+
</div>
|
| 618 |
+
|
| 619 |
+
<div class="insp-section">
|
| 620 |
+
<button id="custom-run-btn" class="btn-run">
|
| 621 |
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 23c-3.6 0-8-2.69-8-7.5 0-3.5 3-6.5 4.5-8 .27-.27.75-.08.75.28v2.44c0 .42.5.63.72.28C12.28 7.5 13 3 13 1c0-.42.48-.64.8-.35C18 4.5 20 9 20 12c0 5.5-3.5 11-8 11z"/></svg>
|
| 622 |
+
<span id="run-btn-label">Edit Image</span>
|
| 623 |
+
</button>
|
| 624 |
+
<button id="custom-cancel-btn" class="btn-cancel" style="display:none;">Cancel</button>
|
| 625 |
+
<div class="run-hint">⌘/Ctrl + Enter</div>
|
| 626 |
+
</div>
|
| 627 |
+
|
| 628 |
+
<div class="insp-section">
|
| 629 |
+
<div class="insp-section-title"><span>Advanced</span></div>
|
| 630 |
+
<div class="slider-row">
|
| 631 |
+
<label>Seed</label>
|
| 632 |
+
<input type="range" id="custom-seed" min="0" max="2147483647" step="1" value="0">
|
| 633 |
+
<span class="slider-val" id="custom-seed-val">0</span>
|
| 634 |
+
<button class="dice-btn" id="dice-btn" title="Random seed">
|
| 635 |
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM7.5 18c-.83 0-1.5-.67-1.5-1.5S6.67 15 7.5 15s1.5.67 1.5 1.5S8.33 18 7.5 18zm0-9C6.67 9 6 8.33 6 7.5S6.67 6 7.5 6 9 6.67 9 7.5 8.33 9 7.5 9zm4.5 4.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5 4.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm0-9c-.83 0-1.5-.67-1.5-1.5S15.67 6 16.5 6s1.5.67 1.5 1.5S17.33 9 16.5 9z"/></svg>
|
| 636 |
+
</button>
|
| 637 |
+
</div>
|
| 638 |
+
<div class="checkbox-row">
|
| 639 |
+
<input type="checkbox" id="custom-randomize" checked>
|
| 640 |
+
<label for="custom-randomize">Randomize seed</label>
|
| 641 |
+
</div>
|
| 642 |
+
<div class="slider-row">
|
| 643 |
+
<label>Guidance</label>
|
| 644 |
+
<input type="range" id="custom-guidance" min="1" max="10" step="0.1" value="1.0">
|
| 645 |
+
<span class="slider-val" id="custom-guidance-val">1.0</span>
|
| 646 |
+
</div>
|
| 647 |
+
<div class="slider-row">
|
| 648 |
+
<label>Steps</label>
|
| 649 |
+
<input type="range" id="custom-steps" min="1" max="50" step="1" value="4">
|
| 650 |
+
<span class="slider-val" id="custom-steps-val">4</span>
|
| 651 |
+
</div>
|
| 652 |
+
</div>
|
| 653 |
+
</div>
|
| 654 |
+
|
| 655 |
+
<!-- Examples page -->
|
| 656 |
+
<div class="insp-page" id="page-examples">
|
| 657 |
+
<div class="examples-list" id="examples-scroll"></div>
|
| 658 |
+
</div>
|
| 659 |
+
</div>
|
| 660 |
+
|
| 661 |
+
<!-- ══ Status bar ══ -->
|
| 662 |
+
<div class="statusbar">
|
| 663 |
+
<div class="sb-section" id="sb-image-count">No inputs</div>
|
| 664 |
+
<div class="sb-right">
|
| 665 |
+
<a class="sb-link" href="https://huggingface.co/Qwen/Qwen-Image-Edit-2511" target="_blank" rel="noopener">Qwen-Image-Edit-2511</a>
|
| 666 |
+
<span class="sb-pill" id="sb-status">Ready</span>
|
| 667 |
+
</div>
|
| 668 |
+
</div>
|
| 669 |
+
|
| 670 |
+
</div>
|
| 671 |
+
|
| 672 |
+
<input id="custom-file-input" type="file" accept="image/*" multiple style="display:none;" />
|
| 673 |
+
|
| 674 |
+
<!-- Lightbox -->
|
| 675 |
+
<div class="lightbox" id="lightbox"><img id="lightbox-img" alt="zoom"></div>
|
| 676 |
+
|
| 677 |
+
<!-- Global drop overlay -->
|
| 678 |
+
<div class="drop-overlay" id="drop-overlay"><div class="drop-overlay-inner">Drop images to upload</div></div>
|
| 679 |
+
|
| 680 |
+
<script type="module">
|
| 681 |
+
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
|
| 682 |
+
|
| 683 |
+
/* ── DOM refs ── */
|
| 684 |
+
const galleryGrid = document.getElementById('image-gallery-grid');
|
| 685 |
+
const fileInput = document.getElementById('custom-file-input');
|
| 686 |
+
const btnUpload = document.getElementById('tb-upload');
|
| 687 |
+
const btnRemove = document.getElementById('tb-remove');
|
| 688 |
+
const btnClear = document.getElementById('tb-clear');
|
| 689 |
+
const promptInput = document.getElementById('custom-prompt-input');
|
| 690 |
+
const charCount = document.getElementById('char-count');
|
| 691 |
+
const loraSelect = document.getElementById('custom-lora-select');
|
| 692 |
+
const runBtn = document.getElementById('custom-run-btn');
|
| 693 |
+
const runBtnLabel = document.getElementById('run-btn-label');
|
| 694 |
+
const cancelBtn = document.getElementById('custom-cancel-btn');
|
| 695 |
+
const imgCountTb = document.getElementById('tb-image-count');
|
| 696 |
+
const imgCountSb = document.getElementById('sb-image-count');
|
| 697 |
+
const sbStatus = document.getElementById('sb-status');
|
| 698 |
+
const loader = document.getElementById('output-loader');
|
| 699 |
+
const loaderText = document.getElementById('loader-text');
|
| 700 |
+
const loaderFill = document.getElementById('loader-bar-fill');
|
| 701 |
+
const outBody = document.getElementById('output-image-container');
|
| 702 |
+
const outPh = document.getElementById('output-placeholder');
|
| 703 |
+
const dlBtn = document.getElementById('dl-btn-output');
|
| 704 |
+
const compareBtn = document.getElementById('compare-btn');
|
| 705 |
+
const useAsInputBtn= document.getElementById('use-as-input-btn');
|
| 706 |
+
const zoomBtn = document.getElementById('zoom-btn');
|
| 707 |
+
const seedChip = document.getElementById('out-seed-chip');
|
| 708 |
+
const historyStrip = document.getElementById('history-strip');
|
| 709 |
+
const historyCount = document.getElementById('history-count');
|
| 710 |
+
const seedSlider = document.getElementById('custom-seed');
|
| 711 |
+
const seedVal = document.getElementById('custom-seed-val');
|
| 712 |
+
const lightbox = document.getElementById('lightbox');
|
| 713 |
+
const lightboxImg = document.getElementById('lightbox-img');
|
| 714 |
+
const dropOverlay = document.getElementById('drop-overlay');
|
| 715 |
+
const compareWrap = document.getElementById('compare-wrap');
|
| 716 |
+
const compareTop = document.getElementById('compare-top');
|
| 717 |
+
const compareDivider = document.getElementById('compare-divider');
|
| 718 |
+
const compareBeforeImg = document.getElementById('compare-before-img');
|
| 719 |
+
const compareAfterImg = document.getElementById('compare-after-img');
|
| 720 |
+
const canvasMeta = document.getElementById('canvas-meta');
|
| 721 |
+
const segResult = document.getElementById('seg-result');
|
| 722 |
+
const segInput = document.getElementById('seg-input');
|
| 723 |
+
const connDot = document.getElementById('conn-dot');
|
| 724 |
+
const connText = document.getElementById('conn-text');
|
| 725 |
+
|
| 726 |
+
/* ── State ── */
|
| 727 |
+
let images = [];
|
| 728 |
+
let selectedIdx = -1;
|
| 729 |
+
let toastTimer = null;
|
| 730 |
+
let running = false;
|
| 731 |
+
let currentJob = null;
|
| 732 |
+
let currentResult = null; // {b64, seed, prompt, lora, beforeB64}
|
| 733 |
+
let history = [];
|
| 734 |
+
let historyIdx = -1;
|
| 735 |
+
let compareMode = false;
|
| 736 |
+
let viewMode = 'result'; // 'result' | 'input'
|
| 737 |
+
|
| 738 |
+
const SUGGESTIONS = [
|
| 739 |
+
['Anime', 'Transform into anime.'],
|
| 740 |
+
['B&W', 'Convert it to black and white.'],
|
| 741 |
+
['Cinematic', 'Add cinematic lighting with warm orange tones and film grain.'],
|
| 742 |
+
['Oil Paint', 'Apply oil painting effect with visible brush strokes.'],
|
| 743 |
+
['Upscale 4K', 'Upscale this picture to 4K resolution.'],
|
| 744 |
+
['Watercolor', 'Make it look like a watercolor painting with soft edges.'],
|
| 745 |
+
['Pencil Sketch', 'Convert to detailed pencil sketch with cross-hatching and shading.'],
|
| 746 |
+
['Pop Art', 'Apply pop art style with bold colors and halftone patterns.'],
|
| 747 |
+
['Vintage Retro', 'Apply a vintage retro film look with faded colors and light leaks.'],
|
| 748 |
+
['Neon Glow', 'Add neon glow effects with vibrant colors against a dark background.'],
|
| 749 |
+
['Pixel Art', 'Convert to pixel art style with a retro 16-bit aesthetic.'],
|
| 750 |
+
['Noir Comic', 'Transform into a noir comic book style.'],
|
| 751 |
+
['HyperReal', 'Transform into a hyper-realistic face portrait.'],
|
| 752 |
+
['Unblur', 'Unblur and upscale.'],
|
| 753 |
+
['Pixar 3D', 'Transform into Pixar-inspired 3D.'],
|
| 754 |
+
['Manga Tone', 'Paint with manga tone.'],
|
| 755 |
+
];
|
| 756 |
+
|
| 757 |
+
/* ── Toast ── */
|
| 758 |
+
function showToast(message, type) {
|
| 759 |
+
let toast = document.getElementById('app-toast');
|
| 760 |
+
if (!toast) {
|
| 761 |
+
toast = document.createElement('div');
|
| 762 |
+
toast.id = 'app-toast';
|
| 763 |
+
toast.className = 'toast-notification';
|
| 764 |
+
toast.innerHTML = '<span class="toast-icon"></span><span class="toast-text"></span>';
|
| 765 |
+
document.body.appendChild(toast);
|
| 766 |
+
}
|
| 767 |
+
const icon = toast.querySelector('.toast-icon');
|
| 768 |
+
const text = toast.querySelector('.toast-text');
|
| 769 |
+
toast.className = 'toast-notification ' + (type || 'error');
|
| 770 |
+
icon.textContent = type === 'warning' ? '⚠' : type === 'info' ? 'ℹ' : '✗';
|
| 771 |
+
text.textContent = message;
|
| 772 |
+
if (toastTimer) clearTimeout(toastTimer);
|
| 773 |
+
void toast.offsetWidth;
|
| 774 |
+
toast.classList.add('visible');
|
| 775 |
+
toastTimer = setTimeout(() => toast.classList.remove('visible'), 3500);
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
function flashPromptError() {
|
| 779 |
+
promptInput.classList.add('error-flash');
|
| 780 |
+
promptInput.focus();
|
| 781 |
+
setTimeout(() => promptInput.classList.remove('error-flash'), 800);
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
function setStatus(text, cls) {
|
| 785 |
+
sbStatus.textContent = text;
|
| 786 |
+
sbStatus.className = 'sb-pill' + (cls ? ' ' + cls : '');
|
| 787 |
+
}
|
| 788 |
+
|
| 789 |
+
/* ── View mode (Result / Input canvas) ── */
|
| 790 |
+
function setViewMode(mode) {
|
| 791 |
+
viewMode = mode;
|
| 792 |
+
segResult.classList.toggle('active', mode === 'result');
|
| 793 |
+
segInput.classList.toggle('active', mode === 'input');
|
| 794 |
+
renderCanvas();
|
| 795 |
+
}
|
| 796 |
+
segResult.addEventListener('click', () => setViewMode('result'));
|
| 797 |
+
segInput.addEventListener('click', () => setViewMode('input'));
|
| 798 |
+
|
| 799 |
+
function getCanvasImg() { return outBody.querySelector('img.modern-out-img'); }
|
| 800 |
+
|
| 801 |
+
function renderCanvas() {
|
| 802 |
+
exitCompareMode();
|
| 803 |
+
let img = getCanvasImg();
|
| 804 |
+
const showResult = viewMode === 'result' && currentResult;
|
| 805 |
+
const showInput = viewMode === 'input' && images.length > 0;
|
| 806 |
+
|
| 807 |
+
if (showResult || showInput) {
|
| 808 |
+
outPh.style.display = 'none';
|
| 809 |
+
if (!img) {
|
| 810 |
+
img = document.createElement('img');
|
| 811 |
+
img.className = 'modern-out-img';
|
| 812 |
+
img.addEventListener('click', () => {
|
| 813 |
+
if (img.src) { lightboxImg.src = img.src; lightbox.classList.add('visible'); }
|
| 814 |
+
});
|
| 815 |
+
outBody.appendChild(img);
|
| 816 |
+
}
|
| 817 |
+
img.style.display = '';
|
| 818 |
+
if (showResult) {
|
| 819 |
+
img.src = currentResult.b64;
|
| 820 |
+
canvasMeta.textContent = (currentResult.lora || 'result') + ' · seed ' + currentResult.seed;
|
| 821 |
+
} else {
|
| 822 |
+
const i = selectedIdx >= 0 ? selectedIdx : 0;
|
| 823 |
+
img.src = images[i].b64;
|
| 824 |
+
canvasMeta.textContent = 'input #' + (i + 1) + ' · ' + (images[i].name || 'image');
|
| 825 |
+
}
|
| 826 |
+
} else {
|
| 827 |
+
if (img) img.style.display = 'none';
|
| 828 |
+
outPh.style.display = '';
|
| 829 |
+
canvasMeta.textContent = images.length > 0
|
| 830 |
+
? images.length + ' input' + (images.length > 1 ? 's' : '') + ' ready — run an edit'
|
| 831 |
+
: 'No image loaded';
|
| 832 |
+
}
|
| 833 |
+
updateRailState();
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
function updateRailState() {
|
| 837 |
+
const hasResult = !!currentResult;
|
| 838 |
+
dlBtn.disabled = !hasResult;
|
| 839 |
+
zoomBtn.disabled = !hasResult && images.length === 0;
|
| 840 |
+
useAsInputBtn.disabled = !hasResult;
|
| 841 |
+
compareBtn.disabled = !(hasResult && currentResult.beforeB64);
|
| 842 |
+
btnRemove.disabled = selectedIdx < 0;
|
| 843 |
+
btnClear.disabled = images.length === 0;
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
/* ── Inputs filmstrip ── */
|
| 847 |
+
function updateCounts() {
|
| 848 |
+
const n = images.length;
|
| 849 |
+
imgCountTb.textContent = n;
|
| 850 |
+
imgCountSb.textContent = n > 0 ? n + ' input' + (n > 1 ? 's' : '') + ' · ' + history.length + ' result' + (history.length === 1 ? '' : 's') : 'No inputs';
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
function addImage(b64, name) {
|
| 854 |
+
images.push({id: Date.now() + Math.random(), b64, name});
|
| 855 |
+
if (selectedIdx < 0) selectedIdx = 0;
|
| 856 |
+
renderFilmstrip(); updateCounts();
|
| 857 |
+
if (!currentResult || viewMode === 'input') renderCanvas();
|
| 858 |
+
}
|
| 859 |
+
|
| 860 |
+
function removeImage(idx) {
|
| 861 |
+
images.splice(idx, 1);
|
| 862 |
+
if (selectedIdx === idx) selectedIdx = images.length ? 0 : -1;
|
| 863 |
+
else if (selectedIdx > idx) selectedIdx--;
|
| 864 |
+
renderFilmstrip(); updateCounts(); renderCanvas();
|
| 865 |
+
}
|
| 866 |
+
|
| 867 |
+
function clearAll() {
|
| 868 |
+
images = []; selectedIdx = -1;
|
| 869 |
+
renderFilmstrip(); updateCounts(); renderCanvas();
|
| 870 |
+
}
|
| 871 |
+
|
| 872 |
+
function renderFilmstrip() {
|
| 873 |
+
galleryGrid.innerHTML = '';
|
| 874 |
+
if (images.length === 0) {
|
| 875 |
+
const empty = document.createElement('div');
|
| 876 |
+
empty.className = 'fs-empty';
|
| 877 |
+
empty.textContent = 'Drop or paste images…';
|
| 878 |
+
galleryGrid.appendChild(empty);
|
| 879 |
+
}
|
| 880 |
+
images.forEach((img, i) => {
|
| 881 |
+
const t = document.createElement('div');
|
| 882 |
+
t.className = 'fs-thumb' + (i === selectedIdx ? ' selected' : '');
|
| 883 |
+
t.innerHTML = '<img src="' + img.b64 + '" alt="">' +
|
| 884 |
+
'<span class="fs-badge">#' + (i + 1) + '</span>' +
|
| 885 |
+
'<button class="fs-remove">✕</button>';
|
| 886 |
+
t.addEventListener('click', (e) => {
|
| 887 |
+
if (e.target.closest('.fs-remove')) return;
|
| 888 |
+
selectedIdx = i;
|
| 889 |
+
renderFilmstrip();
|
| 890 |
+
setViewMode('input');
|
| 891 |
+
});
|
| 892 |
+
t.querySelector('.fs-remove').addEventListener('click', (e) => {
|
| 893 |
+
e.stopPropagation(); removeImage(i);
|
| 894 |
+
});
|
| 895 |
+
galleryGrid.appendChild(t);
|
| 896 |
+
});
|
| 897 |
+
const add = document.createElement('div');
|
| 898 |
+
add.className = 'fs-add';
|
| 899 |
+
add.innerHTML = '<span class="add-icon">+</span><span class="add-text">Add</span>';
|
| 900 |
+
add.addEventListener('click', () => fileInput.click());
|
| 901 |
+
galleryGrid.appendChild(add);
|
| 902 |
+
updateRailState();
|
| 903 |
+
}
|
| 904 |
+
|
| 905 |
+
function processFiles(files) {
|
| 906 |
+
let added = 0;
|
| 907 |
+
Array.from(files).forEach(file => {
|
| 908 |
+
if (!file.type.startsWith('image/')) return;
|
| 909 |
+
added++;
|
| 910 |
+
const reader = new FileReader();
|
| 911 |
+
reader.onload = (e) => addImage(e.target.result, file.name);
|
| 912 |
+
reader.readAsDataURL(file);
|
| 913 |
+
});
|
| 914 |
+
return added;
|
| 915 |
+
}
|
| 916 |
+
|
| 917 |
+
fileInput.addEventListener('change', (e) => { processFiles(e.target.files); e.target.value = ''; });
|
| 918 |
+
btnUpload.addEventListener('click', () => fileInput.click());
|
| 919 |
+
btnRemove.addEventListener('click', () => { if (selectedIdx >= 0) removeImage(selectedIdx); });
|
| 920 |
+
btnClear.addEventListener('click', clearAll);
|
| 921 |
+
|
| 922 |
+
/* ── Drop anywhere ── */
|
| 923 |
+
let dragDepth = 0;
|
| 924 |
+
window.addEventListener('dragenter', (e) => {
|
| 925 |
+
if (!e.dataTransfer || !Array.from(e.dataTransfer.types).includes('Files')) return;
|
| 926 |
+
e.preventDefault();
|
| 927 |
+
dragDepth++;
|
| 928 |
+
dropOverlay.classList.add('visible');
|
| 929 |
+
});
|
| 930 |
+
window.addEventListener('dragleave', (e) => {
|
| 931 |
+
if (!e.dataTransfer || !Array.from(e.dataTransfer.types).includes('Files')) return;
|
| 932 |
+
dragDepth = Math.max(0, dragDepth - 1);
|
| 933 |
+
if (dragDepth === 0) dropOverlay.classList.remove('visible');
|
| 934 |
+
});
|
| 935 |
+
window.addEventListener('dragover', (e) => { e.preventDefault(); });
|
| 936 |
+
window.addEventListener('drop', (e) => {
|
| 937 |
+
e.preventDefault();
|
| 938 |
+
dragDepth = 0;
|
| 939 |
+
dropOverlay.classList.remove('visible');
|
| 940 |
+
if (e.dataTransfer.files.length) {
|
| 941 |
+
const n = processFiles(e.dataTransfer.files);
|
| 942 |
+
if (n > 0) showToast('Added ' + n + ' image' + (n > 1 ? 's' : ''), 'info');
|
| 943 |
+
}
|
| 944 |
+
});
|
| 945 |
+
|
| 946 |
+
/* ── Paste ── */
|
| 947 |
+
document.addEventListener('paste', (e) => {
|
| 948 |
+
if (e.target === promptInput) return;
|
| 949 |
+
const items = e.clipboardData && e.clipboardData.items;
|
| 950 |
+
if (!items) return;
|
| 951 |
+
const files = [];
|
| 952 |
+
for (const item of items) {
|
| 953 |
+
if (item.kind === 'file' && item.type.startsWith('image/')) {
|
| 954 |
+
const f = item.getAsFile();
|
| 955 |
+
if (f) files.push(f);
|
| 956 |
+
}
|
| 957 |
+
}
|
| 958 |
+
if (files.length) {
|
| 959 |
+
e.preventDefault();
|
| 960 |
+
processFiles(files);
|
| 961 |
+
showToast('Pasted ' + files.length + ' image' + (files.length > 1 ? 's' : ''), 'info');
|
| 962 |
+
}
|
| 963 |
+
});
|
| 964 |
+
|
| 965 |
+
/* ── Inspector tabs ── */
|
| 966 |
+
const tabEdit = document.getElementById('tab-edit');
|
| 967 |
+
const tabExamples = document.getElementById('tab-examples');
|
| 968 |
+
const pageEdit = document.getElementById('page-edit');
|
| 969 |
+
const pageExamples = document.getElementById('page-examples');
|
| 970 |
+
tabEdit.addEventListener('click', () => {
|
| 971 |
+
tabEdit.classList.add('active'); tabExamples.classList.remove('active');
|
| 972 |
+
pageEdit.classList.add('active'); pageExamples.classList.remove('active');
|
| 973 |
+
});
|
| 974 |
+
tabExamples.addEventListener('click', () => {
|
| 975 |
+
tabExamples.classList.add('active'); tabEdit.classList.remove('active');
|
| 976 |
+
pageExamples.classList.add('active'); pageEdit.classList.remove('active');
|
| 977 |
+
});
|
| 978 |
+
|
| 979 |
+
/* ── Suggestion chips ── */
|
| 980 |
+
const suggWrap = document.getElementById('suggestions-wrap');
|
| 981 |
+
SUGGESTIONS.forEach(([label, prompt]) => {
|
| 982 |
+
const chip = document.createElement('button');
|
| 983 |
+
chip.className = 'suggestion-chip';
|
| 984 |
+
chip.textContent = label;
|
| 985 |
+
chip.addEventListener('click', () => {
|
| 986 |
+
promptInput.value = prompt;
|
| 987 |
+
updateCharCount();
|
| 988 |
+
suggWrap.querySelectorAll('.suggestion-chip').forEach(c => c.classList.remove('active'));
|
| 989 |
+
chip.classList.add('active');
|
| 990 |
+
promptInput.focus();
|
| 991 |
+
});
|
| 992 |
+
suggWrap.appendChild(chip);
|
| 993 |
+
});
|
| 994 |
+
|
| 995 |
+
function updateCharCount() { charCount.textContent = promptInput.value.length; }
|
| 996 |
+
promptInput.addEventListener('input', () => {
|
| 997 |
+
updateCharCount();
|
| 998 |
+
suggWrap.querySelectorAll('.suggestion-chip').forEach(c => c.classList.remove('active'));
|
| 999 |
+
});
|
| 1000 |
+
updateCharCount();
|
| 1001 |
+
|
| 1002 |
+
/* ── Sliders ── */
|
| 1003 |
+
function bindSlider(id) {
|
| 1004 |
+
const slider = document.getElementById(id);
|
| 1005 |
+
const valSpan = document.getElementById(id + '-val');
|
| 1006 |
+
slider.addEventListener('input', () => { valSpan.textContent = slider.value; });
|
| 1007 |
+
}
|
| 1008 |
+
bindSlider('custom-seed');
|
| 1009 |
+
bindSlider('custom-guidance');
|
| 1010 |
+
bindSlider('custom-steps');
|
| 1011 |
+
|
| 1012 |
+
document.getElementById('dice-btn').addEventListener('click', () => {
|
| 1013 |
+
const s = Math.floor(Math.random() * 2147483647);
|
| 1014 |
+
seedSlider.value = s; seedVal.textContent = s;
|
| 1015 |
+
});
|
| 1016 |
+
|
| 1017 |
+
/* ── Loader ── */
|
| 1018 |
+
function showLoader(text) {
|
| 1019 |
+
loaderText.textContent = text || 'Processing image…';
|
| 1020 |
+
loaderFill.classList.remove('determinate');
|
| 1021 |
+
loaderFill.style.width = '100%';
|
| 1022 |
+
loader.classList.add('active');
|
| 1023 |
+
setStatus('Processing…');
|
| 1024 |
+
}
|
| 1025 |
+
function setLoaderProgress(text, frac) {
|
| 1026 |
+
loaderText.textContent = text;
|
| 1027 |
+
if (frac != null && frac >= 0 && frac <= 1) {
|
| 1028 |
+
loaderFill.classList.add('determinate');
|
| 1029 |
+
loaderFill.style.width = Math.max(4, Math.round(frac * 100)) + '%';
|
| 1030 |
+
}
|
| 1031 |
+
}
|
| 1032 |
+
function hideLoader(statusText, cls) {
|
| 1033 |
+
loader.classList.remove('active');
|
| 1034 |
+
setStatus(statusText || 'Done', cls || 'done');
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
/* ── Result / history ── */
|
| 1038 |
+
function showResult(entry) {
|
| 1039 |
+
currentResult = entry;
|
| 1040 |
+
setViewMode('result');
|
| 1041 |
+
dlBtn.disabled = false;
|
| 1042 |
+
useAsInputBtn.disabled = false;
|
| 1043 |
+
zoomBtn.disabled = false;
|
| 1044 |
+
if (entry.beforeB64) compareBtn.disabled = false;
|
| 1045 |
+
if (entry.seed != null) {
|
| 1046 |
+
seedChip.textContent = 'seed ' + entry.seed;
|
| 1047 |
+
seedChip.classList.add('visible');
|
| 1048 |
+
}
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
function renderHistory() {
|
| 1052 |
+
historyStrip.innerHTML = '';
|
| 1053 |
+
historyCount.textContent = history.length;
|
| 1054 |
+
if (history.length === 0) {
|
| 1055 |
+
const empty = document.createElement('div');
|
| 1056 |
+
empty.className = 'fs-empty';
|
| 1057 |
+
empty.textContent = 'No results yet';
|
| 1058 |
+
historyStrip.appendChild(empty);
|
| 1059 |
+
return;
|
| 1060 |
+
}
|
| 1061 |
+
history.forEach((entry, i) => {
|
| 1062 |
+
const t = document.createElement('div');
|
| 1063 |
+
t.className = 'fs-thumb' + (i === historyIdx ? ' selected' : '');
|
| 1064 |
+
t.title = (entry.lora || '') + ' · seed ' + entry.seed;
|
| 1065 |
+
const im = document.createElement('img');
|
| 1066 |
+
im.src = entry.b64;
|
| 1067 |
+
t.appendChild(im);
|
| 1068 |
+
t.addEventListener('click', () => { historyIdx = i; showResult(history[i]); renderHistory(); });
|
| 1069 |
+
historyStrip.appendChild(t);
|
| 1070 |
+
});
|
| 1071 |
+
}
|
| 1072 |
+
|
| 1073 |
+
function pushHistory(entry) {
|
| 1074 |
+
history.push(entry);
|
| 1075 |
+
historyIdx = history.length - 1;
|
| 1076 |
+
renderHistory();
|
| 1077 |
+
updateCounts();
|
| 1078 |
+
}
|
| 1079 |
+
|
| 1080 |
+
/* ── Compare slider ── */
|
| 1081 |
+
function enterCompareMode() {
|
| 1082 |
+
if (!currentResult || !currentResult.beforeB64) return;
|
| 1083 |
+
compareMode = true;
|
| 1084 |
+
compareBtn.classList.add('active');
|
| 1085 |
+
const img = getCanvasImg();
|
| 1086 |
+
if (img) img.style.display = 'none';
|
| 1087 |
+
compareAfterImg.src = currentResult.b64;
|
| 1088 |
+
compareBeforeImg.src = currentResult.beforeB64;
|
| 1089 |
+
compareWrap.classList.add('visible');
|
| 1090 |
+
requestAnimationFrame(() => setComparePos(0.5));
|
| 1091 |
+
}
|
| 1092 |
+
function exitCompareMode() {
|
| 1093 |
+
if (!compareMode) return;
|
| 1094 |
+
compareMode = false;
|
| 1095 |
+
compareBtn.classList.remove('active');
|
| 1096 |
+
compareWrap.classList.remove('visible');
|
| 1097 |
+
const img = getCanvasImg();
|
| 1098 |
+
if (img && (viewMode === 'result' && currentResult || viewMode === 'input' && images.length)) img.style.display = '';
|
| 1099 |
+
}
|
| 1100 |
+
function setComparePos(frac) {
|
| 1101 |
+
frac = Math.max(0, Math.min(1, frac));
|
| 1102 |
+
const w = compareWrap.clientWidth;
|
| 1103 |
+
const x = frac * w;
|
| 1104 |
+
compareTop.style.clipPath = 'inset(0 ' + (w - x) + 'px 0 0)';
|
| 1105 |
+
compareDivider.style.left = x + 'px';
|
| 1106 |
+
}
|
| 1107 |
+
compareBtn.addEventListener('click', () => { compareMode ? exitCompareMode() : enterCompareMode(); });
|
| 1108 |
+
|
| 1109 |
+
let compareDragging = false;
|
| 1110 |
+
function compareMove(clientX) {
|
| 1111 |
+
const rect = compareWrap.getBoundingClientRect();
|
| 1112 |
+
setComparePos((clientX - rect.left) / rect.width);
|
| 1113 |
+
}
|
| 1114 |
+
compareWrap.addEventListener('pointerdown', (e) => {
|
| 1115 |
+
compareDragging = true;
|
| 1116 |
+
compareWrap.setPointerCapture(e.pointerId);
|
| 1117 |
+
compareMove(e.clientX);
|
| 1118 |
+
});
|
| 1119 |
+
compareWrap.addEventListener('pointermove', (e) => { if (compareDragging) compareMove(e.clientX); });
|
| 1120 |
+
compareWrap.addEventListener('pointerup', () => { compareDragging = false; });
|
| 1121 |
+
compareWrap.addEventListener('pointercancel', () => { compareDragging = false; });
|
| 1122 |
+
|
| 1123 |
+
/* ── Lightbox ── */
|
| 1124 |
+
lightbox.addEventListener('click', () => lightbox.classList.remove('visible'));
|
| 1125 |
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') lightbox.classList.remove('visible'); });
|
| 1126 |
+
zoomBtn.addEventListener('click', () => {
|
| 1127 |
+
const img = getCanvasImg();
|
| 1128 |
+
const src = (viewMode === 'result' && currentResult) ? currentResult.b64
|
| 1129 |
+
: (images.length ? images[selectedIdx >= 0 ? selectedIdx : 0].b64 : null);
|
| 1130 |
+
if (src) { lightboxImg.src = src; lightbox.classList.add('visible'); }
|
| 1131 |
+
});
|
| 1132 |
+
|
| 1133 |
+
/* ── Download / chain / seed ── */
|
| 1134 |
+
dlBtn.addEventListener('click', () => {
|
| 1135 |
+
if (currentResult && currentResult.b64) {
|
| 1136 |
+
const a = document.createElement('a');
|
| 1137 |
+
a.href = currentResult.b64;
|
| 1138 |
+
a.download = 'qwen_edit_' + (currentResult.seed != null ? currentResult.seed : 'output') + '.png';
|
| 1139 |
+
document.body.appendChild(a); a.click(); document.body.removeChild(a);
|
| 1140 |
+
}
|
| 1141 |
+
});
|
| 1142 |
+
useAsInputBtn.addEventListener('click', () => {
|
| 1143 |
+
if (!currentResult) return;
|
| 1144 |
+
addImage(currentResult.b64, 'edit_seed_' + (currentResult.seed != null ? currentResult.seed : 'x') + '.png');
|
| 1145 |
+
showToast('Result added as input image', 'info');
|
| 1146 |
+
});
|
| 1147 |
+
seedChip.addEventListener('click', () => {
|
| 1148 |
+
if (currentResult && currentResult.seed != null) {
|
| 1149 |
+
navigator.clipboard.writeText(String(currentResult.seed)).then(
|
| 1150 |
+
() => showToast('Seed copied: ' + currentResult.seed, 'info'), () => {});
|
| 1151 |
+
}
|
| 1152 |
+
});
|
| 1153 |
+
|
| 1154 |
+
/* ── Backend connection ── */
|
| 1155 |
+
let client = null;
|
| 1156 |
+
try {
|
| 1157 |
+
client = await Client.connect(window.location.origin);
|
| 1158 |
+
setStatus('Ready');
|
| 1159 |
+
connDot.classList.remove('off');
|
| 1160 |
+
connText.textContent = 'connected';
|
| 1161 |
+
} catch (e) {
|
| 1162 |
+
console.error('Failed to connect to Gradio backend:', e);
|
| 1163 |
+
setStatus('Offline', 'error');
|
| 1164 |
+
connDot.classList.add('off');
|
| 1165 |
+
connText.textContent = 'offline';
|
| 1166 |
+
showToast('Could not connect to the backend API', 'error');
|
| 1167 |
+
}
|
| 1168 |
+
|
| 1169 |
+
/* ── Config: LoRAs + examples ── */
|
| 1170 |
+
function renderConfig(cfg) {
|
| 1171 |
+
loraSelect.innerHTML = '';
|
| 1172 |
+
cfg.loras.forEach(name => {
|
| 1173 |
+
const opt = document.createElement('option');
|
| 1174 |
+
opt.value = name; opt.textContent = name;
|
| 1175 |
+
loraSelect.appendChild(opt);
|
| 1176 |
+
});
|
| 1177 |
+
if (cfg.default_lora) loraSelect.value = cfg.default_lora;
|
| 1178 |
+
|
| 1179 |
+
const list = document.getElementById('examples-scroll');
|
| 1180 |
+
list.innerHTML = '';
|
| 1181 |
+
cfg.examples.forEach(ex => {
|
| 1182 |
+
const card = document.createElement('div');
|
| 1183 |
+
card.className = 'example-card';
|
| 1184 |
+
const thumbs = ex.thumbs.map(t =>
|
| 1185 |
+
t ? '<img src="' + t + '" alt="">' : '<div class="example-thumb-placeholder">Preview</div>'
|
| 1186 |
+
).join('');
|
| 1187 |
+
const promptShort = ex.prompt.length > 90 ? ex.prompt.slice(0, 90) + '…' : ex.prompt;
|
| 1188 |
+
card.innerHTML =
|
| 1189 |
+
'<div class="example-thumbs">' + thumbs + '</div>'
|
| 1190 |
+
+ '<div class="example-meta">'
|
| 1191 |
+
+ '<span class="example-badge">' + ex.n_images + ' img' + (ex.n_images > 1 ? 's' : '') + '</span>'
|
| 1192 |
+
+ '<span class="example-lora-badge"></span>'
|
| 1193 |
+
+ '</div>'
|
| 1194 |
+
+ '<div class="example-prompt-text"></div>';
|
| 1195 |
+
card.querySelector('.example-lora-badge').textContent = ex.lora;
|
| 1196 |
+
card.querySelector('.example-prompt-text').textContent = promptShort;
|
| 1197 |
+
card.addEventListener('click', () => loadExample(card, ex.idx));
|
| 1198 |
+
list.appendChild(card);
|
| 1199 |
+
});
|
| 1200 |
+
}
|
| 1201 |
+
|
| 1202 |
+
async function loadExample(card, idx) {
|
| 1203 |
+
if (!client) { showToast('Backend not connected', 'error'); return; }
|
| 1204 |
+
document.querySelectorAll('.example-card.loading').forEach(c => c.classList.remove('loading'));
|
| 1205 |
+
card.classList.add('loading');
|
| 1206 |
+
showToast('Loading example…', 'info');
|
| 1207 |
+
try {
|
| 1208 |
+
const result = await client.predict('/load_example', { idx: idx });
|
| 1209 |
+
const data = result.data[0];
|
| 1210 |
+
if (data && data.status === 'ok' && data.images && data.images.length > 0) {
|
| 1211 |
+
clearAll();
|
| 1212 |
+
if (data.prompt) { promptInput.value = data.prompt; updateCharCount(); }
|
| 1213 |
+
if (data.lora) loraSelect.value = data.lora;
|
| 1214 |
+
data.images.forEach((b64, i) => {
|
| 1215 |
+
const name = (data.names && data.names[i]) ? data.names[i] : ('example_' + (i + 1) + '.jpg');
|
| 1216 |
+
addImage(b64, name);
|
| 1217 |
+
});
|
| 1218 |
+
tabEdit.click();
|
| 1219 |
+
showToast('Example loaded — ' + data.images.length + ' image(s)', 'info');
|
| 1220 |
+
} else {
|
| 1221 |
+
showToast('Could not load example images', 'error');
|
| 1222 |
+
}
|
| 1223 |
+
} catch (e) {
|
| 1224 |
+
console.error('Example load error:', e);
|
| 1225 |
+
showToast('Could not load example images', 'error');
|
| 1226 |
+
} finally {
|
| 1227 |
+
card.classList.remove('loading');
|
| 1228 |
+
}
|
| 1229 |
+
}
|
| 1230 |
+
|
| 1231 |
+
try {
|
| 1232 |
+
const cfg = await fetch('api/config').then(r => r.json());
|
| 1233 |
+
renderConfig(cfg);
|
| 1234 |
+
} catch (e) {
|
| 1235 |
+
console.error('Failed to load config:', e);
|
| 1236 |
+
}
|
| 1237 |
+
|
| 1238 |
+
/* ── Run ── */
|
| 1239 |
+
function validateBeforeRun() {
|
| 1240 |
+
const promptVal = promptInput.value.trim();
|
| 1241 |
+
const hasImages = images.length > 0;
|
| 1242 |
+
if (!hasImages && !promptVal) { showToast('Please upload an image and enter a prompt', 'error'); flashPromptError(); return false; }
|
| 1243 |
+
if (!hasImages) { showToast('Please upload at least one image', 'error'); return false; }
|
| 1244 |
+
if (!promptVal) { showToast('Please enter an edit prompt', 'warning'); flashPromptError(); return false; }
|
| 1245 |
+
return true;
|
| 1246 |
+
}
|
| 1247 |
+
|
| 1248 |
+
function setRunningUI(on) {
|
| 1249 |
+
running = on;
|
| 1250 |
+
runBtn.disabled = on;
|
| 1251 |
+
runBtnLabel.textContent = on ? 'Editing…' : 'Edit Image';
|
| 1252 |
+
cancelBtn.style.display = on ? 'flex' : 'none';
|
| 1253 |
+
}
|
| 1254 |
+
|
| 1255 |
+
async function runEdit() {
|
| 1256 |
+
if (running) return;
|
| 1257 |
+
if (!client) { showToast('Backend not connected', 'error'); return; }
|
| 1258 |
+
if (!validateBeforeRun()) return;
|
| 1259 |
+
|
| 1260 |
+
setRunningUI(true);
|
| 1261 |
+
setViewMode('result');
|
| 1262 |
+
showLoader('Submitting to queue…');
|
| 1263 |
+
|
| 1264 |
+
const beforeB64 = images[0] ? images[0].b64 : null;
|
| 1265 |
+
const usedPrompt = promptInput.value;
|
| 1266 |
+
const usedLora = loraSelect.value;
|
| 1267 |
+
|
| 1268 |
+
const payload = {
|
| 1269 |
+
images_b64_json: JSON.stringify(images.map(img => img.b64)),
|
| 1270 |
+
prompt: usedPrompt,
|
| 1271 |
+
lora_adapter: usedLora,
|
| 1272 |
+
seed: parseInt(seedSlider.value) || 0,
|
| 1273 |
+
randomize_seed: document.getElementById('custom-randomize').checked,
|
| 1274 |
+
guidance_scale: parseFloat(document.getElementById('custom-guidance').value),
|
| 1275 |
+
steps: parseInt(document.getElementById('custom-steps').value),
|
| 1276 |
+
};
|
| 1277 |
+
|
| 1278 |
+
try {
|
| 1279 |
+
currentJob = client.submit('/edit_image', payload);
|
| 1280 |
+
for await (const msg of currentJob) {
|
| 1281 |
+
if (msg.type === 'status') {
|
| 1282 |
+
if (msg.status === 'pending') {
|
| 1283 |
+
const pos = (msg.position != null && msg.position >= 0)
|
| 1284 |
+
? 'In queue — position ' + (msg.position + 1) + (msg.queue_size ? ' of ' + msg.queue_size : '')
|
| 1285 |
+
: 'Waiting in queue…';
|
| 1286 |
+
setLoaderProgress(pos, null);
|
| 1287 |
+
setStatus('Queued');
|
| 1288 |
+
} else if (msg.status === 'generating') {
|
| 1289 |
+
setStatus('Processing…');
|
| 1290 |
+
const pd = msg.progress_data;
|
| 1291 |
+
if (pd && pd.length > 0) {
|
| 1292 |
+
const p = pd[pd.length - 1];
|
| 1293 |
+
if (p.index != null && p.length) {
|
| 1294 |
+
const pct = Math.round((p.index / p.length) * 100);
|
| 1295 |
+
setLoaderProgress('Generating… ' + p.index + '/' + p.length + ' (' + pct + '%)', p.index / p.length);
|
| 1296 |
+
} else {
|
| 1297 |
+
setLoaderProgress('Generating…', null);
|
| 1298 |
+
}
|
| 1299 |
+
} else {
|
| 1300 |
+
setLoaderProgress('Generating image…', null);
|
| 1301 |
+
}
|
| 1302 |
+
} else if (msg.status === 'error') {
|
| 1303 |
+
throw new Error(msg.message || 'Generation failed');
|
| 1304 |
+
}
|
| 1305 |
+
} else if (msg.type === 'data') {
|
| 1306 |
+
const out = msg.data && msg.data[0];
|
| 1307 |
+
if (out && out.image) {
|
| 1308 |
+
const entry = { b64: out.image, seed: out.seed, prompt: usedPrompt, lora: usedLora, beforeB64 };
|
| 1309 |
+
showResult(entry);
|
| 1310 |
+
pushHistory(entry);
|
| 1311 |
+
if (out.seed != null) {
|
| 1312 |
+
seedSlider.value = out.seed;
|
| 1313 |
+
seedVal.textContent = out.seed;
|
| 1314 |
+
}
|
| 1315 |
+
hideLoader('Done', 'done');
|
| 1316 |
+
showToast('Image edited successfully', 'info');
|
| 1317 |
+
} else {
|
| 1318 |
+
hideLoader('Done', 'done');
|
| 1319 |
+
}
|
| 1320 |
+
}
|
| 1321 |
+
}
|
| 1322 |
+
} catch (e) {
|
| 1323 |
+
console.error('Edit error:', e);
|
| 1324 |
+
hideLoader('Error', 'error');
|
| 1325 |
+
const msg = (e && e.message) ? e.message : 'Generation failed';
|
| 1326 |
+
showToast(msg.length > 120 ? msg.slice(0, 120) + '…' : msg, 'error');
|
| 1327 |
+
} finally {
|
| 1328 |
+
setRunningUI(false);
|
| 1329 |
+
currentJob = null;
|
| 1330 |
+
}
|
| 1331 |
+
}
|
| 1332 |
+
|
| 1333 |
+
runBtn.addEventListener('click', runEdit);
|
| 1334 |
+
|
| 1335 |
+
cancelBtn.addEventListener('click', async () => {
|
| 1336 |
+
if (currentJob) {
|
| 1337 |
+
try { await currentJob.cancel(); } catch (e) { console.warn('Cancel error:', e); }
|
| 1338 |
+
currentJob = null;
|
| 1339 |
+
}
|
| 1340 |
+
setRunningUI(false);
|
| 1341 |
+
hideLoader('Cancelled');
|
| 1342 |
+
showToast('Generation cancelled', 'warning');
|
| 1343 |
+
});
|
| 1344 |
+
|
| 1345 |
+
document.addEventListener('keydown', (e) => {
|
| 1346 |
+
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
| 1347 |
+
e.preventDefault();
|
| 1348 |
+
runEdit();
|
| 1349 |
+
}
|
| 1350 |
+
});
|
| 1351 |
+
|
| 1352 |
+
renderFilmstrip();
|
| 1353 |
+
renderHistory();
|
| 1354 |
+
updateCounts();
|
| 1355 |
+
renderCanvas();
|
| 1356 |
+
</script>
|
| 1357 |
+
</body>
|
| 1358 |
+
</html>
|