plip
1.0.0
PLIP(Pathology Language and Image Pre-Training)는 Pathology AI를 위한 최초의 비전 및 언어 기반 모델입니다. PLIP는 병리학 이미지 및 텍스트 설명에서 시각적 및 언어 특징을 추출하는 데 사용할 수 있는 대규모 사전 학습 모델입니다. 이 모델은 원래 CLIP 모델을 미세 조정한 버전입니다.
from plip . plip import PLIP
import numpy as np
plip = PLIP ( 'vinid/plip' )
# we create image embeddings and text embeddings
image_embeddings = plip . encode_images ( images , batch_size = 32 )
text_embeddings = plip . encode_text ( texts , batch_size = 32 )
# we normalize the embeddings to unit norm (so that we can use dot product instead of cosine similarity to do comparisons)
image_embeddings = image_embeddings / np . linalg . norm ( image_embeddings , ord = 2 , axis = - 1 , keepdims = True )
text_embeddings = text_embeddings / np . linalg . norm ( text_embeddings , ord = 2 , axis = - 1 , keepdims = True )
from PIL import Image
from transformers import CLIPProcessor , CLIPModel
model = CLIPModel . from_pretrained ( "vinid/plip" )
processor = CLIPProcessor . from_pretrained ( "vinid/plip" )
image = Image . open ( "images/image1.jpg" )
inputs = processor ( text = [ "a photo of label 1" , "a photo of label 2" ],
images = image , return_tensors = "pt" , padding = True )
outputs = model ( ** inputs )
logits_per_image = outputs . logits_per_image # this is the image-text similarity score
probs = logits_per_image . softmax ( dim = 1 )
print ( probs )
image . resize (( 224 , 224 ))
연구에 PLIP를 사용하는 경우 다음 논문을 인용하십시오.
@article { huang2023visual ,
title = { A visual--language foundation model for pathology image analysis using medical Twitter } ,
author = { Huang, Zhi and Bianchi, Federico and Yuksekgonul, Mert and Montine, Thomas J and Zou, James } ,
journal = { Nature Medicine } ,
pages = { 1--10 } ,
year = { 2023 } ,
publisher = { Nature Publishing Group US New York }
}
내부 API는 FashionCLIP에서 복사 되었습니다.