Skip to main content

alternat: Automate your image alt-text generation workflow.

Resources

Description

alternat automates the image alt-text generation workflow by offering ready to use methods for downloading (Collection in alternat lingo) images and then generating alt-text.

alternat features are grouped into tasks - Collection and Generation

Collection

Collection offers convenience methods to download images. It uses puppeteer (headless chrome) to automate the website crawling and image download process

Generation

Generation offers convenience methods to generate alt-texts. It offers drivers to generate the alt-texts.

  1. Azure API - Uses Azure API for image captioning and OCR. Note Azure is a paid service.
  2. Google API - Uses google API for image captioning and OCR. Note google is a paid service.
  3. Open Source - Uses free open source alternative for OCR and image captioning.

Supported Video and image file formats jpeg, jpg and png are supported.

Installation

Installation using Docker

  1. Download and Install Docker Desktop for Mac using this link docker-desktop

  2. Clone this repo https://github.com/keplerlab/alternat.git

  3. Change your directory to your cloned repo.

  4. Open terminal and run following commands

cd <path-to-repo> //you need to be in your repo folder
docker-compose build
  1. Start docker container using this command
docker-compose up
  1. In a new terminal window open terminal inside docker container for running alternat using command line type following command:
docker-compose exec alternat bash
  1. You can use this command line to execute collect or generate command line application like this .

Installation from pypi, source and Anaconda Python

Please refer to os specific respective installation guides for macOS, ubuntu and Windows respectively.

Running generate task using command line:

If you want to generate alternate text for any image or folder containing multiple images, you can use Command line option which we call generation stage.

To run generation stage alone you can use following command:

# To run a single file, results will be collected under "results/generate"
# The image extensions supported are: .jpg, .jpeg, .png.

python app.py generate --output-dir-path="./results" --input-image-file-path="./sample/images_with_text/sample1.png"  

or

# To run for entire directory, results will be collected under "results/generate"
# The image extensions supported are: .jpg, .jpeg, .png.

python app.py generate --input-dir-path="./sample/images_with_text" --output-dir-path="./results"

or 

# To generate alt-text using specific driver (like azure, google or open source)
# Do not forget to add the credentials to their respective config files when using azure and google
# azure needs SUBSCRIPTION_KEY and ENDPOINT URL
# google needs ABSOLUTE_PATH_TO_CREDENTIALS_FILE (a credential json file)

python app.py generate --output-dir-path="./results" --input-image-file-path="./sample/images_with_text/sample1.png" --driver-config-file-path="./sample/generator_driver_conf/azure.json"

Sample images are located at sample/images and sample/images_with_text

Running collect task using command line:

First stage is called collection stage, it can be used to crawl and download images from any website or website url, to run the collection stage use following commands:

Use case: Download image from single page

    # To run the collection 
     python app.py collect  --url=<WEBSITE_URL> --output-dir-path=./DATADUMP

Use case: Download images recursively for a given site

    # To run the collection 
    python app.py collect --download-recursive --url=<WEBSITE_URL> --output-dir-path=./DATADUMP

Knows Issue / Troubleshooting

Please refer to FAQ\Troubleshooting section inside alternat documenation, or raise an Github issue.

Attributions

  1. For open source ocr we are using EasyOCR project https://github.com/JaidedAI/EasyOCR by Rakpong Kittinaradorn.
  2. For opensource caption generation we are using model training and inference scripts using method at https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Image-Captioning by Sagar Vinodababu.
  3. For web crawling we are using apify wrapper over puppeteer library https://apify.com/.

Metadata

Release files for alternat 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alternat 0.1.5
File Size Uploaded
alternat-0.1.5.tar.gz 29.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alternat 0.1.5
File Interpreter ABI Platform
alternat-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 72.4 kB

Release files / alternat-0.1.5.tar.gz

Download URL alternat-0.1.5.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5e74b5ad1bacc066b78cee0139cc302daf84745ea9a3195a8b985e88c274b24c
BLAKE2b-256 checksum
How to use checksums
a65b46387f7fd66450a3e674cd7abac646d113db1718b4b65da120f3af32b1f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

Release files / alternat-0.1.5-py3-none-any.whl

Download URL alternat-0.1.5-py3-none-any.whl
Size 42.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f61a6bb2cbaaee1824104302f4a71435783283710e92ce39669ea96c70e08c2
BLAKE2b-256 checksum
How to use checksums
df46d658eeeb7b48f2d476cb914f206cdb11df21db44e7746aea2b3c4e323aaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

1 release file

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page