Spaces:
Running
on
Zero
Running
on
Zero
silveroxides
commited on
Commit
•
4a757d2
1
Parent(s):
4138dc4
Update app.py
Browse files
app.py
CHANGED
@@ -63,60 +63,60 @@ download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealES
|
|
63 |
download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth?download=true", "models/upscalers/", "RealESRGAN_x4.pth")
|
64 |
|
65 |
# Download the model files
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
# Load the models
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
vae=
|
78 |
torch_dtype=torch.float16,
|
79 |
use_safetensors=True,
|
80 |
)
|
81 |
-
|
82 |
-
|
83 |
-
vae=
|
84 |
torch_dtype=torch.float16,
|
85 |
use_safetensors=True,
|
86 |
)
|
87 |
-
|
88 |
-
|
89 |
-
vae=
|
90 |
torch_dtype=torch.float16,
|
91 |
use_safetensors=True,
|
92 |
)
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
|
102 |
# Define samplers
|
103 |
samplers = {
|
104 |
-
"Euler a": EulerAncestralDiscreteScheduler.from_config(
|
105 |
-
"DPM++ SDE Karras": DPMSolverSDEScheduler.from_config(
|
106 |
-
"Heun": HeunDiscreteScheduler.from_config(
|
107 |
# New samplers
|
108 |
-
"DPM++ 2M SDE Karras": DPMSolverMultistepScheduler.from_config(
|
109 |
-
"DPM++ 2M": DPMSolverMultistepScheduler.from_config(
|
110 |
-
"DDIM": DDIMScheduler.from_config(
|
111 |
-
"LMS": LMSDiscreteScheduler.from_config(
|
112 |
-
"PNDM": PNDMScheduler.from_config(
|
113 |
-
"UniPC": UniPCMultistepScheduler.from_config(
|
114 |
}
|
115 |
|
116 |
-
DEFAULT_POSITIVE_PREFIX = "
|
117 |
-
DEFAULT_POSITIVE_SUFFIX = "
|
118 |
-
DEFAULT_NEGATIVE_PREFIX = "
|
119 |
-
DEFAULT_NEGATIVE_SUFFIX = "
|
120 |
|
121 |
# Initialize Florence model
|
122 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -211,12 +211,12 @@ def generate_image(model_choice, additional_positive_prompt, additional_negative
|
|
211 |
input_image=None, progress=gr.Progress(track_tqdm=True)):
|
212 |
|
213 |
# Select the appropriate pipe based on the model choice
|
214 |
-
if model_choice == "Pony
|
215 |
-
pipe =
|
216 |
-
elif model_choice == "
|
217 |
-
pipe =
|
218 |
-
else: # "
|
219 |
-
pipe =
|
220 |
|
221 |
if use_random_seed:
|
222 |
seed = random.randint(0, 2**32 - 1)
|
@@ -298,14 +298,11 @@ def generate_image(model_choice, additional_positive_prompt, additional_negative
|
|
298 |
# Gradio interface
|
299 |
with gr.Blocks(theme='bethecloud/storj_theme') as demo:
|
300 |
gr.HTML("""
|
301 |
-
<h1 align="center">Pony
|
302 |
<p align="center">
|
303 |
-
<a href="https://huggingface.co/
|
304 |
-
<a href="https://huggingface.co/
|
305 |
-
<a href="https://huggingface.co/
|
306 |
-
<a href="https://civitai.com/models/372465/pony-realism" target="_blank">[Pony Realism civitai]</a>
|
307 |
-
<a href="https://civitai.com/models/443821?modelVersionId=680915" target="_blank">[Cyberrealistic Pony civitai]</a>
|
308 |
-
<a href="https://civitai.com/models/628846/stallion-dreams-pony-realistic" target="_blank">[Stallion Dreams civitai]</a>
|
309 |
<a href="https://huggingface.co/microsoft/Florence-2-base" target="_blank">[Florence-2 Model]</a>
|
310 |
<a href="https://huggingface.co/gokaygokay/Lamini-Prompt-Enchance-Long" target="_blank">[Prompt Enhancer Long]</a>
|
311 |
<a href="https://huggingface.co/gokaygokay/Lamini-Prompt-Enchance" target="_blank">[Prompt Enhancer Medium]</a>
|
@@ -315,9 +312,9 @@ with gr.Blocks(theme='bethecloud/storj_theme') as demo:
|
|
315 |
with gr.Row():
|
316 |
with gr.Column(scale=1):
|
317 |
model_choice = gr.Dropdown(
|
318 |
-
["Pony
|
319 |
label="Model Choice",
|
320 |
-
value="Pony
|
321 |
positive_prompt = gr.Textbox(label="Positive Prompt", placeholder="Add your positive prompt here")
|
322 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Add your negative prompt here")
|
323 |
|
|
|
63 |
download_file("https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth?download=true", "models/upscalers/", "RealESRGAN_x4.pth")
|
64 |
|
65 |
# Download the model files
|
66 |
+
ckpt_dir_realpony = snapshot_download(repo_id="silveroxides/RNS_RealPonyV20")
|
67 |
+
ckpt_dir_ultpony = snapshot_download(repo_id="silveroxides/RNS_PonyUltimateV20")
|
68 |
+
ckpt_dir_hybridpony = snapshot_download(repo_id="silveroxides/RealHybridPony")
|
69 |
|
70 |
# Load the models
|
71 |
+
vae_realpony = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir_realpony, "vae"), torch_dtype=torch.float16)
|
72 |
+
vae_ultpony = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir_ultpony, "vae"), torch_dtype=torch.float16)
|
73 |
+
vae_hybridpony = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir_hybridpony, "vae"), torch_dtype=torch.float16)
|
74 |
|
75 |
+
pipe_realpony = StableDiffusionXLPipeline.from_pretrained(
|
76 |
+
ckpt_dir_realpony,
|
77 |
+
vae=vae_realpony,
|
78 |
torch_dtype=torch.float16,
|
79 |
use_safetensors=True,
|
80 |
)
|
81 |
+
pipe_ultpony = StableDiffusionXLPipeline.from_pretrained(
|
82 |
+
ckpt_dir_ultpony,
|
83 |
+
vae=vae_ultpony,
|
84 |
torch_dtype=torch.float16,
|
85 |
use_safetensors=True,
|
86 |
)
|
87 |
+
pipe_hybridpony = StableDiffusionXLPipeline.from_pretrained(
|
88 |
+
ckpt_dir_hybridpony,
|
89 |
+
vae=vae_hybridpony,
|
90 |
torch_dtype=torch.float16,
|
91 |
use_safetensors=True,
|
92 |
)
|
93 |
|
94 |
+
pipe_realpony = pipe_realpony.to("cuda")
|
95 |
+
pipe_ultpony = pipe_ultpony.to("cuda")
|
96 |
+
pipe_hybridpony = pipe_hybridpony.to("cuda")
|
97 |
|
98 |
+
pipe_realpony.unet.set_attn_processor(AttnProcessor2_0())
|
99 |
+
pipe_ultpony.unet.set_attn_processor(AttnProcessor2_0())
|
100 |
+
pipe_hybridpony.unet.set_attn_processor(AttnProcessor2_0())
|
101 |
|
102 |
# Define samplers
|
103 |
samplers = {
|
104 |
+
"Euler a": EulerAncestralDiscreteScheduler.from_config(pipe_realpony.scheduler.config),
|
105 |
+
"DPM++ SDE Karras": DPMSolverSDEScheduler.from_config(pipe_realpony.scheduler.config, use_karras_sigmas=True),
|
106 |
+
"Heun": HeunDiscreteScheduler.from_config(pipe_realpony.scheduler.config),
|
107 |
# New samplers
|
108 |
+
"DPM++ 2M SDE Karras": DPMSolverMultistepScheduler.from_config(pipe_realpony.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++"),
|
109 |
+
"DPM++ 2M": DPMSolverMultistepScheduler.from_config(pipe_realpony.scheduler.config),
|
110 |
+
"DDIM": DDIMScheduler.from_config(pipe_realpony.scheduler.config),
|
111 |
+
"LMS": LMSDiscreteScheduler.from_config(pipe_realpony.scheduler.config),
|
112 |
+
"PNDM": PNDMScheduler.from_config(pipe_realpony.scheduler.config),
|
113 |
+
"UniPC": UniPCMultistepScheduler.from_config(pipe_realpony.scheduler.config),
|
114 |
}
|
115 |
|
116 |
+
DEFAULT_POSITIVE_PREFIX = "score_8_up, score_7_up, accurate, genuine"
|
117 |
+
DEFAULT_POSITIVE_SUFFIX = "perfect composition, detailed, photorealism, real life, raw, reality, cinematic"
|
118 |
+
DEFAULT_NEGATIVE_PREFIX = "score_1, score_2, score_3, text, artist name, signature, watermark, logo, url, web address"
|
119 |
+
DEFAULT_NEGATIVE_SUFFIX = "low quality, low resolution, simple background, bad composition, deformed, disfigured, sketch, unfinished"
|
120 |
|
121 |
# Initialize Florence model
|
122 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
211 |
input_image=None, progress=gr.Progress(track_tqdm=True)):
|
212 |
|
213 |
# Select the appropriate pipe based on the model choice
|
214 |
+
if model_choice == "Real Pony RNS":
|
215 |
+
pipe = pipe_realpony
|
216 |
+
elif model_choice == "Ultimate Pony RNS":
|
217 |
+
pipe = pipe_ultpony
|
218 |
+
else: # "Hybrid Pony SDXL"
|
219 |
+
pipe = pipe_hybridpony
|
220 |
|
221 |
if use_random_seed:
|
222 |
seed = random.randint(0, 2**32 - 1)
|
|
|
298 |
# Gradio interface
|
299 |
with gr.Blocks(theme='bethecloud/storj_theme') as demo:
|
300 |
gr.HTML("""
|
301 |
+
<h1 align="center">Real Pony RNS / Ultimate Pony RNS / Hybrid Pony SDXL</h1>
|
302 |
<p align="center">
|
303 |
+
<a href="https://huggingface.co/silveroxides/RNS_RealPonyV20" target="_blank">[Pony Realism]</a>
|
304 |
+
<a href="https://huggingface.co/silveroxides/RNS_PonyUltimateV20" target="_blank">[Cyberrealistic Pony]</a>
|
305 |
+
<a href="https://huggingface.co/silveroxides/RealHybridPony" target="_blank">[Stallion Dreams]</a><br>
|
|
|
|
|
|
|
306 |
<a href="https://huggingface.co/microsoft/Florence-2-base" target="_blank">[Florence-2 Model]</a>
|
307 |
<a href="https://huggingface.co/gokaygokay/Lamini-Prompt-Enchance-Long" target="_blank">[Prompt Enhancer Long]</a>
|
308 |
<a href="https://huggingface.co/gokaygokay/Lamini-Prompt-Enchance" target="_blank">[Prompt Enhancer Medium]</a>
|
|
|
312 |
with gr.Row():
|
313 |
with gr.Column(scale=1):
|
314 |
model_choice = gr.Dropdown(
|
315 |
+
["Real Pony RNS", "Ultimate Pony RNS", "Hybrid Pony SDXL"],
|
316 |
label="Model Choice",
|
317 |
+
value="Real Pony RNS")
|
318 |
positive_prompt = gr.Textbox(label="Positive Prompt", placeholder="Add your positive prompt here")
|
319 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Add your negative prompt here")
|
320 |
|