Update app.py
Browse files
app.py
CHANGED
@@ -39,17 +39,14 @@ MAX_IMAGE_SIZE = 1216
|
|
39 |
|
40 |
|
41 |
@spaces.GPU
|
42 |
-
def infer(image: PIL.Image.Image, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps) -> PIL.Image.Image:
|
43 |
# Check if the input image is a valid PIL Image and is not empty
|
44 |
-
if
|
45 |
-
use_image = True
|
46 |
width, height = image['composite'].size
|
47 |
ratio = np.sqrt(1024. * 1024. / (width * height))
|
48 |
new_width, new_height = int(width * ratio), int(height * ratio)
|
49 |
image = image['composite'].resize((new_width, new_height))
|
50 |
print(image)
|
51 |
-
else:
|
52 |
-
use_image = False
|
53 |
|
54 |
if randomize_seed:
|
55 |
seed = random.randint(0, MAX_SEED)
|
@@ -112,6 +109,8 @@ with gr.Blocks(css=css) as demo:
|
|
112 |
image = gr.ImageEditor(type="pil", image_mode="L", crop_size=(512, 512))
|
113 |
result = gr.Image(label="Result", show_label=False)
|
114 |
|
|
|
|
|
115 |
with gr.Accordion("Advanced Settings", open=False):
|
116 |
|
117 |
negative_prompt = gr.Text(
|
@@ -167,7 +166,7 @@ with gr.Blocks(css=css) as demo:
|
|
167 |
|
168 |
run_button.click(lambda x: None, inputs=None, outputs=result).then(
|
169 |
fn=infer,
|
170 |
-
inputs=[image, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
171 |
outputs=[result]
|
172 |
)
|
173 |
|
|
|
39 |
|
40 |
|
41 |
@spaces.GPU
|
42 |
+
def infer(use_image, image: PIL.Image.Image, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps) -> PIL.Image.Image:
|
43 |
# Check if the input image is a valid PIL Image and is not empty
|
44 |
+
if use_image :
|
|
|
45 |
width, height = image['composite'].size
|
46 |
ratio = np.sqrt(1024. * 1024. / (width * height))
|
47 |
new_width, new_height = int(width * ratio), int(height * ratio)
|
48 |
image = image['composite'].resize((new_width, new_height))
|
49 |
print(image)
|
|
|
|
|
50 |
|
51 |
if randomize_seed:
|
52 |
seed = random.randint(0, MAX_SEED)
|
|
|
109 |
image = gr.ImageEditor(type="pil", image_mode="L", crop_size=(512, 512))
|
110 |
result = gr.Image(label="Result", show_label=False)
|
111 |
|
112 |
+
gradio_en = True
|
113 |
+
|
114 |
with gr.Accordion("Advanced Settings", open=False):
|
115 |
|
116 |
negative_prompt = gr.Text(
|
|
|
166 |
|
167 |
run_button.click(lambda x: None, inputs=None, outputs=result).then(
|
168 |
fn=infer,
|
169 |
+
inputs=[gradio_en, image, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
170 |
outputs=[result]
|
171 |
)
|
172 |
|