Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,8 @@ from stablepy import (
|
|
24 |
import time
|
25 |
# import urllib.parse
|
26 |
|
|
|
|
|
27 |
# - **Download SD 1.5 Models**
|
28 |
download_model = "https://civitai.com/api/download/models/574369, https://huggingface.co/TechnoByte/MilkyWonderland/resolve/main/milkyWonderland_v40.safetensors"
|
29 |
# - **Download VAEs**
|
@@ -36,6 +38,8 @@ load_diffusers_format_model = [
|
|
36 |
'John6666/blue-pencil-flux1-v021-fp8-flux',
|
37 |
'John6666/wai-ani-flux-v10forfp8-fp8-flux',
|
38 |
'John6666/xe-anime-flux-v04-fp8-flux',
|
|
|
|
|
39 |
'cagliostrolab/animagine-xl-3.1',
|
40 |
'John6666/epicrealism-xl-v8kiss-sdxl',
|
41 |
'misri/epicrealismXL_v7FinalDestination',
|
@@ -52,12 +56,24 @@ load_diffusers_format_model = [
|
|
52 |
'WhiteAiZ/autismmixSDXL_autismmixConfetti_diffusers',
|
53 |
'kitty7779/ponyDiffusionV6XL',
|
54 |
'GraydientPlatformAPI/aniverse-pony',
|
|
|
|
|
55 |
'John6666/mistoon-anime-ponyalpha-sdxl',
|
|
|
|
|
56 |
'John6666/ebara-mfcg-pony-mix-v12-sdxl',
|
57 |
'John6666/t-ponynai3-v51-sdxl',
|
|
|
|
|
58 |
'John6666/mala-anime-mix-nsfw-pony-xl-v5-sdxl',
|
59 |
'John6666/wai-real-mix-v11-sdxl',
|
|
|
|
|
|
|
|
|
|
|
60 |
'John6666/cyberrealistic-pony-v63-sdxl',
|
|
|
61 |
'GraydientPlatformAPI/realcartoon-pony-diffusion',
|
62 |
'John6666/nova-anime-xl-pony-v5-sdxl',
|
63 |
'John6666/autismmix-sdxl-autismmix-pony-sdxl',
|
@@ -373,18 +389,21 @@ def extract_parameters(input_string):
|
|
373 |
input_string = input_string.replace("\n", "")
|
374 |
|
375 |
if "Negative prompt:" not in input_string:
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
379 |
|
380 |
parm = input_string.split("Negative prompt:")
|
381 |
-
parameters["prompt"] = parm[0]
|
382 |
if "Steps:" not in parm[1]:
|
383 |
print("Steps not detected")
|
384 |
-
parameters["neg_prompt"] = parm[1]
|
385 |
return parameters
|
386 |
parm = parm[1].split("Steps:")
|
387 |
-
parameters["neg_prompt"] = parm[0]
|
388 |
input_string = "Steps:" + parm[1]
|
389 |
|
390 |
# Extracting Steps
|
@@ -971,35 +990,38 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
971 |
for key, val in parameters.items():
|
972 |
# print(val)
|
973 |
if key in valid_keys:
|
974 |
-
|
975 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
continue
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
if key == "prompt":
|
983 |
-
if ">" in val and "<" in val:
|
984 |
-
val = re.sub(r'<[^>]+>', '', val)
|
985 |
-
print("Removed LoRA written in the prompt")
|
986 |
-
if key in ["prompt", "neg_prompt"]:
|
987 |
-
val = val.strip()
|
988 |
-
if key in ["Steps", "width", "height", "Seed"]:
|
989 |
-
val = int(val)
|
990 |
-
if key == "scale":
|
991 |
-
val = float(val)
|
992 |
-
if key == "Model":
|
993 |
-
filtered_models = [m for m in model_list if val in m]
|
994 |
-
if filtered_models:
|
995 |
-
val = filtered_models[0]
|
996 |
-
else:
|
997 |
-
val = name_model
|
998 |
-
if key == "Seed":
|
999 |
-
continue
|
1000 |
-
valid_receptors[key] = gr.update(value=val)
|
1001 |
-
# print(val, type(val))
|
1002 |
-
# print(valid_receptors)
|
1003 |
return [value for value in valid_receptors.values()]
|
1004 |
|
1005 |
set_params_gui.click(
|
@@ -1272,7 +1294,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1272 |
[
|
1273 |
"a digital illustration of a movie poster titled 'Finding Emo', finding nemo parody poster, featuring a depressed cartoon clownfish with black emo hair, eyeliner, and piercings, bored expression, swimming in a dark underwater scene, in the background, movie title in a dripping, grungy font, moody blue and purple color palette",
|
1274 |
"",
|
1275 |
-
|
1276 |
3.5,
|
1277 |
-1,
|
1278 |
"None",
|
@@ -1456,7 +1478,6 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1456 |
|
1457 |
with gr.Row():
|
1458 |
with gr.Column(scale=2):
|
1459 |
-
# image_base = gr.ImageEditor(label="Base image", show_label=True, brush=gr.Brush(colors=["#000000"]))
|
1460 |
image_base = gr.ImageEditor(
|
1461 |
sources=["upload", "clipboard"],
|
1462 |
# crop_size="1:1",
|
@@ -1488,6 +1509,35 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
1488 |
return img_source, img_result
|
1489 |
btn_send.click(send_img, [img_source, img_result], [image_control, image_mask_gui])
|
1490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1491 |
generate_button.click(
|
1492 |
fn=sd_gen.load_new_model,
|
1493 |
inputs=[
|
|
|
24 |
import time
|
25 |
# import urllib.parse
|
26 |
|
27 |
+
print(os.getenv("SPACES_ZERO_GPU"))
|
28 |
+
|
29 |
# - **Download SD 1.5 Models**
|
30 |
download_model = "https://civitai.com/api/download/models/574369, https://huggingface.co/TechnoByte/MilkyWonderland/resolve/main/milkyWonderland_v40.safetensors"
|
31 |
# - **Download VAEs**
|
|
|
38 |
'John6666/blue-pencil-flux1-v021-fp8-flux',
|
39 |
'John6666/wai-ani-flux-v10forfp8-fp8-flux',
|
40 |
'John6666/xe-anime-flux-v04-fp8-flux',
|
41 |
+
'John6666/lyh-anime-flux-v2a1-fp8-flux',
|
42 |
+
'John6666/carnival-unchained-v10-fp8-flux',
|
43 |
'cagliostrolab/animagine-xl-3.1',
|
44 |
'John6666/epicrealism-xl-v8kiss-sdxl',
|
45 |
'misri/epicrealismXL_v7FinalDestination',
|
|
|
56 |
'WhiteAiZ/autismmixSDXL_autismmixConfetti_diffusers',
|
57 |
'kitty7779/ponyDiffusionV6XL',
|
58 |
'GraydientPlatformAPI/aniverse-pony',
|
59 |
+
'John6666/ras-real-anime-screencap-v1-sdxl',
|
60 |
+
'John6666/duchaiten-pony-xl-no-score-v60-sdxl',
|
61 |
'John6666/mistoon-anime-ponyalpha-sdxl',
|
62 |
+
'John6666/3x3x3mixxl-v2-sdxl',
|
63 |
+
'John6666/3x3x3mixxl-3dv01-sdxl',
|
64 |
'John6666/ebara-mfcg-pony-mix-v12-sdxl',
|
65 |
'John6666/t-ponynai3-v51-sdxl',
|
66 |
+
'John6666/t-ponynai3-v65-sdxl',
|
67 |
+
'John6666/prefect-pony-xl-v3-sdxl',
|
68 |
'John6666/mala-anime-mix-nsfw-pony-xl-v5-sdxl',
|
69 |
'John6666/wai-real-mix-v11-sdxl',
|
70 |
+
'John6666/wai-c-v6-sdxl',
|
71 |
+
'John6666/iniverse-mix-xl-sfwnsfw-pony-guofeng-v43-sdxl',
|
72 |
+
'John6666/photo-realistic-pony-v5-sdxl',
|
73 |
+
'John6666/pony-realism-v21main-sdxl',
|
74 |
+
'John6666/pony-realism-v22main-sdxl',
|
75 |
'John6666/cyberrealistic-pony-v63-sdxl',
|
76 |
+
'John6666/cyberrealistic-pony-v64-sdxl',
|
77 |
'GraydientPlatformAPI/realcartoon-pony-diffusion',
|
78 |
'John6666/nova-anime-xl-pony-v5-sdxl',
|
79 |
'John6666/autismmix-sdxl-autismmix-pony-sdxl',
|
|
|
389 |
input_string = input_string.replace("\n", "")
|
390 |
|
391 |
if "Negative prompt:" not in input_string:
|
392 |
+
if "Steps:" in input_string:
|
393 |
+
input_string = input_string.replace("Steps:", "Negative prompt: Steps:")
|
394 |
+
else:
|
395 |
+
print("Invalid metadata")
|
396 |
+
parameters["prompt"] = input_string
|
397 |
+
return parameters
|
398 |
|
399 |
parm = input_string.split("Negative prompt:")
|
400 |
+
parameters["prompt"] = parm[0].strip()
|
401 |
if "Steps:" not in parm[1]:
|
402 |
print("Steps not detected")
|
403 |
+
parameters["neg_prompt"] = parm[1].strip()
|
404 |
return parameters
|
405 |
parm = parm[1].split("Steps:")
|
406 |
+
parameters["neg_prompt"] = parm[0].strip()
|
407 |
input_string = "Steps:" + parm[1]
|
408 |
|
409 |
# Extracting Steps
|
|
|
990 |
for key, val in parameters.items():
|
991 |
# print(val)
|
992 |
if key in valid_keys:
|
993 |
+
try:
|
994 |
+
if key == "Sampler":
|
995 |
+
if val not in scheduler_names:
|
996 |
+
continue
|
997 |
+
elif key == "skip":
|
998 |
+
if "," in str(val):
|
999 |
+
val = val.replace(",", "")
|
1000 |
+
if int(val) >= 2:
|
1001 |
+
val = True
|
1002 |
+
if key == "prompt":
|
1003 |
+
if ">" in val and "<" in val:
|
1004 |
+
val = re.sub(r'<[^>]+>', '', val)
|
1005 |
+
print("Removed LoRA written in the prompt")
|
1006 |
+
if key in ["prompt", "neg_prompt"]:
|
1007 |
+
val = re.sub(r'\s+', ' ', re.sub(r',+', ',', val)).strip()
|
1008 |
+
if key in ["Steps", "width", "height", "Seed"]:
|
1009 |
+
val = int(val)
|
1010 |
+
if key == "scale":
|
1011 |
+
val = float(val)
|
1012 |
+
if key == "Model":
|
1013 |
+
filtered_models = [m for m in model_list if val in m]
|
1014 |
+
if filtered_models:
|
1015 |
+
val = filtered_models[0]
|
1016 |
+
else:
|
1017 |
+
val = name_model
|
1018 |
+
if key == "Seed":
|
1019 |
continue
|
1020 |
+
valid_receptors[key] = gr.update(value=val)
|
1021 |
+
# print(val, type(val))
|
1022 |
+
# print(valid_receptors)
|
1023 |
+
except Exception as e:
|
1024 |
+
print(str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
return [value for value in valid_receptors.values()]
|
1026 |
|
1027 |
set_params_gui.click(
|
|
|
1294 |
[
|
1295 |
"a digital illustration of a movie poster titled 'Finding Emo', finding nemo parody poster, featuring a depressed cartoon clownfish with black emo hair, eyeliner, and piercings, bored expression, swimming in a dark underwater scene, in the background, movie title in a dripping, grungy font, moody blue and purple color palette",
|
1296 |
"",
|
1297 |
+
24,
|
1298 |
3.5,
|
1299 |
-1,
|
1300 |
"None",
|
|
|
1478 |
|
1479 |
with gr.Row():
|
1480 |
with gr.Column(scale=2):
|
|
|
1481 |
image_base = gr.ImageEditor(
|
1482 |
sources=["upload", "clipboard"],
|
1483 |
# crop_size="1:1",
|
|
|
1509 |
return img_source, img_result
|
1510 |
btn_send.click(send_img, [img_source, img_result], [image_control, image_mask_gui])
|
1511 |
|
1512 |
+
with gr.Tab("PNG Info"):
|
1513 |
+
def extract_exif_data(image):
|
1514 |
+
if image is None: return ""
|
1515 |
+
|
1516 |
+
try:
|
1517 |
+
metadata_keys = ['parameters', 'metadata', 'prompt', 'Comment']
|
1518 |
+
|
1519 |
+
for key in metadata_keys:
|
1520 |
+
if key in image.info:
|
1521 |
+
return image.info[key]
|
1522 |
+
|
1523 |
+
return str(image.info)
|
1524 |
+
|
1525 |
+
except Exception as e:
|
1526 |
+
return f"Error extracting metadata: {str(e)}"
|
1527 |
+
|
1528 |
+
with gr.Row():
|
1529 |
+
with gr.Column():
|
1530 |
+
image_metadata = gr.Image(label="Image with metadata", type="pil", sources=["upload"])
|
1531 |
+
|
1532 |
+
with gr.Column():
|
1533 |
+
result_metadata = gr.Textbox(label="Metadata", show_label=True, show_copy_button=True, interactive=False, container=True, max_lines=99)
|
1534 |
+
|
1535 |
+
image_metadata.change(
|
1536 |
+
fn=extract_exif_data,
|
1537 |
+
inputs=[image_metadata],
|
1538 |
+
outputs=[result_metadata],
|
1539 |
+
)
|
1540 |
+
|
1541 |
generate_button.click(
|
1542 |
fn=sd_gen.load_new_model,
|
1543 |
inputs=[
|