Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
e4b31e4
1
Parent(s):
b879202
Update app.py
Browse files
app.py
CHANGED
@@ -37,14 +37,14 @@ pipe_normal.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigm
|
|
37 |
pipe_normal.to("cuda")
|
38 |
|
39 |
@spaces.GPU
|
40 |
-
def run_normal(prompt, progress=gr.Progress(track_tqdm=True)):
|
41 |
-
return pipe_normal(prompt, num_inference_steps=20).images[0]
|
42 |
|
43 |
@spaces.GPU
|
44 |
-
def run_edit(image, prompt, progress=gr.Progress(track_tqdm=True)):
|
45 |
resolution = 1024
|
46 |
image.resize((resolution, resolution))
|
47 |
-
return pipe_edit(prompt=prompt,image=image,height=resolution,width=resolution,num_inference_steps=20).images[0]
|
48 |
css = '''
|
49 |
.gradio-container{
|
50 |
max-width: 768px !important;
|
@@ -62,7 +62,8 @@ with gr.Blocks(css=css) as demo:
|
|
62 |
button_normal = gr.Button("Generate", min_width=120)
|
63 |
output_normal = gr.Image(label="Your result image", interactive=False)
|
64 |
with gr.Accordion("Advanced Settings", open=False):
|
65 |
-
|
|
|
66 |
with gr.Tab("CosXL Edit"):
|
67 |
with gr.Group():
|
68 |
image_edit = gr.Image(label="Image you would like to edit", type="pil")
|
@@ -71,7 +72,8 @@ with gr.Blocks(css=css) as demo:
|
|
71 |
button_edit = gr.Button("Generate", min_width=120)
|
72 |
output_edit = gr.Image(label="Your result image", interactive=False)
|
73 |
with gr.Accordion("Advanced Settings", open=False):
|
74 |
-
|
|
|
75 |
|
76 |
button_edit.click(
|
77 |
|
@@ -82,7 +84,7 @@ with gr.Blocks(css=css) as demo:
|
|
82 |
prompt_normal.submit
|
83 |
],
|
84 |
fn=run_normal,
|
85 |
-
inputs=[prompt_normal],
|
86 |
outputs=[output_normal],
|
87 |
)
|
88 |
gr.on(
|
@@ -91,7 +93,7 @@ with gr.Blocks(css=css) as demo:
|
|
91 |
prompt_edit.submit
|
92 |
],
|
93 |
fn=run_edit,
|
94 |
-
inputs=[image_edit, prompt_edit],
|
95 |
outputs=[output_edit]
|
96 |
)
|
97 |
if __name__ == "__main__":
|
|
|
37 |
pipe_normal.to("cuda")
|
38 |
|
39 |
@spaces.GPU
|
40 |
+
def run_normal(prompt, negative_prompt, guidance_scale, progress=gr.Progress(track_tqdm=True)):
|
41 |
+
return pipe_normal(prompt, negative_prompt=negative_prompt, guidance_scale=guidance_scale, num_inference_steps=20).images[0]
|
42 |
|
43 |
@spaces.GPU
|
44 |
+
def run_edit(image, prompt, negative_prompt, guidance_scale, progress=gr.Progress(track_tqdm=True)):
|
45 |
resolution = 1024
|
46 |
image.resize((resolution, resolution))
|
47 |
+
return pipe_edit(prompt=prompt,image=image,height=resolution,width=resolution,negative_prompt=negative_prompt, guidance_scale=guidance_scale,num_inference_steps=20).images[0]
|
48 |
css = '''
|
49 |
.gradio-container{
|
50 |
max-width: 768px !important;
|
|
|
62 |
button_normal = gr.Button("Generate", min_width=120)
|
63 |
output_normal = gr.Image(label="Your result image", interactive=False)
|
64 |
with gr.Accordion("Advanced Settings", open=False):
|
65 |
+
negative_prompt_normal = gr.Textbox(label="Negative Prompt")
|
66 |
+
guidance_scale_normal = gr.Number(label="Guidance Scale", value=7)
|
67 |
with gr.Tab("CosXL Edit"):
|
68 |
with gr.Group():
|
69 |
image_edit = gr.Image(label="Image you would like to edit", type="pil")
|
|
|
72 |
button_edit = gr.Button("Generate", min_width=120)
|
73 |
output_edit = gr.Image(label="Your result image", interactive=False)
|
74 |
with gr.Accordion("Advanced Settings", open=False):
|
75 |
+
negative_prompt_edit = gr.Textbox(label="Negative Prompt")
|
76 |
+
guidance_scale_edit = gr.Number(label="Guidance Scale", value=7)
|
77 |
|
78 |
button_edit.click(
|
79 |
|
|
|
84 |
prompt_normal.submit
|
85 |
],
|
86 |
fn=run_normal,
|
87 |
+
inputs=[prompt_normal, negative_prompt_normal, guidance_scale_normal],
|
88 |
outputs=[output_normal],
|
89 |
)
|
90 |
gr.on(
|
|
|
93 |
prompt_edit.submit
|
94 |
],
|
95 |
fn=run_edit,
|
96 |
+
inputs=[image_edit, prompt_edit, negative_prompt_edit, guidance_scale_edit],
|
97 |
outputs=[output_edit]
|
98 |
)
|
99 |
if __name__ == "__main__":
|