Skip to main content

Alternat is a tool that automates alt text generation.

Project description

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.

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

Installation

Using pypi

  1. Install node (>=v.12)
  2. Install Python >= 3.8
  3. pip install alternat
  4. Install apify at alternat designated folder
# For ubuntu / linux run this command before installing apify
sudo apt-get install -y procps  libxss1 fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf ffmpeg libsm6 libxext6

mkdir -p ~/.alternat && cd ~/.alternat && npm install apify && cd -

Install from source

  1. Install git
  2. Install node (>=v.12)
  3. Install python >= 3.8
  4. Open terminal or command prompt
  5. Clone repo from here https://github.com/keplerlab/alternat.git
  6. Change the directory to the directory where you have cloned your repo
    $cd path_to_the_folder_repo_cloned
    
Mac and Linux
  1. Run the setup if alternat to be used as standalone application:

    sh install_application_mode.sh 
    

    Run the setup if alternat to be used as service:

    sh install_api_mode.sh 
    

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

Installation using Anaconda python

  1. Install node (>=v.12)
  2. Create conda environment and install dependencies using environment.yml file
conda env create -f environment.yml
  1. If you want to do image downloads from websites (collect step in alternat) using apify pupeeter you need to also first install nodejs and then goto folder apify. Run npm install:
cd <repo_path>
cd alternat/collection/apify
npm install

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 --collect-using-apify <WEBSITE_URL> ./DATADUMP

Use case: Download images recursively for a given site

    # To run the collection 
    python app.py collect --collect-using-apify --download-recursive <WEBSITE_URL> ./DATADUMP

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

alternat-0.1.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

alternat-0.1.0-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file alternat-0.1.0.tar.gz.

File metadata

  • Download URL: alternat-0.1.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2.post20201201 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for alternat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5843c97515a3c0c9f1a4e3f88bc8c528ab3002423c106a25add902965ce83895
MD5 93ce09f61c425d93ab886c1b8abd6ce0
BLAKE2b-256 8d6ea8a2f5be5c10f514cdc04893ad2186f2ddaf6e6ba8ee350af1ec4034178f

See more details on using hashes here.

File details

Details for the file alternat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: alternat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2.post20201201 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

File hashes

Hashes for alternat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b6ba1f7b855d8242eb2faaebc4e0c612c96ee895ef2aef502a8490aa30353a6
MD5 2a4ab19affc4326e3b0e8faafb70d703
BLAKE2b-256 2bef43a17450dffb7d21c23dda29703c2e0df5203072ee3424b3f35220a1b458

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