Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,7 @@ def img_resize(image):
|
|
19 |
|
20 |
def image_objects(image):
|
21 |
global pred
|
|
|
22 |
image = img_resize(image)
|
23 |
pred = model(image)
|
24 |
pred_object_list = [str(i)+'_'+x['label'] for i, x in enumerate(pred)]
|
@@ -56,24 +57,11 @@ def blurr_object(image, object, blur_strength):
|
|
56 |
def get_seg(image, object):
|
57 |
image = img_resize(image)
|
58 |
|
59 |
-
object_number = int(object.split('_')[0])
|
60 |
-
mask_array = np.asarray(pred[object_number]['mask'])/255
|
61 |
-
image_array = np.asarray(image)
|
62 |
-
|
63 |
-
mask_array_three_channel = np.zeros_like(image_array)
|
64 |
-
mask_array_three_channel[:,:,0] = mask_array
|
65 |
-
mask_array_three_channel[:,:,1] = mask_array
|
66 |
-
mask_array_three_channel[:,:,2] = mask_array
|
67 |
-
|
68 |
-
segmented_image = image_array*mask_array_three_channel
|
69 |
-
|
70 |
-
#blur_image = np.asarray(image.filter(ImageFilter.GaussianBlur(radius=blur_strength)))
|
71 |
-
mask_array_three_channel_invert = 1-mask_array_three_channel
|
72 |
#blur_image_reverse_mask = blur_image*mask_array_three_channel_invert
|
73 |
seg_box=[]
|
74 |
for i in range(len(pred)):
|
75 |
-
object_number = int(object.split('
|
76 |
-
mask_array = np.asarray(pred[
|
77 |
image_array = np.asarray(image)
|
78 |
|
79 |
mask_array_three_channel = np.zeros_like(image_array)
|
|
|
19 |
|
20 |
def image_objects(image):
|
21 |
global pred
|
22 |
+
|
23 |
image = img_resize(image)
|
24 |
pred = model(image)
|
25 |
pred_object_list = [str(i)+'_'+x['label'] for i, x in enumerate(pred)]
|
|
|
57 |
def get_seg(image, object):
|
58 |
image = img_resize(image)
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
#blur_image_reverse_mask = blur_image*mask_array_three_channel_invert
|
61 |
seg_box=[]
|
62 |
for i in range(len(pred)):
|
63 |
+
object_number = int(object.split('_')[0])
|
64 |
+
mask_array = np.asarray(pred[i]['mask'])/255
|
65 |
image_array = np.asarray(image)
|
66 |
|
67 |
mask_array_three_channel = np.zeros_like(image_array)
|