Skip to main content

A utility leveraging GPT-4o for image file renaming based on content.

Project description

VisioNomicon

VisioNomicon is a powerful Python-based command-line utility tool designed to rename image files using the capabilities of GPT-4o. Descriptive filenames are generated based on a user given template and the content of the image.

demo

Features

  • Rename image files based on generated filenames from GPT-4V
  • Flexible name generation based on user given structure
  • Ability to create a mapping file for renamed images
  • Execute renaming based on a generated mapping file
  • Undo renaming to revert to original filenames
  • Verification step for generated names using GPT-4o
  • Support for multiple retry attempts in case of validation or errors
  • Supported file types: .png, .jpeg, .jpg, .webp, .gif (non-animated)

Prerequisites

  • Python 3.6+
  • Access to OpenAI API with GPT-4o capabilities (API key required)

Installation

You can install the package using pip via the following command:

pip install VisioNomicon

Alternatively, you can manually install the package by downloading the source distribution and running the following commands:

  1. Download the latest source distribution from the Releases page.
  2. Extract the file and navigate to the extracted directory.
  3. Run the following command to install:
pip install .

Usage

To use VisioNomicon, you need to set the OPENAI_API_KEY environment variable to your OpenAI API key. This can generally be done with a command like the following:

export OPENAI_API_KEY='your_api_key_here'

Run the script with the desired flags and arguments:

VisioNomicon [OPTIONS]

Or in one single command:

OPENAI_API_KEY='your_api_key_here' VisioNomicon [OPTIONS] 

Options

  • -f, --files: Specify file paths of the images to create mapping for
  • -o, --output: Specify a JSON mapping file to be created with original and new file paths. Defaults to $XDG_DATA_HOME/visionomicon/mapping-%Y-%m-%d-%H-%M-%S.json
  • -x, --execute: Execute renaming based on existing mapping file. Calling this without a value uses the most recently created mapping in $XDG_DATA_HOME/visionomicon
  • -ox, --mapex: Map and execute renaming in one step
  • -u, --undo: Revert renaming to original filenames using a mapping file. Calling this without a value uses the most recently created mapping in $XDG_DATA_HOME/visionomicon
    • It is important to note, if the file names or locations change after executing a mapping, you will not be able to undo
  • -t, --template: Define the template for renaming image files, without file extension. It is recommended to use square brackets to define elements of the filename. Defaults to [SubjectDescription]\_[MainColor/ColorScheme]\_[StyleOrFeel]\_[CompositionElement]
  • -e, --validation-retries: Specify the number of retries for name validation (defaults to 3)
  • -v, --error-retries: Specify the number of retries in case of OpenAI errors (defaults to 3)
  • -E, --ignore-validation-fail: If validation retries limit is reached, map file to original name instead of returning an error
  • -V, --ignore-error-fail: If error retries limit is reached, map file to original name instead of returning an error
  • -b, --create-batch: Create batch job through OpenAI API.
  • -B, --retrieve-batch: Retrieve batch job output through OpenAI API. Run this 24 hours after creating the batch job.

Example Commands

VisioNomicon -f image1.jpg image2.png -ox

This is the most straightforward usage. A mapping file is created for the images, placed at the default location ($XDG_DATA_HOME/visionomicon/mapping-%Y-%m-%d-%H-%M-%S.json). Immediately afterwards, this file is executed, renaming the files.

VisioNomicon -f image1.jpg image2.png -o mapping.json -t "[Object]_[Color]_[Style]"

This command will create a rename mapping file for image1.jpg and image2.png based on the provided template and output the mapping to mapping.json.

Subsequently, you can execute the mapping, renaming the files.

VisioNomicon -x mapping.json

This can also be done in one single command if you'd like, using -ox:

VisioNomicon -f image1.jpg image2.png -ox mapping.json -t "[Object]_[Color]_[Style]"

Limitations

  • GPT-4o is limited in the file types it can handle(.png, .jpeg, .jpg, .webp, non-animated .gif), and the size (up to 20MB)
  • With some templates it can be quite finicky, not really generating the filenames you might expect

Contributing

Contributions are welcome. Please open an issue first to discuss what you would like to change or add.

License

This project is open-sourced under the GLP-3.0 License.

Disclaimer

This tool is not affiliated with OpenAI. The functionality is subject to change based on updates to the API or the terms of service provided by OpenAI.

Project details


Download files

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

Source Distribution

visionomicon-0.1.5.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

VisioNomicon-0.1.5-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file visionomicon-0.1.5.tar.gz.

File metadata

  • Download URL: visionomicon-0.1.5.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for visionomicon-0.1.5.tar.gz
Algorithm Hash digest
SHA256 710349f12a163fbd49be95cd15a53bd814f94159a09c8cae906a57b98ea741d2
MD5 6a5f231a0419a38ac6d781bda57a3b0f
BLAKE2b-256 70775aa9109f359a155d9b656b3a556c5c72480c13e909592b38caced2f03441

See more details on using hashes here.

File details

Details for the file VisioNomicon-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: VisioNomicon-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for VisioNomicon-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4ce76b3ed0c6bd1406f81de4a41bf0946833e66db7481a271589a1090f3c732c
MD5 1aa3c44d82606ab4b43fe38c27025cf1
BLAKE2b-256 65bfd4dcf9bba0e4f39e65331c69ff0fad781ab004adc246570c633610403bac

See more details on using hashes here.

Supported by

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