rom1504 / clip-retrieval

Easily compute clip embeddings and build a clip retrieval system with them
https://rom1504.github.io/clip-retrieval/
MIT License
2.42k stars 213 forks source link

Automatically detect whether images/text are missing, and use enable image/text False #200

Closed nielsrolf closed 2 years ago

nielsrolf commented 2 years ago

Hi, first of all thanks for this amazing repo.

I ran the following two commands:

img2dataset --url_list=img_paths.txt --output_folder=image_folder --thread_count=1 --image_size=512
clip-retrieval inference --input_dataset image_folder --output_folder embeddings_folder --batch_size 4 --num_prepro_workers 1

and end up with an embeddings_folder that contains no files except the empty folders.

The first command worked fine and created the following dir:

image_folder/
|-- 00000
|   |-- 000000000.jpg
|   |-- 000000000.json
|   |-- 000000001.jpg
|   |-- 000000001.json
|   |-- 000000002.jpg
...
|   `-- 000000069.json
|-- 00000.parquet
`-- 00000_stats.json

For the second command, I first had to modify logger.py: line 137 to be start_time_no_initial_load = min(start_time_no_initial_load, v.get("start_time", start_time_no_initial_load)) I did this modification just to avoid the error you describe in issue #199 but don't know if this breaks anything else.

The contents of embeddings_folder looks like this:

embeddings_folder/
|-- img_emb
|-- metadata
|-- stats
|   `-- 0.json
`-- text_emb

>> cat embeddings_folder/stats/0.json 
{}

Version of the repo is:

git log
commit 114a3d7dae974b1c4b854c8b424cfe46b56e9d0a (HEAD -> main, tag: 2.35.0, or
igin/main, origin/HEAD)
Author: Romain Beaumont <romain.rom1@gmail.com>
Date:   Tue Oct 25 20:10:15 2022 +0200

    Release 2.35.0
nielsrolf commented 2 years ago

I was missing --enable_text False, now it works! Maybe one could automatically disable it if no text files are present, but I'm closing the issue

rom1504 commented 2 years ago

Detecting text missing is supposed to be supported

Let's reopen to track this

r-tinn commented 2 years ago

Agreed amazing repo, I had the same issue as this now resolved.

nousr commented 2 years ago

Detecting text missing is supposed to be supported

Let's reopen to track this

seems like this got silently dropped when shuffling around the responsibilities in the slurm update. clip_retrieval.clip_inference.main now updates the toggles accordingly.

rom1504 commented 2 years ago

Fix released as 2.35.1