silveroxides commited on
Commit
4a757d2
1 Parent(s): 4138dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -49
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
- ckpt_dir_pony = snapshot_download(repo_id="John6666/pony-realism-v21main-sdxl")
67
- ckpt_dir_cyber = snapshot_download(repo_id="John6666/cyberrealistic-pony-v63-sdxl")
68
- ckpt_dir_stallion = snapshot_download(repo_id="John6666/stallion-dreams-pony-realistic-v1-sdxl")
69
 
70
  # Load the models
71
- vae_pony = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir_pony, "vae"), torch_dtype=torch.float16)
72
- vae_cyber = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir_cyber, "vae"), torch_dtype=torch.float16)
73
- vae_stallion = AutoencoderKL.from_pretrained(os.path.join(ckpt_dir_stallion, "vae"), torch_dtype=torch.float16)
74
 
75
- pipe_pony = StableDiffusionXLPipeline.from_pretrained(
76
- ckpt_dir_pony,
77
- vae=vae_pony,
78
  torch_dtype=torch.float16,
79
  use_safetensors=True,
80
  )
81
- pipe_cyber = StableDiffusionXLPipeline.from_pretrained(
82
- ckpt_dir_cyber,
83
- vae=vae_cyber,
84
  torch_dtype=torch.float16,
85
  use_safetensors=True,
86
  )
87
- pipe_stallion = StableDiffusionXLPipeline.from_pretrained(
88
- ckpt_dir_stallion,
89
- vae=vae_stallion,
90
  torch_dtype=torch.float16,
91
  use_safetensors=True,
92
  )
93
 
94
- pipe_pony = pipe_pony.to("cuda")
95
- pipe_cyber = pipe_cyber.to("cuda")
96
- pipe_stallion = pipe_stallion.to("cuda")
97
 
98
- pipe_pony.unet.set_attn_processor(AttnProcessor2_0())
99
- pipe_cyber.unet.set_attn_processor(AttnProcessor2_0())
100
- pipe_stallion.unet.set_attn_processor(AttnProcessor2_0())
101
 
102
  # Define samplers
103
  samplers = {
104
- "Euler a": EulerAncestralDiscreteScheduler.from_config(pipe_pony.scheduler.config),
105
- "DPM++ SDE Karras": DPMSolverSDEScheduler.from_config(pipe_pony.scheduler.config, use_karras_sigmas=True),
106
- "Heun": HeunDiscreteScheduler.from_config(pipe_pony.scheduler.config),
107
  # New samplers
108
- "DPM++ 2M SDE Karras": DPMSolverMultistepScheduler.from_config(pipe_pony.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++"),
109
- "DPM++ 2M": DPMSolverMultistepScheduler.from_config(pipe_pony.scheduler.config),
110
- "DDIM": DDIMScheduler.from_config(pipe_pony.scheduler.config),
111
- "LMS": LMSDiscreteScheduler.from_config(pipe_pony.scheduler.config),
112
- "PNDM": PNDMScheduler.from_config(pipe_pony.scheduler.config),
113
- "UniPC": UniPCMultistepScheduler.from_config(pipe_pony.scheduler.config),
114
  }
115
 
116
- DEFAULT_POSITIVE_PREFIX = "Score_9 score_8_up score_7_up BREAK"
117
- DEFAULT_POSITIVE_SUFFIX = "(masterpiece) very_aesthetic detailed_face cinematic footage"
118
- DEFAULT_NEGATIVE_PREFIX = "Score_1 score_2 score _3 text low_res"
119
- DEFAULT_NEGATIVE_SUFFIX = "Nsfw oversaturated crappy_art low_quality blurry bad_anatomy extra_digits fewer_digits simple_background very_displeasing watermark signature"
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 Realism v21":
215
- pipe = pipe_pony
216
- elif model_choice == "Cyber Realistic Pony v63":
217
- pipe = pipe_cyber
218
- else: # "Stallion Dreams Pony Realistic v1"
219
- pipe = pipe_stallion
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 Realism / Cyber Realism / Stallion Dreams</h1>
302
  <p align="center">
303
- <a href="https://huggingface.co/John6666/pony-realism-v21main-sdxl/" target="_blank">[Pony Realism]</a>
304
- <a href="https://huggingface.co/John6666/cyberrealistic-pony-v63-sdxl" target="_blank">[Cyberrealistic Pony]</a>
305
- <a href="https://huggingface.co/John6666/stallion-dreams-pony-realistic-v1-sdxl" target="_blank">[Stallion Dreams]</a><br>
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 Realism v21", "Cyber Realistic Pony v63", "Stallion Dreams Pony Realistic v1"],
319
  label="Model Choice",
320
- value="Pony Realism v21")
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