Spaces:
Running
Running
Dynamic interface + time
Browse files
app.py
CHANGED
@@ -91,7 +91,7 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
|
|
91 |
|
92 |
# Mask
|
93 |
mask_image = Image.new(mode = input_image.mode, size = (output_width, output_height), color = (255, 255, 255, 0))
|
94 |
-
black_mask = Image.new(mode = input_image.mode, size = (original_width - 20, original_height - 20), color = (
|
95 |
mask_image.paste(black_mask, (enlarge_left + 10, enlarge_top + 10))
|
96 |
mask_image = mask_image.filter(ImageFilter.BoxBlur(10))
|
97 |
|
@@ -126,26 +126,85 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
|
|
126 |
mask_image
|
127 |
]
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
# Mask
|
93 |
mask_image = Image.new(mode = input_image.mode, size = (output_width, output_height), color = (255, 255, 255, 0))
|
94 |
+
black_mask = Image.new(mode = input_image.mode, size = (original_width - 20, original_height - 20), color = (0, 0, 0, 0))
|
95 |
mask_image.paste(black_mask, (enlarge_left + 10, enlarge_top + 10))
|
96 |
mask_image = mask_image.filter(ImageFilter.BoxBlur(10))
|
97 |
|
|
|
126 |
mask_image
|
127 |
]
|
128 |
|
129 |
+
with gr.Blocks() as interface:
|
130 |
+
gr.Markdown(
|
131 |
+
"""
|
132 |
+
<h1 style="text-align: center;">Uncrop</h1>
|
133 |
+
<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>
|
134 |
+
<br/>
|
135 |
+
<br/>
|
136 |
+
🚀 Powered by <i>SDXL 1.0</i> artificial intellingence
|
137 |
+
<br/>
|
138 |
+
<ul>
|
139 |
+
<li>If you need to change the <b>view angle</b> of your image, I recommend you to use <i>Zero123</i>,</li>
|
140 |
+
<li>If you need to <b>upscale</b> your image, I recommend you to use <i>Ilaria Upscaler</i>,</li>
|
141 |
+
<li>If you need to <b>slightly change</b> your image, I recommend you to use <i>Image-to-Image SDXL</i>,</li>
|
142 |
+
<li>If you need to change <b>one detail</b> on your image, I recommend you to use <i>Inpaint SDXL</i>.</li>
|
143 |
+
</ul>
|
144 |
+
<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/>
|
145 |
+
<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>
|
146 |
+
<br/>
|
147 |
+
<br/>
|
148 |
+
⚖️ You can use, modify and share the generated images but not for commercial uses.
|
149 |
+
|
150 |
+
"""
|
151 |
+
)
|
152 |
+
with gr.Row():
|
153 |
+
with gr.Column():
|
154 |
+
with gr.Column():
|
155 |
+
enlarge_top = gr.Number(minimum = 0, value = 64, precision = 0, label = "Enlarge on top", info = "in pixels")
|
156 |
+
with gr.Column():
|
157 |
+
with gr.Row():
|
158 |
+
with gr.Column():
|
159 |
+
enlarge_left = gr.Number(minimum = 0, value = 64, precision = 0, label = "Enlarge on left", info = "in pixels")
|
160 |
+
with gr.Column():
|
161 |
+
source_img = gr.Image(label = "Your image", source = "upload", type = "numpy")
|
162 |
+
with gr.Column():
|
163 |
+
enlarge_right = gr.Number(minimum = 0, value = 64, precision = 0, label = "Enlarge on right", info = "in pixels")
|
164 |
+
with gr.Row():
|
165 |
+
with gr.Column():
|
166 |
+
with gr.Column():
|
167 |
+
enlarge_bottom = gr.Number(minimum = 0, value = 64, precision = 0, label = "Enlarge on bottom", info = "in pixels")
|
168 |
+
with gr.Column():
|
169 |
+
with gr.Row():
|
170 |
+
with gr.Row():
|
171 |
+
prompt = gr.Textbox(label = 'Prompt', info = "Describe the subject, the background and the style of image; 77 token limit", placeholder = 'Describe what you want to see in the entire image')
|
172 |
+
with gr.Accordion("Advanced options", open = False):
|
173 |
+
negative_prompt = gr.Textbox(label = 'Negative prompt', placeholder = 'Describe what you do NOT want to see in the entire image', value = 'Border, frame, painting, scribbling, smear, noise, blur, watermark')
|
174 |
+
denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 1000, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
|
175 |
+
num_inference_steps = gr.Slider(minimum = 10, maximum = 25, value = 10, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
|
176 |
+
guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt")
|
177 |
+
randomize_seed = gr.Checkbox(label = "Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different")
|
178 |
+
seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)")
|
179 |
+
debug_mode = gr.Checkbox(label = "Debug mode", value = True, info = "Show intermediate results")
|
180 |
+
with gr.Row():
|
181 |
+
submit = gr.Button("Uncrop", variant = "primary")
|
182 |
+
with gr.Row():
|
183 |
+
uncropped_image = gr.Image(label = "Uncropped image")
|
184 |
+
information = gr.Label(label = "Information")
|
185 |
+
original_image = gr.Image(label = "Original image")
|
186 |
+
enlarged_image = gr.Image(label = "Enlarged image")
|
187 |
+
mask_image = gr.Image(label = "Mask image")
|
188 |
+
submit.click(predict, inputs = [
|
189 |
+
source_img,
|
190 |
+
enlarge_top,
|
191 |
+
enlarge_right,
|
192 |
+
enlarge_bottom,
|
193 |
+
enlarge_left,
|
194 |
+
prompt,
|
195 |
+
negative_prompt,
|
196 |
+
denoising_steps,
|
197 |
+
num_inference_steps,
|
198 |
+
guidance_scale,
|
199 |
+
randomize_seed,
|
200 |
+
seed,
|
201 |
+
debug_mode
|
202 |
+
], outputs = [
|
203 |
+
uncropped_image,
|
204 |
+
information,
|
205 |
+
original_image,
|
206 |
+
enlarged_image,
|
207 |
+
mask_image
|
208 |
+
], scroll_to_output = True)
|
209 |
+
|
210 |
+
interface.queue().launch()
|