yizhangliu commited on
Commit
881ab59
1 Parent(s): 607dee4

update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -773,13 +773,11 @@ def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_t
773
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
774
 
775
  logger.info(f'run_anything_task_[{file_temp}]_{task_type}_2_')
776
- if task_type == 'segment' or ((task_type in ['inpainting', 'outpainting'] or task_type == 'remove') and mask_source_radio == mask_source_segment):
 
777
  image = np.array(input_img)
778
- use_sam_predictor = True
779
- if remove_use_segment and task_type == 'remove':
780
- use_sam_predictor = False
781
 
782
- if sam_predictor and use_sam_predictor:
783
  sam_predictor.set_image(image)
784
 
785
  for i in range(boxes_filt.size(0)):
@@ -787,7 +785,7 @@ def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_t
787
  boxes_filt[i][:2] -= boxes_filt[i][2:] / 2
788
  boxes_filt[i][2:] += boxes_filt[i][:2]
789
 
790
- if sam_predictor and use_sam_predictor:
791
  boxes_filt = boxes_filt.to(sam_device)
792
  transformed_boxes = sam_predictor.transform.apply_boxes_torch(boxes_filt, image.shape[:2])
793
 
 
773
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
774
 
775
  logger.info(f'run_anything_task_[{file_temp}]_{task_type}_2_')
776
+
777
+ if task_type == 'segment' or ((task_type in ['inpainting', 'outpainting'] or (task_type == 'remove' and remove_use_segment )) and mask_source_radio == mask_source_segment):
778
  image = np.array(input_img)
 
 
 
779
 
780
+ if sam_predictor:
781
  sam_predictor.set_image(image)
782
 
783
  for i in range(boxes_filt.size(0)):
 
785
  boxes_filt[i][:2] -= boxes_filt[i][2:] / 2
786
  boxes_filt[i][2:] += boxes_filt[i][:2]
787
 
788
+ if sam_predictor:
789
  boxes_filt = boxes_filt.to(sam_device)
790
  transformed_boxes = sam_predictor.transform.apply_boxes_torch(boxes_filt, image.shape[:2])
791