Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ HF_TOKEN = os.getenv("HF_TOKEN")
|
|
14 |
|
15 |
# Load the diffusion pipeline
|
16 |
pipe = StableDiffusionXLPipeline.from_single_file(
|
17 |
-
"https://huggingface.co/kayfahaarukku/AkashicPulse-v1.0/blob/main/AkashicPulse-v1.0-ft-ft.safetensors",
|
18 |
torch_dtype=torch.float16,
|
19 |
custom_pipeline="lpw_stable_diffusion_xl",
|
20 |
use_safetensors=True,
|
@@ -23,16 +23,16 @@ pipe = StableDiffusionXLPipeline.from_single_file(
|
|
23 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
24 |
|
25 |
# Function to generate an image
|
26 |
-
@spaces.GPU
|
27 |
def generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress=gr.Progress()):
|
28 |
try:
|
29 |
-
pipe.to('cuda')
|
30 |
|
31 |
if randomize_seed:
|
32 |
seed = random.randint(0, 99999999)
|
33 |
if use_defaults:
|
34 |
-
prompt = f"{prompt},
|
35 |
-
negative_prompt = f"
|
36 |
generator = torch.manual_seed(seed)
|
37 |
|
38 |
def callback(step, timestep, latents):
|
@@ -68,11 +68,11 @@ def interface_fn(prompt, negative_prompt, use_defaults, resolution, guidance_sca
|
|
68 |
return image, seed, gr.update(value=metadata_text)
|
69 |
|
70 |
def reset_inputs():
|
71 |
-
return gr.update(value=''), gr.update(value=''), gr.update(value=True), gr.update(value='832x1216'), gr.update(value=
|
72 |
|
73 |
-
with gr.Blocks(title="
|
74 |
gr.HTML(
|
75 |
-
"<h1>
|
76 |
"<p>This demo is intended to showcase what the model is capable of and is not intended to be the main generation platform. "
|
77 |
"Results produced with Diffusers are not the best, and it's highly recommended for you to get the model running inside "
|
78 |
"Stable Diffusion WebUI or ComfyUI.</p>"
|
@@ -90,7 +90,7 @@ with gr.Blocks(title="irAsu 1.0 Demo", theme="NoCrypt/[email protected]") as demo:
|
|
90 |
label="Resolution",
|
91 |
value="832x1216"
|
92 |
)
|
93 |
-
guidance_scale_input = gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=
|
94 |
num_inference_steps_input = gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=28)
|
95 |
seed_input = gr.Slider(minimum=0, maximum=999999999, step=1, label="Seed", value=0, interactive=True)
|
96 |
randomize_seed_input = gr.Checkbox(label="Randomize Seed", value=True)
|
@@ -104,15 +104,15 @@ with gr.Blocks(title="irAsu 1.0 Demo", theme="NoCrypt/[email protected]") as demo:
|
|
104 |
metadata_textbox = gr.Textbox(lines=6, label="Image Parameters", interactive=False, max_lines=6)
|
105 |
gr.Markdown(
|
106 |
"""
|
107 |
-
### Recommended prompt formatting:
|
108 |
-
`1girl/1boy, character name, from what series, everything else in any order, best quality, amazing quality, very aesthetic,`
|
109 |
-
|
110 |
-
**PS:** `best quality, amazing quality, very aesthetic,` is automatically added when "Use Default Quality Tags and Negative Prompt" is enabled
|
111 |
-
|
112 |
### Recommended settings:
|
113 |
-
-
|
114 |
-
-
|
115 |
-
-
|
|
|
|
|
|
|
|
|
|
|
116 |
"""
|
117 |
)
|
118 |
|
|
|
14 |
|
15 |
# Load the diffusion pipeline
|
16 |
pipe = StableDiffusionXLPipeline.from_single_file(
|
17 |
+
"https://huggingface.co/kayfahaarukku/AkashicPulse-v1.0/blob/main/AkashicPulse-v1.0-ft-ft.safetensors",
|
18 |
torch_dtype=torch.float16,
|
19 |
custom_pipeline="lpw_stable_diffusion_xl",
|
20 |
use_safetensors=True,
|
|
|
23 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
24 |
|
25 |
# Function to generate an image
|
26 |
+
@spaces.GPU
|
27 |
def generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress=gr.Progress()):
|
28 |
try:
|
29 |
+
pipe.to('cuda')
|
30 |
|
31 |
if randomize_seed:
|
32 |
seed = random.randint(0, 99999999)
|
33 |
if use_defaults:
|
34 |
+
prompt = f"{prompt}, masterpiece, best quality"
|
35 |
+
negative_prompt = f"lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, signature, watermark, username, blurry, {negative_prompt}"
|
36 |
generator = torch.manual_seed(seed)
|
37 |
|
38 |
def callback(step, timestep, latents):
|
|
|
68 |
return image, seed, gr.update(value=metadata_text)
|
69 |
|
70 |
def reset_inputs():
|
71 |
+
return gr.update(value=''), gr.update(value=''), gr.update(value=True), gr.update(value='832x1216'), gr.update(value=7), gr.update(value=28), gr.update(value=0), gr.update(value=True), gr.update(value='')
|
72 |
|
73 |
+
with gr.Blocks(title="AkashicPulse Demo", theme="NoCrypt/[email protected]") as demo:
|
74 |
gr.HTML(
|
75 |
+
"<h1>AkashicPulse Demo</h1>"
|
76 |
"<p>This demo is intended to showcase what the model is capable of and is not intended to be the main generation platform. "
|
77 |
"Results produced with Diffusers are not the best, and it's highly recommended for you to get the model running inside "
|
78 |
"Stable Diffusion WebUI or ComfyUI.</p>"
|
|
|
90 |
label="Resolution",
|
91 |
value="832x1216"
|
92 |
)
|
93 |
+
guidance_scale_input = gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=7)
|
94 |
num_inference_steps_input = gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=28)
|
95 |
seed_input = gr.Slider(minimum=0, maximum=999999999, step=1, label="Seed", value=0, interactive=True)
|
96 |
randomize_seed_input = gr.Checkbox(label="Randomize Seed", value=True)
|
|
|
104 |
metadata_textbox = gr.Textbox(lines=6, label="Image Parameters", interactive=False, max_lines=6)
|
105 |
gr.Markdown(
|
106 |
"""
|
|
|
|
|
|
|
|
|
|
|
107 |
### Recommended settings:
|
108 |
+
- Sampling: Euler a
|
109 |
+
- Steps: 20-30 (sweet spot: 28)
|
110 |
+
- CFG: 4-10 (sweet spot: 7)
|
111 |
+
- [Not mandatory] On reForge or ComfyUI, have MaHiRo CFG enabled
|
112 |
+
|
113 |
+
### Recommended prompt formatting:
|
114 |
+
- Prompt: [1girl/1boy], [character name], [series], by [artist name], [the rest of the prompt], masterpiece, best quality
|
115 |
+
- Negative prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, signature, watermark, username, blurry, [the rest of the negative prompt]
|
116 |
"""
|
117 |
)
|
118 |
|