Commit ·
d1eea16
1
Parent(s): c527acb
Made background transparent in generated mask
Browse files- .gitignore +3 -1
- app.py +6 -4
.gitignore
CHANGED
|
@@ -1 +1,3 @@
|
|
| 1 |
-
__pycache__
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
*.diff
|
| 3 |
+
.DS_Store
|
app.py
CHANGED
|
@@ -14,10 +14,11 @@ model = Model()
|
|
| 14 |
|
| 15 |
|
| 16 |
def run(image_path, threshold):
|
| 17 |
-
image =
|
|
|
|
|
|
|
| 18 |
# We copy the image that and fill it with black, to get the dimensions
|
| 19 |
-
rgb = np.
|
| 20 |
-
rgb.fill(0)
|
| 21 |
masks = model(image_path, threshold, 1)
|
| 22 |
|
| 23 |
mask = masks[0]
|
|
@@ -46,4 +47,5 @@ demo = gr.Interface(fn=run,
|
|
| 46 |
examples=[[path.as_posix(), 0.15] for path in paths],
|
| 47 |
title=TITLE,
|
| 48 |
description=DESCRIPTION)
|
| 49 |
-
demo.queue()
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def run(image_path, threshold):
|
| 17 |
+
image = Image.open(image_path).convert('RGBA')
|
| 18 |
+
canvas = Image.new('RGBA', image.size, (0, 0, 0, 0))
|
| 19 |
+
|
| 20 |
# We copy the image that and fill it with black, to get the dimensions
|
| 21 |
+
rgb = np.array(canvas)
|
|
|
|
| 22 |
masks = model(image_path, threshold, 1)
|
| 23 |
|
| 24 |
mask = masks[0]
|
|
|
|
| 47 |
examples=[[path.as_posix(), 0.15] for path in paths],
|
| 48 |
title=TITLE,
|
| 49 |
description=DESCRIPTION)
|
| 50 |
+
demo.queue(concurrency_count=3, api_open=True)
|
| 51 |
+
demo.launch()
|