Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,12 +26,12 @@ def predict(dict, prompt="", negative_prompt="", guidance_scale=7.5, steps=30, s
|
|
| 26 |
|
| 27 |
add_kwargs = {}
|
| 28 |
if len(scheduler.split("-")) > 1:
|
| 29 |
-
add_kwargs["
|
| 30 |
if len(scheduler.split("-")) > 2:
|
| 31 |
add_kwargs["algorithm_type"] = "sde-dpmsolver++"
|
| 32 |
|
| 33 |
scheduler = getattr(diffusers, scheduler_class_name)
|
| 34 |
-
pipe.scheduler = scheduler.from_pretrained("
|
| 35 |
|
| 36 |
|
| 37 |
|
|
@@ -51,7 +51,16 @@ def predict(dict, prompt="", negative_prompt="", guidance_scale=7.5, steps=30, s
|
|
| 51 |
mask_image.putdata(new_data)
|
| 52 |
mask_image = mask_image.resize(init_image.size, resample=Image.LANCZOS)
|
| 53 |
#mask_image = pipe.mask_processor.blur(mask_image, blur_factor=25)
|
| 54 |
-
output = pipe(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
print("Positive:",prompt)
|
| 56 |
print("Negative:",negative_prompt)
|
| 57 |
print("Guidance_scale:",guidance_scale)
|
|
@@ -103,7 +112,7 @@ with image_blocks as demo:
|
|
| 103 |
gr.HTML(read_content("header.html"))
|
| 104 |
with gr.Row():
|
| 105 |
with gr.Column():
|
| 106 |
-
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Upload",height=
|
| 107 |
with gr.Row(elem_id="prompt-container",equal_height=True):
|
| 108 |
with gr.Row():
|
| 109 |
prompt = gr.Textbox(placeholder="Your prompt", show_label=False, elem_id="prompt", lines=5, allow_resize=True)
|
|
@@ -112,7 +121,7 @@ with image_blocks as demo:
|
|
| 112 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 113 |
with gr.Row(equal_height=True):
|
| 114 |
guidance_scale = gr.Number(value=7.5, minimum=1.0, maximum=20.0, step=0.1, label="guidance_scale")
|
| 115 |
-
steps = gr.Number(value=
|
| 116 |
strength = gr.Number(value=0.8, minimum=0.01, maximum=1.0, step=0.01, label="strength")
|
| 117 |
negative_prompt = gr.Textbox(label="negative_prompt", placeholder="Your negative prompt", info="what you don't want to see in the image")
|
| 118 |
with gr.Row(equal_height=True):
|
|
@@ -120,7 +129,7 @@ with image_blocks as demo:
|
|
| 120 |
scheduler = gr.Dropdown(label="Schedulers", choices=schedulers, value="DPMSolverMultistepScheduler-Karras")
|
| 121 |
|
| 122 |
with gr.Column():
|
| 123 |
-
image_out = gr.Image(label="Output", elem_id="output-img", height=
|
| 124 |
with gr.Group(elem_id="share-btn-container", visible=False) as share_btn_container:
|
| 125 |
community_icon = gr.HTML(community_icon_html)
|
| 126 |
loading_icon = gr.HTML(loading_icon_html)
|
|
@@ -132,4 +141,4 @@ with image_blocks as demo:
|
|
| 132 |
share_button.click(None, [], [], _js=share_js)
|
| 133 |
|
| 134 |
|
| 135 |
-
image_blocks.queue(max_size=25,api_open=True).launch(show_api=True)
|
|
|
|
| 26 |
|
| 27 |
add_kwargs = {}
|
| 28 |
if len(scheduler.split("-")) > 1:
|
| 29 |
+
add_kwargs["use_karras_sigmas"] = True
|
| 30 |
if len(scheduler.split("-")) > 2:
|
| 31 |
add_kwargs["algorithm_type"] = "sde-dpmsolver++"
|
| 32 |
|
| 33 |
scheduler = getattr(diffusers, scheduler_class_name)
|
| 34 |
+
pipe.scheduler = scheduler.from_pretrained("emilianJR/epiCRealism", subfolder="scheduler", **add_kwargs)
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 51 |
mask_image.putdata(new_data)
|
| 52 |
mask_image = mask_image.resize(init_image.size, resample=Image.LANCZOS)
|
| 53 |
#mask_image = pipe.mask_processor.blur(mask_image, blur_factor=25)
|
| 54 |
+
output = pipe(
|
| 55 |
+
prompt = prompt,
|
| 56 |
+
negative_prompt=negative_prompt,
|
| 57 |
+
image=init_image,
|
| 58 |
+
mask_image=mask_image,
|
| 59 |
+
guidance_scale=guidance_scale,
|
| 60 |
+
num_inference_steps=int(steps),
|
| 61 |
+
strength=strength,
|
| 62 |
+
clip_skip=1
|
| 63 |
+
)
|
| 64 |
print("Positive:",prompt)
|
| 65 |
print("Negative:",negative_prompt)
|
| 66 |
print("Guidance_scale:",guidance_scale)
|
|
|
|
| 112 |
gr.HTML(read_content("header.html"))
|
| 113 |
with gr.Row():
|
| 114 |
with gr.Column():
|
| 115 |
+
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Upload",height=512)
|
| 116 |
with gr.Row(elem_id="prompt-container",equal_height=True):
|
| 117 |
with gr.Row():
|
| 118 |
prompt = gr.Textbox(placeholder="Your prompt", show_label=False, elem_id="prompt", lines=5, allow_resize=True)
|
|
|
|
| 121 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 122 |
with gr.Row(equal_height=True):
|
| 123 |
guidance_scale = gr.Number(value=7.5, minimum=1.0, maximum=20.0, step=0.1, label="guidance_scale")
|
| 124 |
+
steps = gr.Number(value=40, minimum=10, maximum=100, step=1, label="steps")
|
| 125 |
strength = gr.Number(value=0.8, minimum=0.01, maximum=1.0, step=0.01, label="strength")
|
| 126 |
negative_prompt = gr.Textbox(label="negative_prompt", placeholder="Your negative prompt", info="what you don't want to see in the image")
|
| 127 |
with gr.Row(equal_height=True):
|
|
|
|
| 129 |
scheduler = gr.Dropdown(label="Schedulers", choices=schedulers, value="DPMSolverMultistepScheduler-Karras")
|
| 130 |
|
| 131 |
with gr.Column():
|
| 132 |
+
image_out = gr.Image(label="Output", elem_id="output-img", height=512, width=512)
|
| 133 |
with gr.Group(elem_id="share-btn-container", visible=False) as share_btn_container:
|
| 134 |
community_icon = gr.HTML(community_icon_html)
|
| 135 |
loading_icon = gr.HTML(loading_icon_html)
|
|
|
|
| 141 |
share_button.click(None, [], [], _js=share_js)
|
| 142 |
|
| 143 |
|
| 144 |
+
image_blocks.queue(max_size=25,api_open=True).launch(show_api=True,share=True)
|