Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

experiments_mask_generation.py 637 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  1. # https://github.com/sail-sg/EditAnything/blob/main/sam2groundingdino_edit.py
  2. import numpy as np
  3. from PIL import Image
  4. from extras.inpaint_mask import SAMOptions, generate_mask_from_image
  5. original_image = Image.open('cat.webp')
  6. image = np.array(original_image, dtype=np.uint8)
  7. sam_options = SAMOptions(
  8. dino_prompt='eye',
  9. dino_box_threshold=0.3,
  10. dino_text_threshold=0.25,
  11. dino_erode_or_dilate=0,
  12. dino_debug=False,
  13. max_detections=2,
  14. model_type='vit_b'
  15. )
  16. mask_image, _, _, _ = generate_mask_from_image(image, sam_options=sam_options)
  17. merged_masks_img = Image.fromarray(mask_image)
  18. merged_masks_img.show()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...