Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import diffusers
|
|
| 9 |
|
| 10 |
|
| 11 |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse")
|
| 12 |
-
|
| 13 |
|
| 14 |
def read_content(file_path: str) -> str:
|
| 15 |
"""read the content of target file
|
|
@@ -19,7 +19,18 @@ def read_content(file_path: str) -> str:
|
|
| 19 |
|
| 20 |
return content
|
| 21 |
|
| 22 |
-
def predict(dict, prompt="", negative_prompt="", guidance_scale=7.5, steps=30, strength=0.8, scheduler="DPMSolverMultistepScheduler-Karras"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
if negative_prompt == "":
|
| 24 |
negative_prompt = None
|
| 25 |
scheduler_class_name = scheduler.split("-")[0]
|
|
@@ -50,7 +61,7 @@ def predict(dict, prompt="", negative_prompt="", guidance_scale=7.5, steps=30, s
|
|
| 50 |
|
| 51 |
mask_image.putdata(new_data)
|
| 52 |
mask_image = mask_image.resize(init_image.size, resample=Image.LANCZOS)
|
| 53 |
-
|
| 54 |
output = pipe(
|
| 55 |
prompt = prompt,
|
| 56 |
negative_prompt=negative_prompt,
|
|
@@ -105,9 +116,9 @@ with image_blocks as demo:
|
|
| 105 |
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Upload",height=512)
|
| 106 |
with gr.Row(elem_id="prompt-container",equal_height=True):
|
| 107 |
with gr.Row():
|
| 108 |
-
prompt = gr.Textbox(placeholder="Your prompt", show_label=False, elem_id="prompt", lines=5
|
| 109 |
-
|
| 110 |
-
|
| 111 |
|
| 112 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 113 |
with gr.Row(equal_height=True):
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse")
|
| 12 |
+
|
| 13 |
|
| 14 |
def read_content(file_path: str) -> str:
|
| 15 |
"""read the content of target file
|
|
|
|
| 19 |
|
| 20 |
return content
|
| 21 |
|
| 22 |
+
def predict(dict, prompt="", negative_prompt="", guidance_scale=7.5, steps=30, strength=0.8,model="Realistic_V5.0", scheduler="DPMSolverMultistepScheduler-Karras"):
|
| 23 |
+
|
| 24 |
+
pipe = AutoPipelineForInpainting.from_pretrained("SG161222/Realistic_Vision_V5.0_noVAE",vae=vae).to("cuda")
|
| 25 |
+
|
| 26 |
+
if model == "Realistic_V5.0":
|
| 27 |
+
pipe = AutoPipelineForInpainting.from_pretrained("SG161222/Realistic_Vision_V5.0_noVAE", vae=vae).to("cuda")
|
| 28 |
+
if model == "EpicRealism":
|
| 29 |
+
pipe = AutoPipelineForInpainting.from_pretrained("emilianJR/epiCRealism", vae=vae).to("cuda")
|
| 30 |
+
if model == "Realistic_V6.0":
|
| 31 |
+
pipe = AutoPipelineForInpainting.from_pretrained("SG161222/Realistic_Vision_V6.0_B1_noVAE", vae=vae).to("cuda")
|
| 32 |
+
|
| 33 |
+
|
| 34 |
if negative_prompt == "":
|
| 35 |
negative_prompt = None
|
| 36 |
scheduler_class_name = scheduler.split("-")[0]
|
|
|
|
| 61 |
|
| 62 |
mask_image.putdata(new_data)
|
| 63 |
mask_image = mask_image.resize(init_image.size, resample=Image.LANCZOS)
|
| 64 |
+
mask_image = pipe.mask_processor.blur(mask_image, blur_factor=5)
|
| 65 |
output = pipe(
|
| 66 |
prompt = prompt,
|
| 67 |
negative_prompt=negative_prompt,
|
|
|
|
| 116 |
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Upload",height=512)
|
| 117 |
with gr.Row(elem_id="prompt-container",equal_height=True):
|
| 118 |
with gr.Row():
|
| 119 |
+
prompt = gr.Textbox(placeholder="Your prompt", show_label=False, elem_id="prompt", lines=5)
|
| 120 |
+
with gr.Row(equal_height=True):
|
| 121 |
+
btn = gr.Button("Inpaint!", elem_id="run_button")
|
| 122 |
|
| 123 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 124 |
with gr.Row(equal_height=True):
|