Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,15 +43,27 @@ def blurr_object(image, object, blur_strength):
|
|
43 |
blur_image = np.asarray(image.filter(ImageFilter.GaussianBlur(radius=blur_strength)))
|
44 |
mask_array_three_channel_invert = 1-mask_array_three_channel
|
45 |
blur_image_reverse_mask = blur_image*mask_array_three_channel_invert
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
#seg_out=image_array.astype(np.uint8)
|
49 |
|
50 |
|
51 |
blurred_output_image = Image.fromarray((blur_image_reverse_mask).astype(np.uint8)+segmented_image.astype(np.uint8))
|
52 |
for _ in range(int(blur_strength//2.5)):
|
53 |
blurred_output_image = blurred_output_image.filter(ImageFilter.SMOOTH_MORE)
|
54 |
-
return blurred_output_image,
|
55 |
|
56 |
app = gr.Blocks()
|
57 |
|
|
|
43 |
blur_image = np.asarray(image.filter(ImageFilter.GaussianBlur(radius=blur_strength)))
|
44 |
mask_array_three_channel_invert = 1-mask_array_three_channel
|
45 |
blur_image_reverse_mask = blur_image*mask_array_three_channel_invert
|
46 |
+
seg_box=[]
|
47 |
+
for i in range(object):
|
48 |
+
object_number = int(object.split('i')[0])
|
49 |
+
mask_array = np.asarray(pred[object_number]['mask'])/255
|
50 |
+
image_array = np.asarray(image)
|
51 |
+
|
52 |
+
mask_array_three_channel = np.zeros_like(image_array)
|
53 |
+
mask_array_three_channel[:,:,0] = mask_array
|
54 |
+
mask_array_three_channel[:,:,1] = mask_array
|
55 |
+
mask_array_three_channel[:,:,2] = mask_array
|
56 |
+
|
57 |
+
segmented_image = image_array*mask_array_three_channel
|
58 |
+
seg_out=segmented_image.astype(np.uint8)
|
59 |
+
seg_box.append(seg_out)
|
60 |
#seg_out=image_array.astype(np.uint8)
|
61 |
|
62 |
|
63 |
blurred_output_image = Image.fromarray((blur_image_reverse_mask).astype(np.uint8)+segmented_image.astype(np.uint8))
|
64 |
for _ in range(int(blur_strength//2.5)):
|
65 |
blurred_output_image = blurred_output_image.filter(ImageFilter.SMOOTH_MORE)
|
66 |
+
return blurred_output_image, seg_box
|
67 |
|
68 |
app = gr.Blocks()
|
69 |
|