{"id":16735318,"url":"https://github.com/merveenoyan/siglip","last_synced_at":"2025-04-04T14:06:45.753Z","repository":{"id":215435555,"uuid":"738939565","full_name":"merveenoyan/siglip","owner":"merveenoyan","description":"Projects based on SigLIP (Zhai et. al, 2023) and Hugging Face transformers integration 🤗","archived":false,"fork":false,"pushed_at":"2025-02-21T10:31:29.000Z","size":1737,"stargazers_count":224,"open_issues_count":2,"forks_count":12,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-28T13:11:08.353Z","etag":null,"topics":["computer-vision","machine-learning","multimodal-learning","siglip"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/merveenoyan.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":"2024-01-04T11:56:49.000Z","updated_at":"2025-03-25T21:49:20.000Z","dependencies_parsed_at":"2024-10-28T11:34:53.807Z","dependency_job_id":"95689538-40bd-491f-98f4-dfdda6557f6e","html_url":"https://github.com/merveenoyan/siglip","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"660544447c9bae582c0887aea62cfdeb4fabd231"},"previous_names":["merveenoyan/siglip"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merveenoyan%2Fsiglip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merveenoyan%2Fsiglip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merveenoyan%2Fsiglip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merveenoyan%2Fsiglip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/merveenoyan","download_url":"https://codeload.github.com/merveenoyan/siglip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190250,"owners_count":20898702,"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","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":["computer-vision","machine-learning","multimodal-learning","siglip"],"created_at":"2024-10-13T00:05:31.216Z","updated_at":"2025-04-04T14:06:45.735Z","avatar_url":"https://github.com/merveenoyan.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SigLIP Projects 📎📓\n\nSigLIP is [CLIP](https://huggingface.co/docs/transformers/model_doc/clip), a multimodal model, with a better loss function. The sigmoid loss operates solely on image-text pairs and does not require a global view of the pairwise similarities for normalization. This allows further scaling up the batch size, while also performing better at smaller batch sizes. \n\n**Update:** SigLIP 2 is released today, here's [an intuitive explanation](https://huggingface.co/blog/siglip2) about what's new, and Naflex variant.\n\nA TL;DR of SigLIP by one of the authors can be found [here](https://twitter.com/giffmana/status/1692641733459267713).\n\n## What is this repository for? 👀\n\nThis repository shows how you can utilize [SigLIP](https://arxiv.org/abs/2303.15343) and SigLIP 2 for search in different modalities.\n\n📚 It contains:\n- A notebook on how to create an embedding index using SigLIP with Hugging Face Transformers and FAISS,\n- An image similarity search application that uses the created index, ([link to 🤗Space](https://huggingface.co/spaces/merve/draw_to_search_art))\n- An application that compares SigLIP and CLIP ([link to the 🤗Space](https://huggingface.co/spaces/merve/compare_clip_siglip))\n- Another notebook to index text embeddings the 🤗datasets-FAISS integration.\n  \n\u003cimg width=\"1014\" alt=\"Screenshot 2024-01-08 at 22 23 44\" src=\"https://github.com/merveenoyan/siglip/assets/53175384/c621f100-2f29-407e-a233-1f74f4919131\"\u003e\n\n\n\n## Intended uses \u0026 limitations\n\nYou can use the raw SigLIP for tasks like zero-shot image classification and image-text retrieval. See the [SigLIP checkpoints on Hugging Face Hub](https://huggingface.co/models?search=google/siglip) to look for other versions on a task that interests you.\n\n### How to use with 🤗transformers\n\nHere is how to use this model to perform zero-shot image classification. This also supports SigLIP 2 checkpoints. For Naflex variant, use `padding=\"max_length\", max_length=64\"`.\n\n```python\nfrom PIL import Image\nimport requests\nfrom transformers import AutoProcessor, AutoModel\nimport torch\n\nmodel = AutoModel.from_pretrained(\"google/siglip-base-patch16-256-i18n\")\nprocessor = AutoProcessor.from_pretrained(\"google/siglip-base-patch16-256-i18n\")\n\nurl = \"http://images.cocodataset.org/val2017/000000039769.jpg\"\nimage = Image.open(requests.get(url, stream=True).raw)\n\ntexts = [\"a photo of 2 cats\", \"a photo of 2 dogs\"]\ninputs = processor(text=texts, images=image, return_tensors=\"pt\")\n\nwith torch.no_grad():\n    outputs = model(**inputs)\n\nlogits_per_image = outputs.logits_per_image\nprobs = torch.sigmoid(logits_per_image) # these are the probabilities\nprint(f\"{probs[0][0]:.1%} that image 0 is '{texts[0]}'\")\n```\n\nAlternatively, one can leverage the pipeline API which abstracts away the complexity for the user:\n\n```\nfrom transformers import pipeline\nfrom PIL import Image\nimport requests\n\n# load pipe\nimage_classifier = pipeline(task=\"zero-shot-image-classification\", model=\"google/siglip-base-patch16-256-i18n\")\n\n# load image\nurl = 'http://images.cocodataset.org/val2017/000000039769.jpg'\nimage = Image.open(requests.get(url, stream=True).raw)\n\n# inference\noutputs = image_classifier(image, candidate_labels=[\"2 cats\", \"a plane\", \"a remote\"])\noutputs = [{\"score\": round(output[\"score\"], 4), \"label\": output[\"label\"] } for output in outputs]\nprint(outputs)\n```\nFor more code examples, we refer to the [documentation](https://huggingface.co/transformers/main/model_doc/siglip.html#).\n\n\n\n**Citation**\n\n```bibtex\n@misc{zhai2023sigmoid,\n      title={Sigmoid Loss for Language Image Pre-Training}, \n      author={Xiaohua Zhai and Basil Mustafa and Alexander Kolesnikov and Lucas Beyer},\n      year={2023},\n      eprint={2303.15343},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerveenoyan%2Fsiglip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerveenoyan%2Fsiglip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerveenoyan%2Fsiglip/lists"}