vigrep is like grep but for images, filtering images using a query and GPT-4o Vision.
Status: Alpha ⚡
- Visually scan for images using a natural language query.
- Simple grep-compatible interface. If you've ever used
grep -l, you already know how to usevigrep. - Low-ish cost. Uses about 180 tokens per image depending on the length of your query, costing about a dollar per 1100 images processed at the time of this writing.
- Run
npm install -g vigrep@latestto install. - Make sure you have an
$OPENAI_API_KEYenvironment variable which you can generate here.
In this example we have a directory full of photos and we want to print the files containing cats to stdout:
vigrep 'has a cat' *.jpgSimilar to grep, we can use -L to print only the files that do NOT match the
query. You can also do the usual piping tricks in combination with other
commands like xargs. For example, to delete all the files that don't contain
cats:
vigrep -L 'has a cat' *.jpg | xargs rm...or more technically correct, handling any weird file names:
vigrep -L --null 'has a cat' -- *.jpg | xargs -0 rmTo see all options, run vigrep --help.
Vigrep sends all the files you pass it to OpenAI! Don't use it on sensitive images.
See OpenAI's documentation about Vision limitations.