Sm0kyWu commited on
Commit
1e2a854
·
verified ·
1 Parent(s): 8435ca1

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -48,7 +48,7 @@ def reset_image(predictor, img):
48
  - 设置 predictor 的输入图像,
49
  - 返回原图
50
  """
51
- # predictor.set_image(img)
52
  original_img = img.copy()
53
  # 返回predictor,visible occlusion mask初始化, 原始图像
54
  return predictor, img, img, original_img
@@ -63,14 +63,14 @@ def run_sam(image, predictor, selected_points):
63
  """
64
  调用 SAM 模型进行分割。
65
  """
66
- predictor.set_image(image)
67
  if len(selected_points) == 0:
68
  return [], None
69
- # input_points = [p for p in selected_points]
70
- # input_labels = [1 for _ in range(len(selected_points))]
71
- input_points = np.array([[210, 300]])
72
- input_labels = np.array([1])
73
- masks, scores, _ = predictor.predict(
74
  point_coords=input_points,
75
  point_labels=input_labels,
76
  multimask_output=False, # 单对象输出
 
48
  - 设置 predictor 的输入图像,
49
  - 返回原图
50
  """
51
+ predictor.set_image(img)
52
  original_img = img.copy()
53
  # 返回predictor,visible occlusion mask初始化, 原始图像
54
  return predictor, img, img, original_img
 
63
  """
64
  调用 SAM 模型进行分割。
65
  """
66
+ # predictor.set_image(image)
67
  if len(selected_points) == 0:
68
  return [], None
69
+ input_points = [p for p in selected_points]
70
+ input_labels = [1 for _ in range(len(selected_points))]
71
+ # input_points = np.array([[210, 300]])
72
+ # input_labels = np.array([1])
73
+ masks, _, _ = predictor.predict(
74
  point_coords=input_points,
75
  point_labels=input_labels,
76
  multimask_output=False, # 单对象输出