shgao commited on
Commit
94fe49e
1 Parent(s): 6ac5c7a
Files changed (2) hide show
  1. sam2edit.py +1 -0
  2. sam2image.py +2 -1
sam2edit.py CHANGED
@@ -58,6 +58,7 @@ def create_demo():
58
  print('segment_anything not installed')
59
  result = subprocess.run(['pip', 'install', 'git+https://github.com/facebookresearch/segment-anything.git'], check=True)
60
  print(f'Install segment_anything {result}')
 
61
  if not os.path.exists('./models/sam_vit_h_4b8939.pth'):
62
  result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth', '-P', 'models'], check=True)
63
  print(f'Download sam_vit_h_4b8939.pth {result}')
 
58
  print('segment_anything not installed')
59
  result = subprocess.run(['pip', 'install', 'git+https://github.com/facebookresearch/segment-anything.git'], check=True)
60
  print(f'Install segment_anything {result}')
61
+ from segment_anything import sam_model_registry, SamAutomaticMaskGenerator
62
  if not os.path.exists('./models/sam_vit_h_4b8939.pth'):
63
  result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth', '-P', 'models'], check=True)
64
  print(f'Download sam_vit_h_4b8939.pth {result}')
sam2image.py CHANGED
@@ -58,7 +58,8 @@ def create_demo():
58
  except ImportError:
59
  print('segment_anything not installed')
60
  result = subprocess.run(['pip', 'install', 'git+https://github.com/facebookresearch/segment-anything.git'], check=True)
61
- print(f'Install segment_anything {result}')
 
62
  if not os.path.exists('./models/sam_vit_h_4b8939.pth'):
63
  result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth', '-P', 'models'], check=True)
64
  print(f'Download sam_vit_h_4b8939.pth {result}')
 
58
  except ImportError:
59
  print('segment_anything not installed')
60
  result = subprocess.run(['pip', 'install', 'git+https://github.com/facebookresearch/segment-anything.git'], check=True)
61
+ print(f'Install segment_anything {result}')
62
+ from segment_anything import sam_model_registry, SamAutomaticMaskGenerator
63
  if not os.path.exists('./models/sam_vit_h_4b8939.pth'):
64
  result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth', '-P', 'models'], check=True)
65
  print(f'Download sam_vit_h_4b8939.pth {result}')