Skip to main content

AI-Powered Command-Line Photo Search Tool

Project description

rclip - AI-Powered Command-Line Photo Search Tool

All Contributors

[Blog] [Demo on YouTube] [Paper]

rclip logo

rclip is a command-line photo search tool powered by the awesome OpenAI's CLIP neural network.

Installation

Linux

sudo snap install rclip
Alternative options (AppImage and pip)

If your Linux distribution doesn't support snap, you can use one of the alternative installation options:

AppImage (self-contained x86_64 executable)

On Linux x86_64, you can install rclip as a self-contained executable.

  1. Download the AppImage from the latest release.

  2. Execute the following commands:

chmod +x <downloaded AppImage filename>
sudo mv <downloaded AppImage filename> /usr/local/bin/rclip

Using pip

pip install --extra-index-url https://download.pytorch.org/whl/cpu rclip

macOS

brew install yurijmikhalevich/tap/rclip

Note: We only support Apple Silicon (arm64) on macOS.

Alternative option (pip)
pip install rclip

Windows

  1. Download the "*.msi" from the latest release.
  2. Install rclip by running the installer.
Alternative option (pip)
pip install rclip

Usage

cd photos && rclip "search query"
rclip usage demo

When you run rclip for the first time in a particular directory, it will extract features from the photos, which takes time. How long it will take depends on your CPU and the number of pictures you will search through. It took about a day to process 73 thousand photos on my NAS, which runs an old-ish Intel Celeron J3455, 7 minutes to index 50 thousand images on my MacBook with an M1 Max CPU, and three hours to process 1.28 million images on the same MacBook.

For a detailed demonstration, watch the video: https://www.youtube.com/watch?v=tAJHXOkHidw.

Similar image search

You can use another image as a query by passing a file path or even an URL to the image file, and rclip will find the images most similar to the one you used as a query. If you are referencing a local image via a relative path, you must prefix it with ./. For example:

cd photos && rclip ./cat.jpg

# or use URL
cd photos && rclip https://raw.githubusercontent.com/yurijmikhalevich/rclip/main/tests/e2e/images/cat.jpg

Check this video out for the image-to-image search demo: https://www.youtube.com/watch?v=1YQZKeCBxWM.

Combining multiple queries

You can add and subtract image and text queries from each other; here are a few usage examples:

cd photos && rclip horse + stripes
cd photos && rclip apple - fruit
cd photos && rclip "./new york city.jpg" + night
cd photos && rclip "2:golden retriever" + "./swimming pool.jpg"
cd photos && rclip "./racing car.jpg" - "2:sports car" + "2:snow"

If you want to see how these queries perform when executed on the 1.28 million images ImageNet-1k dataset, check out the demo on YouTube: https://www.youtube.com/watch?v=MsTgYdOpgcQ.

How do I preview the results?

If you are using either one of iTerm2, Konsole (version 22.04 and higher), wezterm, Mintty, or mlterm all you need to do is pass --preview (or -p) argument to rclip:

rclip -p kitty
Using a different terminal or viewer

If you are using any other terminal or want to view the results in your viewer of choice, you can pass the output of rclip to it. For example, on Linux, the command from below will open top-5 results for "kitty" in your default image viewer:

rclip -f -t 5 kitty | xargs -d '\n' -n 1 xdg-open

The -f param or --filepath-only makes rclip print the file paths only, without scores or the header, which makes it ideal to use together with a custom viewer as in the example.

I prefer to use feh's thumbnail mode to preview multiple results:

rclip -f -t 5 kitty | feh -f - -t

Can I use rclip to copy images matching a certain query?

Yes, you can pipe rclip's output to another tool to copy the images. For example, to copy top 3 images matching the "search query" to /path/to/destination on macOS, Linux, or WSL you can do:

rclip -f -t 3 "search query" | xargs -I {} cp {} /path/to/destination

How does rclip update the index?

When you run rclip in a directory that has already been processed, it will only index the new images added since the last run and remove the deleted images from its index. This makes consecutive runs much faster.

If you know that no new images were added or deleted since the last run, you can use the --no-indexing (or -n) argument to skip the indexing step altogether and speed up the search even more.

rclip -n cat

Get help

https://github.com/yurijmikhalevich/rclip/discussions/new/choose

Contributing

This repository follows the Conventional Commits standard.

Running locally from the source code

To run rclip locally from the source code, you must have Python and Poetry installed.

Then do:

# clone the source code repository
git clone git@github.com:yurijmikhalevich/rclip.git

# install dependencies and rclip
cd rclip
poetry install

# activate the new poetry environment
poetry shell

If the poetry environment is active, you can use rclip locally, as described in the Usage section above.

Contributors ✨

Thanks go to these wonderful people and organizations (emoji key):

ramayer
ramayer

💻
Caphyon
Caphyon

🚇
AbId KhAn
AbId KhAn

💻
Ben
Ben

💻
Tanmay Chaudhari
Tanmay Chaudhari

💻
Leo Auri
Leo Auri

💻

Thanks to Caphyon and Advanced Installer team for generously supplying rclip project with the Professional Advanced Installer license for creating the Windows installer.

This project follows the all-contributors specification. Contributions of any kind are welcome!

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rclip-2.1.7a3.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rclip-2.1.7a3-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file rclip-2.1.7a3.tar.gz.

File metadata

  • Download URL: rclip-2.1.7a3.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rclip-2.1.7a3.tar.gz
Algorithm Hash digest
SHA256 cbe840e2b4bb84bd73cafbac5bc5b03deb64513a12c0658eec403524e6b7f41a
MD5 6585666ab87833069ed49631a07f3e20
BLAKE2b-256 0164704bcc3366d1db8f5344117c467626876e05595e2677f7921669a958d578

See more details on using hashes here.

Provenance

The following attestation bundles were made for rclip-2.1.7a3.tar.gz:

Publisher: release.yaml on yurijmikhalevich/rclip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rclip-2.1.7a3-py3-none-any.whl.

File metadata

  • Download URL: rclip-2.1.7a3-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rclip-2.1.7a3-py3-none-any.whl
Algorithm Hash digest
SHA256 b9c34384adfae17207c712021e76789a00f86bb6a9de671a80a24f8155298e8b
MD5 f151d7a5ef566fa904dd27891737f00f
BLAKE2b-256 7415743fe6dc85b6891a2d3d6233248d5b4b88aa77f5d3457272528b7b151239

See more details on using hashes here.

Provenance

The following attestation bundles were made for rclip-2.1.7a3-py3-none-any.whl:

Publisher: release.yaml on yurijmikhalevich/rclip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page