{"id":25754035,"url":"https://github.com/taylor-eos/sam","last_synced_at":"2026-06-10T02:31:17.102Z","repository":{"id":279114045,"uuid":"937755706","full_name":"Taylor-eOS/sam","owner":"Taylor-eOS","description":"Create segmentation masks for automatically selecting objects in your images","archived":false,"fork":false,"pushed_at":"2025-02-23T20:33:52.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T21:26:27.492Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Taylor-eOS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-23T20:20:17.000Z","updated_at":"2025-02-23T20:33:56.000Z","dependencies_parsed_at":"2025-02-23T21:36:56.380Z","dependency_job_id":null,"html_url":"https://github.com/Taylor-eOS/sam","commit_stats":null,"previous_names":["taylor-eos/sam"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Taylor-eOS/sam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taylor-eOS%2Fsam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taylor-eOS%2Fsam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taylor-eOS%2Fsam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taylor-eOS%2Fsam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Taylor-eOS","download_url":"https://codeload.github.com/Taylor-eOS/sam/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taylor-eOS%2Fsam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34134633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-26T15:30:11.301Z","updated_at":"2026-06-10T02:31:17.086Z","avatar_url":"https://github.com/Taylor-eOS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Python Script to create layer masks in [Segment Anything](https://huggingface.co/docs/transformers/model_doc/sam) (SAM)**\n\n![sam](https://github.com/user-attachments/assets/2e47564c-ead7-4c11-82bc-5382a133f15a)\n\n### **Instructions:**\nInstall dependencies with `pip install -r requirements.txt`.\nDownload the model from `https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth` (version name might have changed) and place it in the same folder as the script.\nOpen your image and find the coordinates for the object you want to select. (Draw a box around it and hover your mouse over the boundaries.)\nRun the script with `python sam.py input.jpg x0 y0 x1 y1`, replacing `input.jpg` with your image file and entering the bounding box coordinates as four integers: `x0` and `y0` for the top-left corner, `x1` and `y1` for the bottom-right corner.\nThese define the rectangular area in which the model will select an object.\nThe script saves `segmentation_mask.png` in the same folder.\n\nTo use your black-and-white segmentation mask in GIMP:\n1. **Open the Segmentation Mask Image**  \n   - Open the black-and-white segmentation mask (`File \u003e Open as Layers`) so it appears as a separate layer above your original image.\n2. **Copy the Mask Image**  \n   - Select the segmentation mask layer in the **Layers** panel.\n   - Press **Ctrl + A** to select all.\n   - Press **Ctrl + C** to copy it.\n3. **Add a Layer Mask to the Original Image**  \n   - Click on your original image’s layer in the **Layers** panel.\n   - Right-click it and choose **Add Layer Mask**.\n   - In the dialog, select **White (full opacity)** and click **Add**.\n   - If the mask is inverted, click **Colors**, **Invert**.\n   - Click anywhere else in the image with the `Rectangle` tool to remove the selection. Delete or hide the black-and-white upper layer.\n4. **Paste the Segmentation Mask into the Layer Mask**  \n   - Press **Ctrl + V** to paste the segmentation mask into it.\n   - In the **Layers** panel, click the **Anchor Layer** button or press **Ctrl + H** to apply the mask.\n   - Click anywhere else in the image with the `Rectangle` tool to merge the floating selection.\n5. **Use the mask**\n   - Go to **Select \u003e By Color**.\n   - Click on the part of the mask you want to cut out.\n   - Adjust the **Threshold** if necessary (higher means selecting more shades of gray).\n   - Click on your original image layer in the **Layers** panel, and copy (**Ctrl + V**) the selection.\n   - In **Layers**, click **New Layer** button, create a new **Transparency** layer.\n   - Paste in the floating selection. Click anywhere else to remove the selection.\n   - Click **Layer**, **Crop content**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylor-eos%2Fsam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaylor-eos%2Fsam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylor-eos%2Fsam/lists"}