portu-sim / comfyui_bmab

BMAB for ComfyUI
GNU Affero General Public License v3.0
76 stars 5 forks source link

transformers의 groundingdino 구현 이용 #19

Closed Bing-su closed 3 months ago

Bing-su commented 3 months ago

transformers 4.40버전부터 transformers 라이브러리에 groundingdino가 추가되었습니다.

https://github.com/huggingface/transformers/releases/tag/v4.40.0

transformers 요구사항을 4.40이상으로 올리고, groundingdino 를 transformers 라이브러리를 사용하면 설치문제에서 자유로워질 수 있지 않으실까 제안드립니다.

https://huggingface.co/docs/transformers/model_doc/grounding-dino

groundingdino의 소스코드를 보면 여기에는 torch, pillow, scipy, pycocotools만 의존성을 가지는 것으로 보입니다.

https://github.com/NielsRogge/Transformers-Tutorials/blob/master/Grounding%20DINO/GroundingDINO_with_Segment_Anything.ipynb

또, 이 튜토리얼에서는 groundingdino 사용법과 groundingdino + sam의 예시를 보여주고 있습니다.

portu-sim commented 3 months ago

레전드께서 방문해 주셨네요 ^^, 바로 확인해보겠습니다. 좋은 의견 감사합니다.

portu-sim commented 3 months ago

지금 확인해보니 4.40.2가 설치되어 있어서 바로 적용해봤습니다. 잘 동작하는 것을 확인했습니다. 이제 설치 염려를 덜었네요. 정말 좋은 의견 감사합니다.

image
Bing-su commented 3 months ago

칸페키

Bing-su commented 3 months ago

제가 조사가 부족했습니다.

최소 버전은 4.41.0일 수도 있고, https://github.com/huggingface/transformers/pull/30768

cuda 설치가 필요할지도 모르겠습니다. ㅠㅠ

+++

cuda 설치 유무에 따라 구현을 변경하는 기능이 있네요 없어도 됩니다. https://github.com/huggingface/transformers/blob/573565e35a5cc68f6cfb6337f5a93753ab16c65b/src/transformers/models/grounding_dino/modeling_grounding_dino.py#L739-L755

portu-sim commented 3 months ago

우선 제 맥에서 4.40.2로 잘 돌아갑니다. device를 CPU로 지정해도 잘 돌아갔습니다. device에 cuda가 없는 경우 cpu를 지정해서 동작하게 했고, MAC의 경우 msp로 하면 결과가 cpu와 다르고 더 느려져서 그냥 cpu로 동작하게 했습니다.