niulx commited on
Commit
577723e
1 Parent(s): 0f8c3e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -39,13 +39,17 @@ def create_segmentation(mask_np_list):
39
 
40
 
41
  def run_segmentation_wrapper(image):
42
- image, mask_np_list,mask_label_list = run_segmentation(image)
43
- #image = image.convert('RGB')
44
- segmentation = create_segmentation(mask_np_list)
45
- print("!!", len(mask_np_list))
46
- max_val = len(mask_np_list)-1
47
- sliderup = gr.Slider(value = 0, minimum=0, maximum=max_val, step=1, visible=True)
48
- return image, segmentation, mask_np_list, mask_label_list, image, sliderup, sliderup , 'Segmentation finish. Select mask id and move to the next step.'
 
 
 
 
49
 
50
 
51
  def transparent_paste_with_mask(backimg, foreimg, mask_np,transparency = 128):
 
39
 
40
 
41
  def run_segmentation_wrapper(image):
42
+ try:
43
+ image, mask_np_list,mask_label_list = run_segmentation(image)
44
+ #image = image.convert('RGB')
45
+ segmentation = create_segmentation(mask_np_list)
46
+ print("!!", len(mask_np_list))
47
+ max_val = len(mask_np_list)-1
48
+ sliderup = gr.Slider(value = 0, minimum=0, maximum=max_val, step=1, visible=True)
49
+ return image, segmentation, mask_np_list, mask_label_list, image, sliderup, sliderup , 'Segmentation finish. Select mask id and move to the next step.'
50
+ except:
51
+ sliderup = gr.Slider(value = 0, minimum=0, maximum=max_val, step=1, visible=False)
52
+ return None,None,None,None,None, sliderup, sliderup , 'Please upload an image before proceeding.'
53
 
54
 
55
  def transparent_paste_with_mask(backimg, foreimg, mask_np,transparency = 128):