Spaces:
Running
on
Zero
Running
on
Zero
add config.py
Browse files
app.py
CHANGED
|
@@ -23,6 +23,10 @@ from stablepy import (
|
|
| 23 |
SDXL_TASKS,
|
| 24 |
)
|
| 25 |
import urllib.parse
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
preprocessor_controlnet = {
|
| 28 |
"openpose": [
|
|
@@ -139,8 +143,14 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
| 139 |
|
| 140 |
|
| 141 |
def get_model_list(directory_path):
|
| 142 |
-
model_list = []
|
| 143 |
-
valid_extensions = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
for filename in os.listdir(directory_path):
|
| 146 |
if os.path.splitext(filename)[1] in valid_extensions:
|
|
@@ -174,6 +184,7 @@ os.makedirs(directory_vaes, exist_ok=True)
|
|
| 174 |
# - **Download SD 1.5 Models**
|
| 175 |
download_model = (
|
| 176 |
"https://civitai.com/api/download/models/597138, "
|
|
|
|
| 177 |
"https://civitai.com/api/download/models/609052, "
|
| 178 |
"https://civitai.com/api/download/models/5036?type=Model&format=SafeTensor&size=full&fp=fp16, "
|
| 179 |
"https://civitai.com/api/download/models/574369, "
|
|
@@ -191,6 +202,7 @@ download_vae = (
|
|
| 191 |
)
|
| 192 |
# - **Download LoRAs**
|
| 193 |
download_lora = (
|
|
|
|
| 194 |
"https://civitai.com/api/download/models/50503, "
|
| 195 |
"https://civitai.com/api/download/models/133160, "
|
| 196 |
"https://civitai.com/api/download/models/29332, "
|
|
@@ -571,11 +583,11 @@ class GuiSD:
|
|
| 571 |
|
| 572 |
task = task_stablepy[task]
|
| 573 |
|
| 574 |
-
params_ip_img = []
|
| 575 |
-
params_ip_msk = []
|
| 576 |
-
params_ip_model = []
|
| 577 |
-
params_ip_mode = []
|
| 578 |
-
params_ip_scale = []
|
| 579 |
|
| 580 |
all_adapters = [
|
| 581 |
(image_ip1, mask_ip1, model_ip1, mode_ip1, scale_ip1),
|
|
@@ -750,8 +762,11 @@ class GuiSD:
|
|
| 750 |
|
| 751 |
random_number = random.randint(1, 100)
|
| 752 |
if random_number < 25 and num_images < 3:
|
| 753 |
-
if not upscaler_model and
|
| 754 |
-
|
|
|
|
|
|
|
|
|
|
| 755 |
num_images *= 2
|
| 756 |
pipe_params["num_images"] = num_images
|
| 757 |
gr.Info("Num images x 2 🎉")
|
|
@@ -801,7 +816,8 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 801 |
gr.Markdown("# 🧩 (Ivan) DiffuseCraft")
|
| 802 |
gr.Markdown(
|
| 803 |
f"""
|
| 804 |
-
### This demo uses [diffusers](https://github.com/huggingface/diffusers)
|
|
|
|
| 805 |
"""
|
| 806 |
)
|
| 807 |
with gr.Tab("Generation"):
|
|
@@ -810,8 +826,12 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 810 |
with gr.Column(scale=2):
|
| 811 |
|
| 812 |
task_gui = gr.Dropdown(label="Task", choices=sdxl_task, value=task_model_list[0])
|
| 813 |
-
model_name_gui = gr.Dropdown(
|
| 814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
prompt_gui = gr.Textbox(lines=5, placeholder="Enter prompt", label="Prompt")
|
| 816 |
neg_prompt_gui = gr.Textbox(lines=3, placeholder="Enter Neg prompt", label="Negative prompt")
|
| 817 |
with gr.Row(equal_height=False):
|
|
@@ -844,9 +864,21 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 844 |
actual_task_info = gr.HTML()
|
| 845 |
|
| 846 |
with gr.Column(scale=1):
|
| 847 |
-
steps_gui = gr.Slider(
|
| 848 |
-
|
| 849 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
|
| 851 |
img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
|
| 852 |
seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
|
|
@@ -930,39 +962,81 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 930 |
run_set_random_seed, [], seed_gui
|
| 931 |
)
|
| 932 |
|
| 933 |
-
num_images_gui = gr.Slider(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
prompt_s_options = [
|
| 935 |
-
("Compel format: (word)weight", "Compel"),
|
| 936 |
("Classic format: (word:weight)", "Classic"),
|
|
|
|
| 937 |
("Classic-original format: (word:weight)", "Classic-original"),
|
| 938 |
("Classic-no_norm format: (word:weight)", "Classic-no_norm"),
|
| 939 |
("Classic-ignore", "Classic-ignore"),
|
| 940 |
("None", "None"),
|
| 941 |
]
|
| 942 |
-
prompt_syntax_gui = gr.Dropdown(
|
| 943 |
-
|
| 944 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 945 |
|
| 946 |
with gr.Accordion("Hires fix", open=False, visible=True):
|
| 947 |
|
| 948 |
upscaler_keys = list(upscaler_dict_gui.keys())
|
| 949 |
|
| 950 |
-
upscaler_model_path_gui = gr.Dropdown(
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 954 |
esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
|
| 955 |
esrgan_tile_overlap_gui = gr.Slider(minimum=1, maximum=200, step=1, value=10,
|
| 956 |
label="ESRGAN Tile Overlap")
|
| 957 |
-
hires_steps_gui = gr.Slider(
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
| 965 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 966 |
|
| 967 |
with gr.Accordion("LoRA", open=False, visible=True):
|
| 968 |
lora1_gui = gr.Dropdown(label="Lora1", choices=lora_model_list)
|
|
@@ -1177,10 +1251,28 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 1177 |
gr.Examples(
|
| 1178 |
examples=[
|
| 1179 |
[
|
| 1180 |
-
"
|
| 1181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1182 |
1,
|
| 1183 |
-
|
| 1184 |
7.5,
|
| 1185 |
True,
|
| 1186 |
-1,
|
|
@@ -1194,7 +1286,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 1194 |
1.0,
|
| 1195 |
None,
|
| 1196 |
1.0,
|
| 1197 |
-
"
|
| 1198 |
1152,
|
| 1199 |
896,
|
| 1200 |
"cagliostrolab/animagine-xl-3.1",
|
|
@@ -1323,7 +1415,7 @@ with gr.Blocks(theme="NoCrypt/miku", css=CSS) as app:
|
|
| 1323 |
1.0,
|
| 1324 |
None,
|
| 1325 |
1.0,
|
| 1326 |
-
"
|
| 1327 |
1024,
|
| 1328 |
1024,
|
| 1329 |
"misri/juggernautXL_juggernautX",
|
|
|
|
| 23 |
SDXL_TASKS,
|
| 24 |
)
|
| 25 |
import urllib.parse
|
| 26 |
+
from config import (
|
| 27 |
+
MINIMUM_IMAGE_NUMBER,
|
| 28 |
+
MAXIMUM_IMAGE_NUMBER
|
| 29 |
+
)
|
| 30 |
|
| 31 |
preprocessor_controlnet = {
|
| 32 |
"openpose": [
|
|
|
|
| 143 |
|
| 144 |
|
| 145 |
def get_model_list(directory_path):
|
| 146 |
+
model_list: list = []
|
| 147 |
+
valid_extensions = {
|
| 148 |
+
'.ckpt',
|
| 149 |
+
'.pt',
|
| 150 |
+
'.pth',
|
| 151 |
+
'.safetensors',
|
| 152 |
+
'.bin'
|
| 153 |
+
}
|
| 154 |
|
| 155 |
for filename in os.listdir(directory_path):
|
| 156 |
if os.path.splitext(filename)[1] in valid_extensions:
|
|
|
|
| 184 |
# - **Download SD 1.5 Models**
|
| 185 |
download_model = (
|
| 186 |
"https://civitai.com/api/download/models/597138, "
|
| 187 |
+
"https://civitai.com/api/download/models/469243, "
|
| 188 |
"https://civitai.com/api/download/models/609052, "
|
| 189 |
"https://civitai.com/api/download/models/5036?type=Model&format=SafeTensor&size=full&fp=fp16, "
|
| 190 |
"https://civitai.com/api/download/models/574369, "
|
|
|
|
| 202 |
)
|
| 203 |
# - **Download LoRAs**
|
| 204 |
download_lora = (
|
| 205 |
+
"https://civitai.com/api/download/models/423719, "
|
| 206 |
"https://civitai.com/api/download/models/50503, "
|
| 207 |
"https://civitai.com/api/download/models/133160, "
|
| 208 |
"https://civitai.com/api/download/models/29332, "
|
|
|
|
| 583 |
|
| 584 |
task = task_stablepy[task]
|
| 585 |
|
| 586 |
+
params_ip_img: list = []
|
| 587 |
+
params_ip_msk: list = []
|
| 588 |
+
params_ip_model: list = []
|
| 589 |
+
params_ip_mode: list = []
|
| 590 |
+
params_ip_scale: list = []
|
| 591 |
|
| 592 |
all_adapters = [
|
| 593 |
(image_ip1, mask_ip1, model_ip1, mode_ip1, scale_ip1),
|
|
|
|
| 762 |
|
| 763 |
random_number = random.randint(1, 100)
|
| 764 |
if random_number < 25 and num_images < 3:
|
| 765 |
+
if (not upscaler_model and
|
| 766 |
+
steps < 45 and
|
| 767 |
+
task in ["txt2img", "img2img"] and
|
| 768 |
+
not adetailer_active_a and
|
| 769 |
+
not adetailer_active_b):
|
| 770 |
num_images *= 2
|
| 771 |
pipe_params["num_images"] = num_images
|
| 772 |
gr.Info("Num images x 2 🎉")
|
|
|
|
| 816 |
gr.Markdown("# 🧩 (Ivan) DiffuseCraft")
|
| 817 |
gr.Markdown(
|
| 818 |
f"""
|
| 819 |
+
### This demo uses [diffusers](https://github.com/huggingface/diffusers) \
|
| 820 |
+
to perform different tasks in image generation.
|
| 821 |
"""
|
| 822 |
)
|
| 823 |
with gr.Tab("Generation"):
|
|
|
|
| 826 |
with gr.Column(scale=2):
|
| 827 |
|
| 828 |
task_gui = gr.Dropdown(label="Task", choices=sdxl_task, value=task_model_list[0])
|
| 829 |
+
model_name_gui = gr.Dropdown(
|
| 830 |
+
label="Model",
|
| 831 |
+
choices=model_list,
|
| 832 |
+
value=model_list[0],
|
| 833 |
+
allow_custom_value=True
|
| 834 |
+
)
|
| 835 |
prompt_gui = gr.Textbox(lines=5, placeholder="Enter prompt", label="Prompt")
|
| 836 |
neg_prompt_gui = gr.Textbox(lines=3, placeholder="Enter Neg prompt", label="Negative prompt")
|
| 837 |
with gr.Row(equal_height=False):
|
|
|
|
| 864 |
actual_task_info = gr.HTML()
|
| 865 |
|
| 866 |
with gr.Column(scale=1):
|
| 867 |
+
steps_gui = gr.Slider(
|
| 868 |
+
minimum=1,
|
| 869 |
+
maximum=100,
|
| 870 |
+
step=1,
|
| 871 |
+
value=43,
|
| 872 |
+
label="Steps"
|
| 873 |
+
)
|
| 874 |
+
cfg_gui = gr.Slider(
|
| 875 |
+
minimum=0,
|
| 876 |
+
maximum=30,
|
| 877 |
+
step=0.5,
|
| 878 |
+
value=7.5,
|
| 879 |
+
label="CFG"
|
| 880 |
+
)
|
| 881 |
+
sampler_gui = gr.Dropdown(label="Sampler", choices=scheduler_names, value="DPM++ 2M Karras")
|
| 882 |
img_width_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Width")
|
| 883 |
img_height_gui = gr.Slider(minimum=64, maximum=4096, step=8, value=1024, label="Img Height")
|
| 884 |
seed_gui = gr.Number(minimum=-1, maximum=9999999999, value=-1, label="Seed")
|
|
|
|
| 962 |
run_set_random_seed, [], seed_gui
|
| 963 |
)
|
| 964 |
|
| 965 |
+
num_images_gui = gr.Slider(
|
| 966 |
+
minimum=MINIMUM_IMAGE_NUMBER,
|
| 967 |
+
maximum=MAXIMUM_IMAGE_NUMBER,
|
| 968 |
+
step=1,
|
| 969 |
+
value=1,
|
| 970 |
+
label="Images"
|
| 971 |
+
)
|
| 972 |
prompt_s_options = [
|
|
|
|
| 973 |
("Classic format: (word:weight)", "Classic"),
|
| 974 |
+
("Compel format: (word)weight", "Compel"),
|
| 975 |
("Classic-original format: (word:weight)", "Classic-original"),
|
| 976 |
("Classic-no_norm format: (word:weight)", "Classic-no_norm"),
|
| 977 |
("Classic-ignore", "Classic-ignore"),
|
| 978 |
("None", "None"),
|
| 979 |
]
|
| 980 |
+
prompt_syntax_gui = gr.Dropdown(
|
| 981 |
+
label="Prompt Syntax",
|
| 982 |
+
choices=prompt_s_options,
|
| 983 |
+
value=prompt_s_options[0][1]
|
| 984 |
+
)
|
| 985 |
+
|
| 986 |
+
vae_model_gui = gr.Dropdown(
|
| 987 |
+
label="VAE Model",
|
| 988 |
+
choices=vae_model_list
|
| 989 |
+
)
|
| 990 |
|
| 991 |
with gr.Accordion("Hires fix", open=False, visible=True):
|
| 992 |
|
| 993 |
upscaler_keys = list(upscaler_dict_gui.keys())
|
| 994 |
|
| 995 |
+
upscaler_model_path_gui = gr.Dropdown(
|
| 996 |
+
label="Upscaler",
|
| 997 |
+
choices=upscaler_keys,
|
| 998 |
+
value=upscaler_keys[0]
|
| 999 |
+
)
|
| 1000 |
+
|
| 1001 |
+
upscaler_increases_size_gui = gr.Slider(
|
| 1002 |
+
minimum=1.1,
|
| 1003 |
+
maximum=6.,
|
| 1004 |
+
step=0.1,
|
| 1005 |
+
value=1.4,
|
| 1006 |
+
label="Upscale by"
|
| 1007 |
+
)
|
| 1008 |
esrgan_tile_gui = gr.Slider(minimum=0, value=100, maximum=500, step=1, label="ESRGAN Tile")
|
| 1009 |
esrgan_tile_overlap_gui = gr.Slider(minimum=1, maximum=200, step=1, value=10,
|
| 1010 |
label="ESRGAN Tile Overlap")
|
| 1011 |
+
hires_steps_gui = gr.Slider(
|
| 1012 |
+
minimum=0,
|
| 1013 |
+
value=30,
|
| 1014 |
+
maximum=100,
|
| 1015 |
+
step=1,
|
| 1016 |
+
label="Hires Steps"
|
| 1017 |
+
)
|
| 1018 |
+
hires_denoising_strength_gui = gr.Slider(
|
| 1019 |
+
minimum=0.1,
|
| 1020 |
+
maximum=1.0,
|
| 1021 |
+
step=0.01,
|
| 1022 |
+
value=0.55,
|
| 1023 |
+
label="Hires Denoising Strength"
|
| 1024 |
+
)
|
| 1025 |
+
hires_sampler_gui = gr.Dropdown(
|
| 1026 |
+
label="Hires Sampler",
|
| 1027 |
+
choices=["Use same sampler"] + scheduler_names[:-1],
|
| 1028 |
+
value="Use same sampler"
|
| 1029 |
+
)
|
| 1030 |
+
hires_prompt_gui = gr.Textbox(
|
| 1031 |
+
label="Hires Prompt",
|
| 1032 |
+
placeholder="Main prompt will be use",
|
| 1033 |
+
lines=3
|
| 1034 |
+
)
|
| 1035 |
+
hires_negative_prompt_gui = gr.Textbox(
|
| 1036 |
+
label="Hires Negative Prompt",
|
| 1037 |
+
placeholder="Main negative prompt will be use",
|
| 1038 |
+
lines=3
|
| 1039 |
+
)
|
| 1040 |
|
| 1041 |
with gr.Accordion("LoRA", open=False, visible=True):
|
| 1042 |
lora1_gui = gr.Dropdown(label="Lora1", choices=lora_model_list)
|
|
|
|
| 1251 |
gr.Examples(
|
| 1252 |
examples=[
|
| 1253 |
[
|
| 1254 |
+
"""
|
| 1255 |
+
1girl, loli, serious, cocky, sporty, basketball jersey, lakers, basketball, half body, (basketball court), sweaty, dribble, high detailed, sunny, day light,
|
| 1256 |
+
score_9, score_8_up, score_7_up, very aesthetic,
|
| 1257 |
+
layered, white hair, featuring soft waves and a slight outward curl at the ends, parted in the middle, (short hair),
|
| 1258 |
+
red glowing eyes, beautiful hazel red eyes, highly detailed eyes, thin eyebrows, detailed black eyebrows,
|
| 1259 |
+
long eyelashes,
|
| 1260 |
+
detailed kornea,
|
| 1261 |
+
fisheye,
|
| 1262 |
+
blush,
|
| 1263 |
+
parted lips, gorgeous lips, pink thin lips,
|
| 1264 |
+
detailed ear, human ears, human ear, highly detailed ears, highly detailed ear, detailed ears,
|
| 1265 |
+
perfect anatomy,
|
| 1266 |
+
|
| 1267 |
+
five fingers,
|
| 1268 |
+
two hands,
|
| 1269 |
+
short girl, narrow body, detailed face, petite,
|
| 1270 |
+
medium boobs,
|
| 1271 |
+
armpits, (naval),
|
| 1272 |
+
""",
|
| 1273 |
+
"(EasyNegative:1.05), easynegative, bad_prompt_version2, (poorly rendered), ugly, disfigured, cross eyed, cloned face, bad symmetry, bad anatomy, low quality, blurry, text, watermark, logo, signature, jpeg, artifacts, monochrome, paintings, oil, (hands:1.15), European Woman, woman, noise, dark skin, (3d), By bad artist -neg,bhands-neg, canvas frame,",
|
| 1274 |
1,
|
| 1275 |
+
43,
|
| 1276 |
7.5,
|
| 1277 |
True,
|
| 1278 |
-1,
|
|
|
|
| 1286 |
1.0,
|
| 1287 |
None,
|
| 1288 |
1.0,
|
| 1289 |
+
"DPM++ 2M Karras",
|
| 1290 |
1152,
|
| 1291 |
896,
|
| 1292 |
"cagliostrolab/animagine-xl-3.1",
|
|
|
|
| 1415 |
1.0,
|
| 1416 |
None,
|
| 1417 |
1.0,
|
| 1418 |
+
"DPM++ 2M Karras",
|
| 1419 |
1024,
|
| 1420 |
1024,
|
| 1421 |
"misri/juggernautXL_juggernautX",
|
config.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MINIMUM_IMAGE_NUMBER = 1
|
| 2 |
+
MAXIMUM_IMAGE_NUMBER = 6
|