{"id":20503156,"url":"https://github.com/curt-park/segment-anything-with-clip","last_synced_at":"2025-10-13T21:02:24.278Z","repository":{"id":151624363,"uuid":"624492945","full_name":"Curt-Park/segment-anything-with-clip","owner":"Curt-Park","description":"Segment Anything combined with CLIP","archived":false,"fork":false,"pushed_at":"2024-02-19T14:20:58.000Z","size":17621,"stargazers_count":339,"open_issues_count":4,"forks_count":26,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-26T11:16:39.275Z","etag":null,"topics":["colab-notebook","huggingface-spaces","machine-learning","nlp-machine-learning","segmentation-model"],"latest_commit_sha":null,"homepage":"https://huggingface.co/spaces/curt-park/segment-anything-with-clip","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Curt-Park.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-04-06T15:33:18.000Z","updated_at":"2025-05-17T16:29:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd9616e5-01e6-478e-bba9-3a89b5394089","html_url":"https://github.com/Curt-Park/segment-anything-with-clip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"annotation-ai/python-project-template","purl":"pkg:github/Curt-Park/segment-anything-with-clip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curt-Park%2Fsegment-anything-with-clip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curt-Park%2Fsegment-anything-with-clip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curt-Park%2Fsegment-anything-with-clip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curt-Park%2Fsegment-anything-with-clip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Curt-Park","download_url":"https://codeload.github.com/Curt-Park/segment-anything-with-clip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Curt-Park%2Fsegment-anything-with-clip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016885,"owners_count":26085912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"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":["colab-notebook","huggingface-spaces","machine-learning","nlp-machine-learning","segmentation-model"],"created_at":"2024-11-15T19:29:31.583Z","updated_at":"2025-10-13T21:02:24.261Z","avatar_url":"https://github.com/Curt-Park.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Segment Anything with Clip\n[[HuggingFace Space](https://huggingface.co/spaces/curt-park/segment-anything-with-clip)] | [[COLAB](https://colab.research.google.com/github/Curt-Park/segment-anything-with-clip/blob/main/colab.ipynb)] | [[Demo Video](https://youtu.be/vM7MfAc3BdQ)]\n\nMeta released [a new foundation model for segmentation tasks](https://ai.facebook.com/blog/segment-anything-foundation-model-image-segmentation/).\nIt aims to resolve downstream segmentation tasks with prompt engineering, such as foreground/background points, bounding box, mask, and free-formed text.\nHowever, the text prompt is not released yet.\n\nAlternatively, I took the following steps:\n1. Get all object proposals generated by SAM (Segment Anything Model).\n2. Crop the object regions by bounding boxes.\n3. Get cropped images' features and a query feature from [CLIP](https://openai.com/research/clip).\n4. Calculate the similarity between image features and the query feature.\n```python\n# How to get the similarity.\npreprocessed_img = preprocess(crop).unsqueeze(0)\ntokens = clip.tokenize(texts)\nlogits_per_image, _ = model(preprocessed_img, tokens)\nsimilarity = logits_per_image.softmax(-1)\n```\n\n## How to run on local\n[Anaconda](https://www.anaconda.com/) is required before start setup.\n```bash\nmake env\nconda activate segment-anything-with-clip\nmake setup\n```\n\n```bash\n# this executes GRadio server.\nmake run\n```\nOpen http://localhost:7860/\n![](https://user-images.githubusercontent.com/14961526/232016821-dda192c1-1095-4086-adb8-e6a9f44b685f.png)\n\n## Successive Works\n- [Fast Segment Everything](https://huggingface.co/spaces/Annotation-AI/fast-segment-everything): Re-implemented *Everything* algorithm in iterative manner that is better for CPU only environments. It shows comparable results to the original Everything within 1/5 number of inferences (e.g. 1024 vs 200), and it takes under 10 seconds to search for masks on a `CPU upgrade` instance (8 vCPU, 32GB RAM) of Huggingface space.\n- [Fast Segment Everything with Text Prompt](https://huggingface.co/spaces/Annotation-AI/fast-segment-everything-with-text-prompt): This example based on Fast-Segment-Everything provides a text prompt that generates an attention map for the area you want to focus on.\n- [Fast Segment Everything with Image Prompt](https://huggingface.co/spaces/Annotation-AI/fast-segment-everything-with-image-prompt): This example based on Fast-Segment-Everything provides an image prompt that generates an attention map for the area you want to focus on.\n- [Fast Segment Everything with Drawing Prompt](https://huggingface.co/spaces/Annotation-AI/fast-segment-everything-with-drawing-prompt): This example based on Fast-Segment-Everything provides a drawing prompt that generates an attention map for the area you want to focus on.\n\n## References\n- https://github.com/facebookresearch/segment-anything\n- https://github.com/openai/CLIP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurt-park%2Fsegment-anything-with-clip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurt-park%2Fsegment-anything-with-clip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurt-park%2Fsegment-anything-with-clip/lists"}