/ai-image-renamer

Python script that uses AI to rename images based on their content. Leverages Microsoft Cognitive Services API. Can run recursively on subfolders. Supports jpeg, jpg, png image formats. Great tool for organizing large image collections.

Primary LanguagePythonMIT LicenseMIT

Remarks:

AI-Image-Renamer

This repository contains a Python script that utilizes AI to automatically rename images based on their content. The script leverages the Microsoft Cognitive Services Computer Vision API to extract image descriptions and uses them to create new, more meaningful file names.

Getting Started

Prerequisites

  • Python 3.x
  • A Microsoft Cognitive Services subscription key
  • PIL library

Installation

  • Clone or download the repository
  • Install PIL by running pip install pillow
  • Replace YOUR_SUBSCRIPTION_KEY in the script with your actual subscription key
  • Replace endpoint_url in the script with the desired endpoint URL.

Usage

  • Run the script with the command python script.py image_folder [recursive]

  • image_folder is the path to the folder containing your images

  • recursive is an optional argument that, if provided, will make the script search for images in all subfolders.

GIF Recording 2023-01-20 at 12 09 14 PM

Examples

Default: python3 ai-image-renamer.py "/Users/martinaltmann/Downloads/Website images cleaned/test" will rename all images in that folder

Recursive: python3 ai-image-renamer.py "/Users/martinaltmann/Downloads/Website images cleaned/test" recursive will rename all images in that folder + subfolders

Note

If the image already exists it will add a running number to it. Eg. You have three images with with a table and glass on it. The AI will create "table_with_glas_on_it" for the first and "table_with_glas_on_it_1" for the second. By this its not overwriting the images.

Built With