Spaces:
Running
Running
Fabrice-TIERCELIN
commited on
Commit
•
2516d07
1
Parent(s):
74be613
Hide message before generation
Browse files
app.py
CHANGED
@@ -16,9 +16,9 @@ pipe = StableDiffusionXLInpaintPipeline.from_pretrained("stabilityai/stable-diff
|
|
16 |
pipe = pipe.to(device)
|
17 |
|
18 |
def noise_color(color, noise):
|
19 |
-
return color + random.randint(- noise, noise)
|
20 |
|
21 |
-
def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left, prompt, negative_prompt, denoising_steps, num_inference_steps, guidance_scale, randomize_seed, seed, progress=gr.Progress()):
|
22 |
progress(0, desc = "Preparing data...")
|
23 |
|
24 |
if source_img is None:
|
@@ -81,7 +81,7 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
|
|
81 |
for i in range(output_width):
|
82 |
for j in range(output_height):
|
83 |
enlarged_pixel = enlarged_pixels[i, j]
|
84 |
-
noise =
|
85 |
noise_image.putpixel((i, j), (noise_color(enlarged_pixel[0], noise), noise_color(enlarged_pixel[1], noise), noise_color(enlarged_pixel[2], noise), 255))
|
86 |
|
87 |
enlarged_image.paste(noise_image, (0, 0))
|
@@ -109,7 +109,13 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
|
|
109 |
progress(None, desc = "Processing...")
|
110 |
|
111 |
output_image = pipe(seeds=[seed], width = output_width, height = output_height, prompt = prompt, negative_prompt = negative_prompt, image = enlarged_image, mask_image = mask_image, num_inference_steps = num_inference_steps, guidance_scale = guidance_scale, denoising_steps = denoising_steps, show_progress_bar = True).images[0]
|
112 |
-
return [
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
title = "Uncrop"
|
115 |
description = "<p style='text-align: center;'>Enlarges the point of view of your image, up to 1 million pixels, freely, without account, without watermark, which can be downloaded</p><br/><br/>Powered by <i>SDXL 1.0</i> artificial intellingence<br/><ul><li>If you need to change the <b>view angle</b> of your image, I recommend you to use <i>Zero123</i>,</li><li>If you need to <b>upscale</b> your image, I recommend you to use <i>Ilaria Upscaler</i>,</li><li>If you need to <b>slightly change</b> your image, I recommend you to use <i>Image-to-Image SDXL</i>,</li><li>If you need to change <b>one detail</b> on your image, I recommend you to use <i>Inpaint SDXL</i>.</li></ul><br/>🐌 Slow process... ~20 min with 20 inference steps, ~6 hours with 25 inference steps.<br>You can duplicate this space on a free account, it works on CPU.<br/><a href='https://huggingface.co/spaces/Fabrice-TIERCELIN/Uncrop?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14'></a><br/><br/>⚖️ You can use, modify and share the generated images but not for commercial uses."
|
@@ -125,10 +131,11 @@ gr.Interface(fn = predict, inputs = [
|
|
125 |
gr.Slider(minimum = 10, maximum = 25, value = 10, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality"),
|
126 |
gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt"),
|
127 |
gr.Checkbox(label = "Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different"),
|
128 |
-
gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)")
|
|
|
129 |
], outputs = [
|
130 |
gr.Image(label = "Uncropped image"),
|
131 |
-
gr.Label(),
|
132 |
gr.Image(label = "Original image"),
|
133 |
gr.Image(label = "Enlarged image"),
|
134 |
gr.Image(label = "Mask image")
|
|
|
16 |
pipe = pipe.to(device)
|
17 |
|
18 |
def noise_color(color, noise):
|
19 |
+
return color + random.randint(- noise, noise)
|
20 |
|
21 |
+
def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left, prompt, negative_prompt, denoising_steps, num_inference_steps, guidance_scale, randomize_seed, seed, debug_mode, progress=gr.Progress()):
|
22 |
progress(0, desc = "Preparing data...")
|
23 |
|
24 |
if source_img is None:
|
|
|
81 |
for i in range(output_width):
|
82 |
for j in range(output_height):
|
83 |
enlarged_pixel = enlarged_pixels[i, j]
|
84 |
+
noise = min(abs(enlarge_left - i), abs(enlarge_left + original_width - i), abs(enlarge_top - j), abs(enlarge_top + original_height - j), 255)
|
85 |
noise_image.putpixel((i, j), (noise_color(enlarged_pixel[0], noise), noise_color(enlarged_pixel[1], noise), noise_color(enlarged_pixel[2], noise), 255))
|
86 |
|
87 |
enlarged_image.paste(noise_image, (0, 0))
|
|
|
109 |
progress(None, desc = "Processing...")
|
110 |
|
111 |
output_image = pipe(seeds=[seed], width = output_width, height = output_height, prompt = prompt, negative_prompt = negative_prompt, image = enlarged_image, mask_image = mask_image, num_inference_steps = num_inference_steps, guidance_scale = guidance_scale, denoising_steps = denoising_steps, show_progress_bar = True).images[0]
|
112 |
+
return [
|
113 |
+
output_image,
|
114 |
+
gr.Label("Start again to get a different result. The new image is " + str(output_width) + " pixels large and " + str(output_height) + " pixels high, so an image of " + str(output_width * output_height) + " pixels." + limitation, visible = True),
|
115 |
+
input_image,
|
116 |
+
enlarged_image,
|
117 |
+
mask_image
|
118 |
+
]
|
119 |
|
120 |
title = "Uncrop"
|
121 |
description = "<p style='text-align: center;'>Enlarges the point of view of your image, up to 1 million pixels, freely, without account, without watermark, which can be downloaded</p><br/><br/>Powered by <i>SDXL 1.0</i> artificial intellingence<br/><ul><li>If you need to change the <b>view angle</b> of your image, I recommend you to use <i>Zero123</i>,</li><li>If you need to <b>upscale</b> your image, I recommend you to use <i>Ilaria Upscaler</i>,</li><li>If you need to <b>slightly change</b> your image, I recommend you to use <i>Image-to-Image SDXL</i>,</li><li>If you need to change <b>one detail</b> on your image, I recommend you to use <i>Inpaint SDXL</i>.</li></ul><br/>🐌 Slow process... ~20 min with 20 inference steps, ~6 hours with 25 inference steps.<br>You can duplicate this space on a free account, it works on CPU.<br/><a href='https://huggingface.co/spaces/Fabrice-TIERCELIN/Uncrop?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14'></a><br/><br/>⚖️ You can use, modify and share the generated images but not for commercial uses."
|
|
|
131 |
gr.Slider(minimum = 10, maximum = 25, value = 10, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality"),
|
132 |
gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt"),
|
133 |
gr.Checkbox(label = "Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different"),
|
134 |
+
gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)"),
|
135 |
+
gr.Checkbox(label = "Debug mode", value = True, info = "Show intermediate results")
|
136 |
], outputs = [
|
137 |
gr.Image(label = "Uncropped image"),
|
138 |
+
gr.Label(visible = False),
|
139 |
gr.Image(label = "Original image"),
|
140 |
gr.Image(label = "Enlarged image"),
|
141 |
gr.Image(label = "Mask image")
|