-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A possible solution to solve KeyError: 'xxx.txt' when using “clip-retrieval inference” command #352
Comments
Can you read #329 and propose a fix that make things work without breaking what this PR had fixed ? |
Sure~ This is reasonable because the code uses proxy paths relative to the root directory, resulting in all dictionary keys containing subdirectories of different levels.
|
should I make a PR again? |
I met the same problem as you. I modified my code, but it still cannot work. |
Hi @ShuxunoO I have modified folder_to_keys as per your response but i am getting following error: clip-retrieval inference \Local\Programs\Python\Python312\Lib\multiprocessing\reduction.py", line 60, in dump can you please help |
I met the same error as #345 when I used
clip-retrieval inference
command to extract images and corresponding texts features, my command is like following:My local directory structure is as follows:
and the output traceback is:
——————————————————————————————————————————————————————————
After my analysis, I think the problem is that the file suffix ".txt" in "key" at this location in the code causes an issue in finding the corresponding file in the image dictionary. This is because in the source code, the possible image file extensions are: ".png", ".jpg", ".jpeg", ".bmp", ".webp", ".PNG", ".JPG", ".JPEG", ".BMP", ".WEBP".
To elaborate further, the function
folder_to_keys(folder, enable_text=True, enable_image=True, enable_metadata=False)
at this location in the code incorrectly uses filenames with suffixes as keys while constructing the dictionaries "text_files", "image_files", and "metadata_files". In fact, it should only retain the filename (removing the suffix). Here is my modified version of the code:After modifying the code, the inference process went smoothly and I successfully obtained the corresponding feature vectors for both images and texts.
I hope this can help the users with the same errors!
The text was updated successfully, but these errors were encountered: