File size: 5,571 Bytes
a9bd396 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | <!--Copyright 2022 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.
-->
# CLIPSeg[[clipseg]]
<div class="flex flex-wrap space-x-1">
<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&logo=pytorch&logoColor=white">
</div>
## ๊ฐ์[[overview]]
CLIPSeg ๋ชจ๋ธ์ Timo Lรผddecke์ Alexander Ecker๊ฐ [Image Segmentation Using Text and Image Prompts](https://huggingface.co/papers/2112.10003) ๋
ผ๋ฌธ์์ ์ ์ํ์ต๋๋ค. CLIPSeg๋ ๊ฐ์ค์น๊ฐ ๊ณ ์ ๋ CLIP ๋ชจ๋ธ์ ์ต์ํ์ ๋์ฝ๋๋ฅผ ๊ฒฐํฉํ์ฌ ์ ๋ก์ท ๋ฐ ์์ท ์ด๋ฏธ์ง ๋ถํ ์ ์ํํฉ๋๋ค.
๋
ผ๋ฌธ ์ด๋ก์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
*์ด๋ฏธ์ง ๋ถํ ์ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ ์ ์ ์๋ ๊ฐ์ฒด ํด๋์ค ์งํฉ์ ๋ํด ๋ชจ๋ธ์ ํ๋ จ์ํค๋ ๋ฐฉ์์ผ๋ก ์ ๊ทผํฉ๋๋ค. ํ์ง๋ง ์๋ก์ด ํด๋์ค๋ฅผ ์ถ๊ฐํ๊ฑฐ๋ ๋ณด๋ค ๋ณต์กํ ์ง์๋ฅผ ์ฒ๋ฆฌํ๋ ค๋ฉด, ํด๋น ๋ด์ฉ์ ํฌํจํ ๋ฐ์ดํฐ ์ธํธ๋ก ๋ชจ๋ธ์ ๋ค์ ํ๋ จํด์ผ ํ๋ฏ๋ก ๋น์ฉ์ด ๋ง์ด ๋ญ๋๋ค. ์ด์ ๋ณธ ๋
ผ๋ฌธ์์๋ ํ
์คํธ ์์ ์ ํ
์คํธ๋ ์ด๋ฏธ์ง๋ก ๊ตฌ์ฑ๋ ์์์ ํ๋กฌํํธ๋ง์ผ๋ก ์ด๋ฏธ์ง ๋ถํ ์ ์ํํ ์ ์๋ ์์คํ
์ ์ ์ํฉ๋๋ค. ์ด ์ ๊ทผ ๋ฐฉ์์ ํตํด ์๋ก ๋ค๋ฅธ ๊ณผ์ ๋ฅผ ๊ฐ๋ ์ธ ๊ฐ์ง ์ฃผ์ ์ด๋ฏธ์ง ๋ถํ ํ์คํฌโ์ง์ ํํ ๋ถํ (referring expression segmentation), ์ ๋ก์ท ๋ถํ (zero-shot segmentation), ์์ท ๋ถํ (one-shot segmentation)โ์ ๋จ์ผ ํตํฉ ๋ชจ๋ธ๋ก ์ฒ๋ฆฌํ ์ ์์ต๋๋ค. ์ด๋ฅผ ์ํด ์ฐ๋ฆฌ๋ CLIP ๋ชจ๋ธ์ ๋ฐฑ๋ณธ์ผ๋ก ์ผ๊ณ , ๊ณ ํด์๋ ์์ธก์ ๊ฐ๋ฅํ๊ฒ ํ๋ ํธ๋์คํฌ๋จธ ๊ธฐ๋ฐ ๋์ฝ๋๋ฅผ ์ถ๊ฐํด ์ด๋ฅผ ํ์ฅํ์ต๋๋ค. ํ์ฅ๋ PhraseCut ๋ฐ์ดํฐ ์ธํธ๋ฅผ ํ์ฉํด ํ๋ จํ ๋ณธ ์์คํ
์ ์์ ํ์์ ํ
์คํธ ํ๋กฌํํธ๋ ํน์ ๋ชฉ์ ์ ํํํ๋ ์ด๋ฏธ์ง๋ฅผ ์
๋ ฅ์ผ๋ก ๋ฐ์, ์
๋ ฅ ์ด๋ฏธ์ง์ ๋ํ ์ด์ง ๋ถํ ๋งต์ ์์ฑํฉ๋๋ค. ํนํ ์ด๋ฏธ์ง ๊ธฐ๋ฐ ํ๋กฌํํธ์ ๋ค์ํ ๊ตฌ์ฑ ๋ฐฉ์๊ณผ ๊ทธ ํจ๊ณผ๋ฅผ ์์ธํ ๋ถ์ํ์์ต๋๋ค. ์ด ์๋ก์ด ํ์ด๋ธ๋ฆฌ๋ ์
๋ ฅ ๋ฐฉ์์ ์์ ์ธ๊ธํ ์ธ ๊ฐ์ง ํ์คํฌ๋ฟ๋ง ์๋๋ผ, ํ
์คํธ ๋๋ ์ด๋ฏธ์ง๋ก ์ง์ํ ์ ์๋ ๋ชจ๋ ์ด์ง ๋ถํ ๋ฌธ์ ์ ์ ์ฐํ๊ฒ ๋์ํ ์ ์์ต๋๋ค. ๋ง์ง๋ง์ผ๋ก, ๋ณธ ์์คํ
์ด ์ดํฌ๋์ค(affordance)๋ ๊ฐ์ฒด ์์ฑ๊ณผ ๊ฐ์ ์ผ๋ฐํ๋ ์ง์์๋ ๋์ ์ ์๋ ฅ์ ๋ณด์์ ํ์ธํ์์ต๋๋ค.*
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/clipseg_architecture.png"
alt="drawing" width="600"/>
<small> CLIPSeg ๊ฐ์. <a href="https://huggingface.co/papers/2112.10003">์๋ณธ ๋
ผ๋ฌธ</a>์์ ๋ฐ์ท. </small>
์ด ๋ชจ๋ธ์ [nielsr](https://huggingface.co/nielsr)๋์ด ๊ธฐ์ฌํ์ต๋๋ค.
์๋ณธ ์ฝ๋๋ [์ฌ๊ธฐ](https://github.com/timojl/clipseg)์์ ์ฐพ์ ์ ์์ต๋๋ค.
## ์ฌ์ฉ ํ[[usage-tips]]
- [`CLIPSegForImageSegmentation`]์ [`CLIPSegModel`]๊ณผ ๋์ผํ, [`CLIPSegModel`] ์์ ๋์ฝ๋๋ฅผ ์ถ๊ฐํ ๋ชจ๋ธ์
๋๋ค.
- [`CLIPSegForImageSegmentation`]์ ํ
์คํธ ์์ ์ ์์์ ํ๋กฌํํธ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ด๋ฏธ์ง ๋ถํ ์ ์์ฑํฉ๋๋ค. ์ด๋ ํ๋กฌํํธ๋ ํ
์คํธ(`input_ids`), ์ด๋ฏธ์ง(`conditional_pixel_values`), ์ฌ์ฉ์ ์ ์ ์กฐ๊ฑด๋ถ ์๋ฒ ๋ฉ(`conditional_embeddings`)์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
## ๋ฆฌ์์ค[[resources]]
CLIPSeg๋ฅผ ์์ํ๋ ๋ฐ ๋์์ด ๋ Hugging Face ๊ณต์ ์๋ฃ์ ์ปค๋ฎค๋ํฐ(๐ ์์ด์ฝ์ผ๋ก ํ์)์ ์ ์ฉํ ๋ฆฌ์์ค ๋ชฉ๋ก์ ์๋์ ์ ๋ฆฌํ์ต๋๋ค. ํน์ ๋ชฉ๋ก์ ์๋ ์๋ก์ด ์๋ฃ๋ ํํ ๋ฆฌ์ผ์ ๊ณต์ ํ๊ณ ์ถ์ผ์๋ค๋ฉด, ์ธ์ ๋ ์ง Pull Request๋ฅผ ํตํด ์ ์ํด ์ฃผ์ธ์. ์ ํฌ๊ฐ ๊ฒํ ํ ์์คํ ๋ฐ์ํ๊ฒ ์ต๋๋ค! ๊ธฐ์กด ์๋ฃ์ ์ค๋ณต๋์ง ์๋ ์๋ก์ด ๋ด์ฉ์ด๋ผ๋ฉด ๋์ฑ ์ข์ต๋๋ค.
<PipelineTag pipeline="image-segmentation"/>
- [zero-shot image segmentation with CLIPSeg](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/CLIPSeg/Zero_shot_image_segmentation_with_CLIPSeg.ipynb)์ ์์ฐํ๋ ๋
ธํธ๋ถ.
## CLIPSegConfig[[transformers.CLIPSegConfig]]
[[autodoc]] CLIPSegConfig
## CLIPSegTextConfig[[transformers.CLIPSegTextConfig]]
[[autodoc]] CLIPSegTextConfig
## CLIPSegVisionConfig[[transformers.CLIPSegVisionConfig]]
[[autodoc]] CLIPSegVisionConfig
## CLIPSegProcessor[[transformers.CLIPSegProcessor]]
[[autodoc]] CLIPSegProcessor
## CLIPSegModel[[transformers.CLIPSegModel]]
[[autodoc]] CLIPSegModel
- forward
- get_text_features
- get_image_features
## CLIPSegTextModel[[transformers.CLIPSegTextModel]]
[[autodoc]] CLIPSegTextModel
- forward
## CLIPSegVisionModel[[transformers.CLIPSegVisionModel]]
[[autodoc]] CLIPSegVisionModel
- forward
## CLIPSegForImageSegmentation[[transformers.CLIPSegForImageSegmentation]]
[[autodoc]] CLIPSegForImageSegmentation
- forward |