Update app.py
Browse files
app.py
CHANGED
@@ -31,14 +31,42 @@ async def generate_image(prompt, model, lora_word, width, height, scales, steps,
|
|
31 |
image = await client.text_to_image(prompt=text, height=height, width=width, guidance_scale=scales, num_inference_steps=steps, model=model)
|
32 |
return image, seed
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
model = lora_model
|
36 |
image, seed = await generate_image(prompt, model, "", width, height, scales, steps, seed)
|
37 |
image_path = "temp_image.png"
|
38 |
image.save(image_path)
|
39 |
|
40 |
if process_upscale:
|
41 |
-
|
|
|
|
|
|
|
42 |
else:
|
43 |
upscale_image = image_path
|
44 |
|
@@ -69,6 +97,7 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
69 |
process_lora = gr.Checkbox(label="Process LORA", value=True)
|
70 |
upscale_factor = gr.Radio(label="UpScale Factor", choices=[2, 4, 8], value=2, scale=2)
|
71 |
process_upscale = gr.Checkbox(label="Process Upscale", value=False)
|
|
|
72 |
|
73 |
with gr.Accordion(label="Advanced Options", open=False):
|
74 |
width = gr.Slider(label="Width", minimum=512, maximum=1280, step=8, value=512)
|
@@ -85,7 +114,7 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
85 |
queue=False
|
86 |
).then(
|
87 |
fn=gen,
|
88 |
-
inputs=[prompt, basemodel_choice, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model_choice, process_lora],
|
89 |
outputs=[output_res]
|
90 |
)
|
91 |
demo.launch()
|
|
|
31 |
image = await client.text_to_image(prompt=text, height=height, width=width, guidance_scale=scales, num_inference_steps=steps, model=model)
|
32 |
return image, seed
|
33 |
|
34 |
+
def get_clarity_upscale(prompt, img_path, upscale_factor):
|
35 |
+
client = Client("jbilcke-hf/clarity-upscaler")
|
36 |
+
result = client.predict(
|
37 |
+
img_path,
|
38 |
+
prompt,
|
39 |
+
"",
|
40 |
+
upscale_factor,
|
41 |
+
1,
|
42 |
+
3,
|
43 |
+
3,
|
44 |
+
"16",
|
45 |
+
"16",
|
46 |
+
"epicrealism_naturalSinRC1VAE.safetensors [84d76a0328]",
|
47 |
+
"DPM++ 2M Karras",
|
48 |
+
1,
|
49 |
+
3,
|
50 |
+
True,
|
51 |
+
3,
|
52 |
+
"Hello!!",
|
53 |
+
"Hello!!",
|
54 |
+
api_name="/predict"
|
55 |
+
)
|
56 |
+
print(result)
|
57 |
+
return result
|
58 |
+
|
59 |
+
async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model, process_lora, upscaler_choice):
|
60 |
model = lora_model
|
61 |
image, seed = await generate_image(prompt, model, "", width, height, scales, steps, seed)
|
62 |
image_path = "temp_image.png"
|
63 |
image.save(image_path)
|
64 |
|
65 |
if process_upscale:
|
66 |
+
if upscaler_choice == "FineGrain":
|
67 |
+
upscale_image = get_upscale_finegrain(prompt, image_path, upscale_factor)
|
68 |
+
elif upscaler_choice == "Upscaler Clarity":
|
69 |
+
upscale_image = get_clarity_upscale(prompt, image_path, upscale_factor)
|
70 |
else:
|
71 |
upscale_image = image_path
|
72 |
|
|
|
97 |
process_lora = gr.Checkbox(label="Process LORA", value=True)
|
98 |
upscale_factor = gr.Radio(label="UpScale Factor", choices=[2, 4, 8], value=2, scale=2)
|
99 |
process_upscale = gr.Checkbox(label="Process Upscale", value=False)
|
100 |
+
upscaler_choice = gr.Radio(label="Upscaler", choices=["FineGrain", "Upscaler Clarity"], value="FineGrain")
|
101 |
|
102 |
with gr.Accordion(label="Advanced Options", open=False):
|
103 |
width = gr.Slider(label="Width", minimum=512, maximum=1280, step=8, value=512)
|
|
|
114 |
queue=False
|
115 |
).then(
|
116 |
fn=gen,
|
117 |
+
inputs=[prompt, basemodel_choice, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model_choice, process_lora, upscaler_choice],
|
118 |
outputs=[output_res]
|
119 |
)
|
120 |
demo.launch()
|