Spaces:
Runtime error
Runtime error
gokaygokay
commited on
Commit
•
e2763db
1
Parent(s):
d8de5c1
Update app.py
Browse files
app.py
CHANGED
@@ -224,25 +224,44 @@ def blend_images(bg_img, obj_img, mask_img, method):
|
|
224 |
|
225 |
return (blend_img * 255).astype(np.uint8)
|
226 |
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
iface.launch()
|
|
|
224 |
|
225 |
return (blend_img * 255).astype(np.uint8)
|
226 |
|
227 |
+
with gr.Blocks(theme='bethecloud/storj_theme') as iface:
|
228 |
+
gr.HTML("<h1>Image Blending with Multiple Methods</h1>")
|
229 |
+
|
230 |
+
with gr.Row():
|
231 |
+
with gr.Column():
|
232 |
+
bg_img = gr.Image(label="Background Image", type="numpy")
|
233 |
+
obj_img = gr.Image(label="Object Image", type="numpy")
|
234 |
+
with gr.Column():
|
235 |
+
mask_img = gr.ImageEditor(
|
236 |
+
label="Mask Image",
|
237 |
+
type="numpy",
|
238 |
+
brush=gr.Brush(colors=["#ffffff"], color_mode="fixed"),
|
239 |
+
eraser=gr.Eraser(),
|
240 |
+
height=300,
|
241 |
+
width=300,
|
242 |
+
)
|
243 |
+
method = gr.Radio(["Poisson", "Mixed Gradient", "Laplacian"], label="Blending Method", value="Poisson")
|
244 |
+
|
245 |
+
blend_button = gr.Button("Blend Images")
|
246 |
+
|
247 |
+
output_image = gr.Image(label="Blended Image")
|
248 |
+
|
249 |
+
blend_button.click(
|
250 |
+
blend_images,
|
251 |
+
inputs=[bg_img, obj_img, mask_img, method],
|
252 |
+
outputs=output_image
|
253 |
+
)
|
254 |
+
|
255 |
+
gr.Examples(
|
256 |
+
examples=[
|
257 |
+
["img1.jpg", "img2.jpg", "mask1.jpg", "Poisson"],
|
258 |
+
["img3.jpg", "img4.jpg", "mask2.jpg", "Mixed Gradient"],
|
259 |
+
["img6.jpg", "img9.jpg", "mask3.jpg", "Laplacian"]
|
260 |
+
],
|
261 |
+
inputs=[bg_img, obj_img, mask_img, method],
|
262 |
+
outputs=output_image,
|
263 |
+
fn=blend_images,
|
264 |
+
cache_examples=True,
|
265 |
+
)
|
266 |
|
267 |
iface.launch()
|