Spaces:
Running
Running
File size: 8,805 Bytes
f575d14 cf1dbe1 4fd7f9a cf1dbe1 bf8e913 cf1dbe1 f575d14 1e9dd50 d1bc90c 1e9dd50 d1bc90c 1e9dd50 be33247 f575d14 be33247 f575d14 ac07e15 cf1dbe1 15704fd cf1dbe1 f575d14 5519c1a cf1dbe1 f575d14 1e9dd50 f575d14 184856d be33247 184856d be33247 184856d bf8e913 184856d bf8e913 184856d bf8e913 184856d 818d649 f575d14 be33247 f0ff983 f575d14 bf8e913 f575d14 1e9dd50 bf8e913 1e9dd50 f575d14 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
import gradio as gr
from convert_url_to_diffusers_sdxl_gr import (
convert_url_to_diffusers_repo,
SCHEDULER_CONFIG_MAP,
)
vaes = [
"",
"https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl.vae.safetensors",
"https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/blob/main/sdxl_vae-fp16fix-blessed.safetensors",
"https://huggingface.co/John6666/safetensors_converting_test/blob/main/xlVAEC_e7.safetensors",
"https://huggingface.co/John6666/safetensors_converting_test/blob/main/xlVAEC_f1.safetensors",
]
clips = [
"",
"openai/clip-vit-large-patch14",
]
loras = [
"",
"https://huggingface.co/SPO-Diffusion-Models/SPO-SDXL_4k-p_10ep_LoRA/blob/main/spo_sdxl_10ep_4k-data_lora_diffusers.safetensors",
"https://huggingface.co/wangfuyun/PCM_Weights/blob/main/sdxl/pcm_sdxl_smallcfg_2step_converted.safetensors",
"https://huggingface.co/wangfuyun/PCM_Weights/blob/main/sdxl/pcm_sdxl_smallcfg_4step_converted.safetensors",
"https://huggingface.co/wangfuyun/PCM_Weights/blob/main/sdxl/pcm_sdxl_smallcfg_8step_converted.safetensors",
"https://huggingface.co/wangfuyun/PCM_Weights/blob/main/sdxl/pcm_sdxl_normalcfg_8step_converted.safetensors",
"https://huggingface.co/wangfuyun/PCM_Weights/blob/main/sdxl/pcm_sdxl_normalcfg_16step_converted.safetensors",
"https://huggingface.co/ByteDance/Hyper-SD/blob/main/Hyper-SDXL-1step-lora.safetensors",
"https://huggingface.co/ByteDance/Hyper-SD/blob/main/Hyper-SDXL-2steps-lora.safetensors",
"https://huggingface.co/ByteDance/Hyper-SD/blob/main/Hyper-SDXL-4steps-lora.safetensors",
"https://huggingface.co/ByteDance/Hyper-SD/blob/main/Hyper-SDXL-8steps-CFG-lora.safetensors",
"https://huggingface.co/ByteDance/Hyper-SD/blob/main/Hyper-SDXL-12steps-CFG-lora.safetensors",
"https://huggingface.co/latent-consistency/lcm-lora-sdxl/blob/main/pytorch_lora_weights.safetensors",
]
schedulers = list(SCHEDULER_CONFIG_MAP.keys())
preset_dict = {
"Default": [True, "", "Euler a", "", 1.0, "", 1.0, "", 1.0, "", 1.0, "", 1.0],
"Bake in standard VAE": [True, "https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl.vae.safetensors",
"Euler a", "", 1.0, "", 1.0, "", 1.0, "", 1.0, "", 1.0],
"Hyper-SDXL / SPO": [True, "https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl.vae.safetensors",
"TCD", "https://huggingface.co/ByteDance/Hyper-SD/blob/main/Hyper-SDXL-8steps-CFG-lora.safetensors", 1.0,
"https://huggingface.co/SPO-Diffusion-Models/SPO-SDXL_4k-p_10ep_LoRA/blob/main/spo_sdxl_10ep_4k-data_lora_diffusers.safetensors",
1.0, "", 1.0, "", 1.0, "", 1.0],
}
def set_presets(preset: str="Default"):
p = []
if preset in preset_dict.keys(): p = preset_dict[preset]
else: p = preset_dict["Default"]
return p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12]
css = """
.title { font-size: 3em; align-items: center; text-align: center; }
.info { align-items: center; text-align: center; }
.block.result { margin: 1em 0; padding: 1em; box-shadow: 0 0 3px 3px #664422, 0 0 3px 2px #664422 inset; border-radius: 6px; background: #665544; }
"""
with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css, delete_cache=(60, 3600)) as demo:
gr.Markdown("# Download and convert any Stable Diffusion XL safetensors to Diffusers and create your repo", elem_classes="title")
gr.Markdown(
f"""
- [A CLI version of this tool (without uploading-related function) is available here](https://huggingface.co/spaces/John6666/sdxl-to-diffusers-v2/tree/main/local).
**⚠️IMPORTANT NOTICE⚠️**<br>
From an information security standpoint, it is dangerous to expose your access token or key to others.
If you do use it, I recommend that you duplicate this space on your own account before doing so.
Keys and tokens could be set to SECRET (HF_TOKEN, CIVITAI_API_KEY) if it's placed in your own space.
It saves you the trouble of typing them in.<br>
<br>
**The steps are the following**:
- Paste a write-access token from [hf.co/settings/tokens](https://huggingface.co/settings/tokens).
- Input a model download url from the Hub or Civitai or other sites.
- If you want to download a model from Civitai, paste a Civitai API Key.
- Input your HF user ID. e.g. 'yourid'.
- Input your new repo name. If empty, auto-complete. e.g. 'newrepo'.
- Set the parameters. If not sure, just use the defaults.
- Click "Submit".
- Patiently wait until the output changes. It takes approximately 2 to 3 minutes (downloading from HF).
"""
)
with gr.Column():
with gr.Group():
dl_url = gr.Textbox(label="URL to download", placeholder="https://huggingface.co/bluepen5805/blue_pencil-XL/blob/main/blue_pencil-XL-v7.0.0.safetensors", value="", max_lines=1)
with gr.Row():
hf_user = gr.Textbox(label="Your HF user ID", placeholder="username", value="", max_lines=1)
hf_repo = gr.Textbox(label="New repo name", placeholder="reponame", info="If empty, auto-complete", value="", max_lines=1)
with gr.Row():
hf_token = gr.Textbox(label="Your HF write token", placeholder="hf_...", value="", max_lines=1)
civitai_key = gr.Textbox(label="Your Civitai API Key (Optional)", info="If you download model from Civitai...", placeholder="", value="", max_lines=1)
with gr.Row():
is_upload_sf = gr.Checkbox(label="Upload single safetensors file into new repo", value=False)
is_private = gr.Checkbox(label="Create private repo", value=True)
is_overwrite = gr.Checkbox(label="Overwrite repo", value=False)
presets = gr.Radio(label="Presets", choices=list(preset_dict.keys()), value="Default")
with gr.Accordion("Advanced settings", open=False):
dtype = gr.Radio(label="Output data type", choices=["fp16", "fp32", "bf16", "fp8", "default"], value="fp16")
with gr.Row():
vae = gr.Dropdown(label="VAE", choices=vaes, value="", allow_custom_value=True)
clip = gr.Dropdown(label="CLIP", choices=clips, value="", allow_custom_value=True)
scheduler = gr.Dropdown(label="Scheduler (Sampler)", choices=schedulers, value="Euler a")
with gr.Row():
with gr.Column():
lora1 = gr.Dropdown(label="LoRA1", choices=loras, value="", allow_custom_value=True, min_width=320)
lora1s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA1 weight scale")
with gr.Column():
lora2 = gr.Dropdown(label="LoRA2", choices=loras, value="", allow_custom_value=True, min_width=320)
lora2s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA2 weight scale")
with gr.Column():
lora3 = gr.Dropdown(label="LoRA3", choices=loras, value="", allow_custom_value=True, min_width=320)
lora3s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA3 weight scale")
with gr.Column():
lora4 = gr.Dropdown(label="LoRA4", choices=loras, value="", allow_custom_value=True, min_width=320)
lora4s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA4 weight scale")
with gr.Column():
lora5 = gr.Dropdown(label="LoRA5", choices=loras, value="", allow_custom_value=True, min_width=320)
lora5s = gr.Slider(minimum=-2, maximum=2, step=0.01, value=1.00, label="LoRA5 weight scale")
run_button = gr.Button(value="Submit")
repo_urls = gr.CheckboxGroup(visible=False, choices=[], value=None)
output_md = gr.Markdown(label="Output", value="<br><br>", elem_classes="result")
gr.DuplicateButton(value="Duplicate Space")
gr.on(
triggers=[run_button.click],
fn=convert_url_to_diffusers_repo,
inputs=[dl_url, hf_user, hf_repo, hf_token, civitai_key, is_private, is_overwrite, is_upload_sf, repo_urls, dtype, vae, clip, scheduler,
lora1, lora1s, lora2, lora2s, lora3, lora3s, lora4, lora4s, lora5, lora5s],
outputs=[repo_urls, output_md],
)
presets.change(
fn=set_presets,
inputs=[presets],
outputs=[dtype, vae, scheduler, lora1, lora1s, lora2, lora2s, lora3, lora3s, lora4, lora4s, lora5, lora5s],
queue=False,
)
demo.queue()
demo.launch()
|