jina-ai / clip-as-service

🏄 Scalable embedding, reasoning, ranking for images and sentences with CLIP
https://clip-as-service.jina.ai
Other
12.48k stars 2.07k forks source link

rank function, sorting images according to text returns empty results, only scores #922

Open kkiskkk opened 1 year ago

kkiskkk commented 1 year ago

image no image name displayed

ZiniuYu commented 1 year ago

Hi, could you please provide a minimum code snippet and a data sample that demonstrate how you obtained the result shown in your screenshot?

kindziora commented 1 year ago

Hi,

i have the same issue using the sample from the docs: "Given sentence, rank images" https://clip-as-service.jina.ai/user-guides/client/#rank-api

code:

from docarray import Document
from client.clip_client import Client

c = Client('grpc://172.17.0.2:51000')
# c.profile()

d = Document(
    text='a photo of a table',
    matches=[
        Document(uri='imagexyzsdfdsf'),
        Document(uri='imagexyz45435'),
        Document(uri='imagexyz68768'),
        Document(uri='imagexyz7865756'),
    ],
)
r = c.rank([d])

**replace image urls

result:

[['', '', '', ''], [0.9542718529701233, 0.0419040322303772, 0.002422966528683901, 0.0014011985622346401]]

kindziora commented 1 year ago

found the problem, the docs are using the wrong label in the sample:

print(c.rank(da)['@m', ['text', 'scoresclip_scorevalue']]) print(c.rank(da)['@m', ['uri', 'scoresclip_scorevalue']])

text --> uri