towhee-io / examples

Analyze the unstructured data with Towhee, such as reverse image search, reverse video search, audio classification, question and answer systems, molecular search, etc.
Apache License 2.0
445 stars 111 forks source link

We couldn't connect to 'https://huggingface.co' to load this file #266

Open AriesJin opened 4 hours ago

AriesJin commented 4 hours ago

from towhee import ops, pipe, DataCollection

create image embeddings and build index

p = ( pipe.input('file_name') .map('file_name', 'img', ops.image_decode.cv2()) .map('img', 'vec', ops.image_text_embedding.clip(model_name='clip_vit_base_patch32', modality='image')) .map('vec', 'vec', ops.towhee.np_normalize()) .map(('vec', 'file_name'), (), ops.ann_insert.faiss_index('./faiss', 512)) .output() )

for f_name in ['https://raw.githubusercontent.com/towhee-io/towhee/main/assets/dog1.png', 'https://raw.githubusercontent.com/towhee-io/towhee/main/assets/dog2.png', 'https://raw.githubusercontent.com/towhee-io/towhee/main/assets/dog3.png']: p(f_name)

Flush faiss data into disk.

p.flush()

search image by text

decode = ops.image_decode.cv2('rgb') p = ( pipe.input('text') .map('text', 'vec', ops.image_text_embedding.clip(model_name='clip_vit_base_patch32', modality='text')) .map('vec', 'vec', ops.towhee.np_normalize())

faiss op result format: [[id, score, [file_name], ...]

.map('vec', 'row', ops.ann_search.faiss_index('./faiss', 3))
.map('row', 'images', lambda x: [decode(item[2][0]) for item in x])
.output('text', 'images')

)

DataCollection(p('puppy Corgi')).show()

OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like openai/clip-vit-base-patch32 is not the path to a directory containing a file named config.json. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

but I had set os.environ["HUGGINGFACE_HUB_ENDPOINT"] = "https://hf-mirror.com/"

can you help me?

junjiejiangjjj commented 2 hours ago

hi @AriesJin , try this export HF_ENDPOINT=https://hf-mirror.com