| <!--Copyright 2021 The HuggingFace Team. All rights reserved. | |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | |
| the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| specific language governing permissions and limitations under the License. | |
| โ ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | |
| rendered properly in your Markdown viewer. | |
| --> | |
| # CLIP[[clip]] | |
| ## ๊ฐ์[[overview]] | |
| CLIP ๋ชจ๋ธ์ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, | |
| Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, Ilya Sutskever๊ฐ ์ ์ํ [์์ฐ์ด ์ง๋(supervision)๋ฅผ ํตํ ์ ์ด ๊ฐ๋ฅํ ์๊ฐ ๋ชจ๋ธ ํ์ต](https://huggingface.co/papers/2103.00020)๋ผ๋ ๋ ผ๋ฌธ์์ ์๊ฐ๋์์ต๋๋ค. CLIP(Contrastive Language-Image Pre-Training)์ ๋ค์ํ ์ด๋ฏธ์ง์ ํ ์คํธ ์์ผ๋ก ํ๋ จ๋ ์ ๊ฒฝ๋ง ์ ๋๋ค. GPT-2์ 3์ ์ ๋ก์ท ๋ฅ๋ ฅ๊ณผ ์ ์ฌํ๊ฒ, ํด๋น ์์ ์ ์ง์ ์ ์ผ๋ก ์ต์ ํํ์ง ์๊ณ ๋ ์ฃผ์ด์ง ์ด๋ฏธ์ง์ ๋ํด ๊ฐ์ฅ ๊ด๋ จ์ฑ ์๋ ํ ์คํธ ์ค๋ํซ์ ์์ธกํ๋๋ก ์์ฐ์ด๋ก ์ง์ํ ์ ์์ต๋๋ค. | |
| ํด๋น ๋ ผ๋ฌธ์ ์ด๋ก์ ๋๋ค. | |
| *์ต์ ์ปดํจํฐ ๋น์ ์์คํ ์ ๋ฏธ๋ฆฌ ์ ํด์ง ๊ณ ์ ๋ ๊ฐ์ฒด ์นดํ ๊ณ ๋ฆฌ ์งํฉ์ ์์ธกํ๋๋ก ํ๋ จ๋ฉ๋๋ค. ์ด๋ฌํ ์ ํ๋ ํํ์ ์ง๋๋ ๋ค๋ฅธ ์๊ฐ์ ๊ฐ๋ ์ ์ง์ ํ๊ธฐ ์ํด ์ถ๊ฐ์ ์ธ ๋ผ๋ฒจ๋ง๋ ๋ฐ์ดํฐ๊ฐ ํ์ํ๋ฏ๋ก ๊ทธ ์ผ๋ฐ์ฑ๊ณผ ์ฌ์ฉ์ฑ์ ์ ํํฉ๋๋ค. ์ด๋ฏธ์ง ์์ ํ ์คํธ์์ ์ง์ ํ์ตํ๋ ๊ฒ์ ํจ์ฌ ๋ ๊ด๋ฒ์ํ ์ง๋ ์์ค๋ฅผ ํ์ฉํ๋ ์์ฃผ ์ข์ ๋์์ ๋๋ค. ์ด๋ฏธ์ง์ ์บก์ ์ ๋ง์ถ๋ ๊ฐ๋จํ ์ฌ์ ํ์ต ์์ ์ด, ์ธํฐ๋ท์์ ์์งํ 4์ต ์์ ์ด๋ฏธ์ง-ํ ์คํธ ๋ฐ์ดํฐ์ ์์ SOTA ์์ค์ ์ด๋ฏธ์ง ํํ์ ์ฒ์๋ถํฐ ํจ์จ์ ์ด๊ณ ํ์ฅ ๊ฐ๋ฅํ๊ฒ ํ์ตํ๋ ๋ฐฉ๋ฒ์์ ํ์ธํ ์ ์์ต๋๋ค. ์ฌ์ ํ๋ จ ํ, ์์ฐ์ด๋ ํ์ต๋ ์๊ฐ์ ๊ฐ๋ ์ ์ฐธ์กฐํ๊ฑฐ๋ ์๋ก์ด ๊ฐ๋ ์ ์ค๋ช ํ๋ ๋ฐ ์ฌ์ฉ๋์ด ๋ชจ๋ธ์ ํ์ ์์ ์ผ๋ก์ ์ ๋ก์ท ์ ์ด๋ฅผ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค. ํด๋น ๋ ผ๋ฌธ์์๋ OCR, ๋น๋์ค ๋ด ํ๋ ์ธ์, ์ง๋ฆฌ์ ์์น ํ์ , ๊ทธ๋ฆฌ๊ณ ๋ง์ ์ข ๋ฅ์ ์ธ๋ฐํ ๊ฐ์ฒด ๋ถ๋ฅ ๋ฑ 30๊ฐ ์ด์์ ๋ค์ํ ๊ธฐ์กด ์ปดํจํฐ ๋น์ ๋ฐ์ดํฐ์ ์ ๋ํ ๋ฒค์น๋งํน์ ํตํด ์ด ์ ๊ทผ ๋ฐฉ์์ ์ฑ๋ฅ์ ์ฐ๊ตฌํฉ๋๋ค. ์ด ๋ชจ๋ธ์ ๋๋ถ๋ถ์ ์์ ์ ๋ํด ์๋ฏธ ์๊ฒ ์ ์ด๋๋ฉฐ, ์ข ์ข ๋ฐ์ดํฐ์ ๋ณ ํ๋ จ ์์ด๋ ์์ ์ง๋ ํ์ต ๊ธฐ์ค์ ๊ณผ ๊ฒฝ์๋ ฅ ์๋ ์ฑ๋ฅ์ ๋ณด์ ๋๋ค. ์๋ฅผ ๋ค์ด, ImageNet์์ ์๋ ResNet-50์ ์ ํ๋๋ฅผ ์ ๋ก์ท์ผ๋ก ์ผ์น์ํค๋๋ฐ, ์ด๋ ResNet-50์ด ํ๋ จ๋ 128๋ง ๊ฐ์ ํ๋ จ ์์ ๋ฅผ ์ ํ ์ฌ์ฉํ ํ์๊ฐ ์์์ต๋๋ค. ์ฝ๋ ๋ฐ ์ฌ์ ํ๋ จ๋ ๋ชจ๋ธ ๊ฐ์ค์น๋ ์ด https URL์์ ๊ณต๊ฐํฉ๋๋ค.* | |
| ์ด ๋ชจ๋ธ์ [valhalla](https://huggingface.co/valhalla)์ ์ํด ๊ธฐ์ฌ๋์์ต๋๋ค. | |
| ์๋ณธ ์ฝ๋๋ [์ด๊ณณ](https://github.com/openai/CLIP)์์ ํ์ธํ ์ ์์ต๋๋ค. | |
| ## ์ฌ์ฉ ํ๊ณผ ์์[[usage-tips-and-example]] | |
| CLIP์ ๋ฉํฐ๋ชจ๋ฌ ๋น์ ๋ฐ ์ธ์ด ๋ชจ๋ธ์ ๋๋ค. ์ด๋ฏธ์ง-ํ ์คํธ ์ ์ฌ๋ ๊ณ์ฐ๊ณผ ์ ๋ก์ท ์ด๋ฏธ์ง ๋ถ๋ฅ์ ์ฌ์ฉ๋ ์ ์์ต๋๋ค. CLIP์ ViT์ ์ ์ฌํ ํธ๋์คํฌ๋จธ๋ฅผ ์ฌ์ฉํ์ฌ ์๊ฐ์ ํน์ง์ ์ถ์ถํ๊ณ , ์ธ๊ณผ์ ์ธ์ด ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ํ ์คํธ ํน์ง์ ์ถ์ถํฉ๋๋ค. ๊ทธ ํ ํ ์คํธ์ ์๊ฐ์ ํน์ง ๋ชจ๋ ๋์ผํ ์ฐจ์์ ์ ์ฌ(latent) ๊ณต๊ฐ์ผ๋ก ํฌ์๋ฉ๋๋ค. ํฌ์๋ ์ด๋ฏธ์ง์ ํ ์คํธ ํน์ง ์ฌ์ด์ ๋ด์ ์ด ์ ์ฌ๋ ์ ์๋ก ์ฌ์ฉ๋ฉ๋๋ค. | |
| ํธ๋์คํฌ๋จธ ์ธ์ฝ๋์ ์ด๋ฏธ์ง๋ฅผ ์ ๋ ฅํ๊ธฐ ์ํด, ๊ฐ ์ด๋ฏธ์ง๋ ๊ณ ์ ํฌ๊ธฐ์ ๊ฒน์น์ง ์๋ ํจ์น๋ค์ ์ํ์ค๋ก ๋ถํ ๋๊ณ , ์ดํ ์ ํ ์๋ฒ ๋ฉ๋ฉ๋๋ค. [CLS]ํ ํฐ์ด ์ ์ฒด ์ด๋ฏธ์ง์ ํํ์ผ๋ก ์ถ๊ฐ๋ฉ๋๋ค. ์ ์๋ค์ ๋ํ ์ ๋ ์์น ์๋ฒ ๋ฉ์ ์ถ๊ฐํ๊ณ , ๊ฒฐ๊ณผ๋ก ๋์จ ๋ฒกํฐ ์ํ์ค๋ฅผ ํ์ค ํธ๋์คํฌ๋จธ ์ธํ ๋์ ์ ๋ ฅํฉ๋๋ค. [`CLIPImageProcessor`]๋ ๋ชจ๋ธ์ ์ํด ์ด๋ฏธ์ง๋ฅผ ๋ฆฌ์ฌ์ด์ฆ(๋๋ ์ฌ์ค์บ์ผ๋ง)ํ๊ณ ์ ๊ทํํ๋๋ฐ ์ฌ์ฉ๋ ์ ์์ต๋๋ค. | |
| [`CLIPTokenizer`]๋ ํ ์คํธ๋ฅผ ์ธ์ฝ๋ฉํ๋๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. [`CLIPProcessor`]๋ [`CLIPImageProcessor`]์ [`CLIPTokenizer`]๋ฅผ ํ๋์ ์ธ์คํด์ค๋ก ๊ฐ์ธ์ ํ ์คํธ๋ฅผ ์ธ์ฝ๋ฉํ๊ณ ์ด๋ฏธ์ง๋ฅผ ์ค๋นํ๋๋ฐ ๋ชจ๋ ์ฌ์ฉ๋ฉ๋๋ค. | |
| ๋ค์ ์์๋ [`CLIPProcessor`]์ [`CLIPModel`]์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง-ํ ์คํธ ์ ์ฌ๋ ์ ์๋ฅผ ์ป๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. | |
| ```python | |
| >>> from PIL import Image | |
| >>> import requests | |
| >>> from transformers import CLIPProcessor, CLIPModel | |
| >>> model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") | |
| >>> processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") | |
| >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" | |
| >>> image = Image.open(requests.get(url, stream=True).raw) | |
| >>> inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True) | |
| >>> outputs = model(**inputs) | |
| >>> logits_per_image = outputs.logits_per_image # ์ด๋ฏธ์ง-ํ ์คํธ ์ ์ฌ์ฑ ์ ์ | |
| >>> probs = logits_per_image.softmax(dim=1) # ํ๋ฅ ์ ๋ ์ด๋ธ๋ง ํ๊ธฐ์ํด์ ์ํํธ๋งฅ์ค๋ฅผ ์ทจํฉ๋๋ค. | |
| ``` | |
| ### CLIP๊ณผ ํ๋์ ์ดํ ์ 2 ๊ฒฐํฉ[[combining-clip-and-flash-attention-2]] | |
| ๋จผ์ ์ต์ ๋ฒ์ ์ ํ๋์ ์ดํ ์ 2๋ฅผ ์ค์นํฉ๋๋ค. | |
| ```bash | |
| pip install -U flash-attn --no-build-isolation | |
| ``` | |
| ํ๋์ ์ดํ ์ 2์ ํธํ๋๋ ํ๋์จ์ด๋ฅผ ๊ฐ์ง๊ณ ์๋์ง ํ์ธํ์ธ์. ์ด์ ๋ํ ์์ธํ ๋ด์ฉ์ flash-attn ๋ฆฌํฌ์งํ ๋ฆฌ์ ๊ณต์๋ฌธ์์์ ํ์ธํ ์ ์์ต๋๋ค. ๋ํ ๋ชจ๋ธ์ ๋ฐ์ ๋ฐ๋(`torch.float16`)๋ก ๋ก๋ํ๋ ๊ฒ์ ์์ง ๋ง์ธ์. | |
| <Tip warning={true}> | |
| ์์ ๋ฐฐ์น ํฌ๊ธฐ๋ฅผ ์ฌ์ฉํ ๋, ํ๋์ ์ดํ ์ ์ ์ฌ์ฉํ๋ฉด ๋ชจ๋ธ์ด ๋๋ ค์ง๋ ๊ฒ์ ๋๋ ์ ์์ต๋๋ค.์๋์ [ํ๋์ ์ดํ ์ ๊ณผ SDPA๋ฅผ ์ฌ์ฉํ ์์ ์๋ ํฅ์](#Expected-speedups-with-Flash-Attention-and-SDPA) ์น์ ์ ์ฐธ์กฐํ์ฌ ์ ์ ํ ์ดํ ์ ๊ตฌํ์ ์ ํํ์ธ์. | |
| </Tip> | |
| ํ๋์ ์ดํ ์ 2๋ฅผ ์ฌ์ฉํด์ ๋ชจ๋ธ์ ๋ก๋ํ๊ณ ๊ตฌ๋ํ๊ธฐ ์ํด์ ๋ค์ ์ค๋ํซ์ ์ฐธ๊ณ ํ์ธ์: | |
| ```python | |
| >>> import torch | |
| >>> import requests | |
| >>> from PIL import Image | |
| >>> from transformers import CLIPProcessor, CLIPModel | |
| >>> device = "cuda" | |
| >>> dtype = torch.float16 | |
| >>> model = CLIPModel.from_pretrained( | |
| ... "openai/clip-vit-base-patch32", | |
| ... attn_implementation="flash_attention_2", | |
| ... device_map=device, | |
| ... dtype=dtype, | |
| ... ) | |
| >>> processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") | |
| >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" | |
| >>> image = Image.open(requests.get(url, stream=True).raw) | |
| >>> inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True) | |
| >>> inputs.to(device) | |
| >>> with torch.no_grad(): | |
| ... with torch.autocast(device): | |
| ... outputs = model(**inputs) | |
| >>> logits_per_image = outputs.logits_per_image # ์ด๋ฏธ์ง-ํ ์คํธ ์ ์ฌ์ฑ ์ ์ | |
| >>> probs = logits_per_image.softmax(dim=1) # ํ๋ฅ ์ ๋ ์ด๋ธ๋ง ํ๊ธฐ์ํด์ ์ํํธ๋งฅ์ค๋ฅผ ์ทจํฉ๋๋ค. | |
| >>> print(probs) | |
| tensor([[0.9946, 0.0052]], device='cuda:0', dtype=torch.float16) | |
| ``` | |
| ### ์ค์ผ์ผ๋ ๋ด์ ์ดํ ์ (Scaled dot-product Attention(SDPA)) ์ฌ์ฉํ๊ธฐ[[using-scaled-dot-product-attention-sdpa]] | |
| ํ์ดํ ์น๋ `torch.nn.functional`์ ์ผ๋ถ๋ก ๋ค์ดํฐ๋ธ ์ค์ผ์ผ๋ ๋ด์ ์ดํ ์ (SPDA) ์ฐ์ฐ์๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค. ์ด ํจ์๋ ์ ๋ ฅ๊ณผ ์ฌ์ฉ ์ค์ธ ํ๋์จ์ด์ ๋ฐ๋ผ ์ ์ฉ๋ ์ ์๋ ์ฌ๋ฌ ๊ตฌํ์ ํฌํจํฉ๋๋ค. ์์ธํ ์ ๋ณด๋ [๊ณต์๋ฌธ์](https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html)๋ [GPU ์ถ๋ก ](https://huggingface.co/docs/transformers/main/en/perf_infer_gpu_one#pytorch-scaled-dot-product-attention) ํ์ด์ง๋ฅผ ์ฐธ์กฐํ์ธ์. | |
| `torch>=2.1.1`์์๋ ๊ตฌํ์ด ๊ฐ๋ฅํ ๋ SDPA๊ฐ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉ๋์ง๋ง, `from_pretrained()` ํจ์์์ `attn_implementation="sdpa"`๋ฅผ ์ค์ ํ์ฌ SDPA๋ฅผ ๋ช ์์ ์ผ๋ก ์ฌ์ฉํ๋๋ก ์์ฒญํ ์๋ ์์ต๋๋ค. | |
| ```python | |
| from transformers import CLIPModel | |
| model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32", dtype=torch.float16, attn_implementation="sdpa") | |
| ``` | |
| ์ต๊ณ ์ ์๋ํฅ์์ ์ํด์, ๋ฐ์ ๋ฐ๋๋ก ๋ชจ๋ธ์ ๋ก๋ํ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค. (์๋ฅผ๋ค๋ฉด `torch.float16` ๋๋ `torch.bfloat16`). | |
| ### ํ๋์ ์ดํ ์ ๊ณผ ์ค์ผ์ผ๋ ๋ด์ ์ดํ ์ (SDPA)์ผ๋ก ์ธํด ์์๋๋ ์๋ํฅ์[[expected-speedups-with-flash-attention-and-sdpa]] | |
| ๋ก์ปฌ ๋ฒค์น๋งํฌ(NVIDIA A10G, PyTorch 2.3.1+cu121)์์ `float16`์ ์ฌ์ฉํ์ฌ `"openai/clip-vit-large-patch14"` ์ฒดํฌํฌ์ธํธ๋ก ์ถ๋ก ์ ์ํํ์ ๋, ๋ค์๊ณผ ๊ฐ์ ์๋ ํฅ์์ ํ์ธ ํ์ต๋๋ค. | |
| [์ฝ๋](https://gist.github.com/qubvel/ac691a54e54f9fae8144275f866a7ff8): | |
| #### CLIPTextModel[[cliptextmodel]] | |
| | Num text labels | Eager (s/iter) | FA2 (s/iter) | FA2 speedup | SDPA (s/iter) | SDPA speedup | | |
| |------------------:|-----------------:|---------------:|--------------:|----------------:|---------------:| | |
| | 4 | 0.009 | 0.012 | 0.737 | 0.007 | 1.269 | | |
| | 16 | 0.009 | 0.014 | 0.659 | 0.008 | 1.187 | | |
| | 32 | 0.018 | 0.021 | 0.862 | 0.016 | 1.142 | | |
| | 64 | 0.034 | 0.034 | 1.001 | 0.03 | 1.163 | | |
| | 128 | 0.063 | 0.058 | 1.09 | 0.054 | 1.174 | | |
|  | |
| #### CLIPVisionModel[[clipvisionmodel]] | |
| | Image batch size | Eager (s/iter) | FA2 (s/iter) | FA2 speedup | SDPA (s/iter) | SDPA speedup | | |
| |-------------------:|-----------------:|---------------:|--------------:|----------------:|---------------:| | |
| | 1 | 0.016 | 0.013 | 1.247 | 0.012 | 1.318 | | |
| | 4 | 0.025 | 0.021 | 1.198 | 0.021 | 1.202 | | |
| | 16 | 0.093 | 0.075 | 1.234 | 0.075 | 1.24 | | |
| | 32 | 0.181 | 0.147 | 1.237 | 0.146 | 1.241 | | |
|  | |
| #### CLIPModel[[clipmodel]] | |
| | Image batch size | Num text labels | Eager (s/iter) | FA2 (s/iter) | FA2 speedup | SDPA (s/iter) | SDPA speedup | | |
| |-------------------:|------------------:|-----------------:|---------------:|--------------:|----------------:|---------------:| | |
| | 1 | 4 | 0.025 | 0.026 | 0.954 | 0.02 | 1.217 | | |
| | 1 | 16 | 0.026 | 0.028 | 0.918 | 0.02 | 1.287 | | |
| | 1 | 64 | 0.042 | 0.046 | 0.906 | 0.036 | 1.167 | | |
| | 4 | 4 | 0.028 | 0.033 | 0.849 | 0.024 | 1.189 | | |
| | 4 | 16 | 0.034 | 0.035 | 0.955 | 0.029 | 1.169 | | |
| | 4 | 64 | 0.059 | 0.055 | 1.072 | 0.05 | 1.179 | | |
| | 16 | 4 | 0.096 | 0.088 | 1.091 | 0.078 | 1.234 | | |
| | 16 | 16 | 0.102 | 0.09 | 1.129 | 0.083 | 1.224 | | |
| | 16 | 64 | 0.127 | 0.11 | 1.157 | 0.105 | 1.218 | | |
| | 32 | 4 | 0.185 | 0.159 | 1.157 | 0.149 | 1.238 | | |
| | 32 | 16 | 0.19 | 0.162 | 1.177 | 0.154 | 1.233 | | |
| | 32 | 64 | 0.216 | 0.181 | 1.19 | 0.176 | 1.228 | | |
| ## ์๋ฃ[[resources]] | |
| CLIP์ ์์ํ๋ ๋ฐ ๋์์ด ๋๋ Hugging Face์ community ์๋ฃ ๋ชฉ๋ก(๐๋ก ํ์๋จ) ์ ๋๋ค. | |
| - [์๊ฒฉ ์ผ์ฑ (์ธ๊ณต์์ฑ) ์ด๋ฏธ์ง์ ์บก์ ์ ๊ฐ์ง๊ณ CLIP ๋ฏธ์ธ์กฐ์ ํ๊ธฐ](https://huggingface.co/blog/fine-tune-clip-rsicd): | |
| [RSICD dataset](https://github.com/201528014227051/RSICD_optimal)์ ๊ฐ์ง๊ณ CLIP์ ๋ฏธ์ธ์กฐ์ ํ๋ ๋ฐฉ๋ฒ๊ณผ ๋ฐ์ดํฐ ์ฆ๊ฐ์ ๋ํ ์ฑ๋ฅ ๋น๊ต์ ๋ํ ๋ธ๋ก๊ทธ ํฌ์คํธ | |
| - ์ด [์์ ์คํฌ๋ฆฝํธ](https://github.com/huggingface/transformers/tree/main/examples/pytorch/contrastive-image-text)๋ [COCO dataset](https://cocodataset.org/#home)๋ฅผ ์ด์ฉํ ์ฌ์ ํ์ต๋ ๋น์ ๊ณผ ํ ์คํธ์ ์ธ์ฝ๋๋ฅผ ์ฌ์ฉํด์ CLIP๊ฐ์ ๋น์ -ํ ์คํธ ๋์ผ ๋ชจ๋ธ์ ์ด๋ป๊ฒ ํ์ต์ํค๋์ง ๋ณด์ฌ์ค๋๋ค. | |
| <PipelineTag pipeline="image-to-text"/> | |
| - ์ฌ์ ํ์ต๋ CLIP๋ชจ๋ธ์ ์ด๋ฏธ์ง ์บก์ ๋์ ์ํ ๋น์์น ์ถ๋ก ์ ์ด๋ป๊ฒ ํ์ฉํ๋์ง์ ๊ดํ [๋ ธํธ๋ถ](https://colab.research.google.com/drive/1tuoAC5F4sC7qid56Z0ap-stR3rwdk0ZV?usp=sharing) | |
| **์ด๋ฏธ์ง ๊ฒ์** | |
| - ์ฌ์ ํ์ต๋ CLIP๋ชจ๋ธ๊ณผ MRR(Mean Reciprocal Rank) ์ ์ ์ฐ์ฐ์ ์ฌ์ฉํ ์ด๋ฏธ์ง ๊ฒ์์ ๋ํ [๋ ธํธ๋ถ](https://colab.research.google.com/drive/1bLVwVKpAndpEDHqjzxVPr_9nGrSbuOQd?usp=sharing). ๐ | |
| - ์ด๋ฏธ์ง ๊ฒ์๊ณผ ์ ์ฌ์ฑ ์ ์์ ๋ํด ๋ณด์ฌ์ฃผ๋ [๋ ธํธ๋ถ](https://colab.research.google.com/github/deep-diver/image_search_with_natural_language/blob/main/notebooks/Image_Search_CLIP.ipynb). ๐ | |
| - Multilingual CLIP๋ฅผ ์ฌ์ฉํด์ ์ด๋ฏธ์ง์ ํ ์คํธ๋ฅผ ์ด๋ป๊ฒ ๊ฐ์ ๋ฒกํฐ ๊ณต๊ฐ์ ๋งคํ ์ํค๋์ง์ ๋ํ [๋ ธํธ๋ถ](https://colab.research.google.com/drive/1xO-wC_m_GNzgjIBQ4a4znvQkvDoZJvH4?usp=sharing). ๐ | |
| - [Unsplash](https://unsplash.com)์ [TMDB](https://www.themoviedb.org/) ๋ฐ์ดํฐ์ ์ ํ์ฉํ ์๋ฏธ๋ก ์ (semantic) ์ด๋ฏธ์ง ๊ฒ์์์ CLIP์ ๊ตฌ๋ํ๋ ๋ฐฉ๋ฒ์ ๋ํ [๋ ธํธ๋ถ](https://colab.research.google.com/github/vivien000/clip-demo/blob/master/clip.ipynb#scrollTo=uzdFhRGqiWkR). ๐ | |
| **์ค๋ช ๊ฐ๋ฅ์ฑ** | |
| - ์ ๋ ฅ ํ ํฐ๊ณผ ์ด๋ฏธ์ง ์กฐ๊ฐ(segment) ์ฌ์ด์ ์ ์ฌ์ฑ์ ์๊ฐํ ์ํค๋ ๋ฐฉ๋ฒ์ ๋ํ [๋ ธํธ๋ถ](https://colab.research.google.com/github/hila-chefer/Transformer-MM-Explainability/blob/main/CLIP_explainability.ipynb). ๐ | |
| ์ฌ๊ธฐ์ ํฌํจ๋ ์๋ฃ๋ฅผ ์ ์ถํ๊ณ ์ถ์ผ์๋ค๋ฉด PR(Pull Request)๋ฅผ ์ด์ด์ฃผ์ธ์. ๋ฆฌ๋ทฐ ํด๋๋ฆฌ๊ฒ ์ต๋๋ค! ์๋ฃ๋ ๊ธฐ์กด ์๋ฃ๋ฅผ ๋ณต์ ํ๋ ๋์ ์๋ก์ด ๋ด์ฉ์ ๋ด๊ณ ์์ด์ผ ํฉ๋๋ค. | |
| ## CLIPConfig[[transformers.CLIPConfig]] | |
| [[autodoc]] CLIPConfig | |
| ## CLIPTextConfig[[transformers.CLIPTextConfig]] | |
| [[autodoc]] CLIPTextConfig | |
| ## CLIPVisionConfig[[transformers.CLIPVisionConfig]] | |
| [[autodoc]] CLIPVisionConfig | |
| ## CLIPTokenizer[[transformers.CLIPTokenizer]] | |
| [[autodoc]] CLIPTokenizer | |
| - get_special_tokens_mask | |
| - save_vocabulary | |
| ## CLIPTokenizerFast[[transformers.CLIPTokenizerFast]] | |
| [[autodoc]] CLIPTokenizerFast | |
| ## CLIPImageProcessor[[transformers.CLIPImageProcessor]] | |
| [[autodoc]] CLIPImageProcessor | |
| - preprocess | |
| ## CLIPProcessor[[transformers.CLIPProcessor]] | |
| [[autodoc]] CLIPProcessor | |
| ## CLIPModel[[transformers.CLIPModel]] | |
| [[autodoc]] CLIPModel | |
| - forward | |
| - get_text_features | |
| - get_image_features | |
| ## CLIPTextModel[[transformers.CLIPTextModel]] | |
| [[autodoc]] CLIPTextModel | |
| - forward | |
| ## CLIPTextModelWithProjection[[transformers.CLIPTextModelWithProjection]] | |
| [[autodoc]] CLIPTextModelWithProjection | |
| - forward | |
| ## CLIPVisionModelWithProjection[[transformers.CLIPVisionModelWithProjection]] | |
| [[autodoc]] CLIPVisionModelWithProjection | |
| - forward | |
| ## CLIPVisionModel[[transformers.CLIPVisionModel]] | |
| [[autodoc]] CLIPVisionModel | |
| - forward | |
| ## CLIPForImageClassification[[transformers.CLIPForImageClassification]] | |
| [[autodoc]] CLIPForImageClassification | |
| - forward | |