Alternat is a tool that automates alt text generation.
Project description
alternat: Automate your image alt-text generation workflow.
Resources
- Homepage and Reference: https://alternat.readthedocs.io/
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.
- Azure API - Uses Azure API for image captioning and OCR. Note Azure is a paid service.
- Google API - Uses google API for image captioning and OCR. Note google is a paid service.
- Open Source - Uses free open source alternative for OCR.
Supported Video and image file formats jpeg, jpg and png are supported.
Installation
Using pypi
- Install node (>=v.12)
- Install Python >= 3.8
- pip install alternat
Install from source
- Install git
- Install node (>=v.12)
- Install python >= 3.8
- Open terminal or command prompt
- Clone repo from here https://github.com/keplerlab/alternat.git
- Change the directory to the directory where you have cloned your repo
$cd path_to_the_folder_repo_cloned
Mac and Linux
-
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
-
Download and Install Docker Desktop for Mac using this link docker-desktop
-
Clone this repo https://github.com/keplerlab/alternat.git
-
Change your directory to your cloned repo.
-
Open terminal and run following commands
cd <path-to-repo> //you need to be in your repo folder
docker-compose build
- Start docker container using this command
docker-compose up
- 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
- Install node (>=v.12)
- Create conda environment and install dependencies using environment.yml file
conda env create -f environment.yml
- 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 --input-image-file-path=./image.jpg --output-dir-path=./results/
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=./DATADUMP/ --output-dir-path=./results
or
# To generate alt-text using specific driver (like azure, google or open source)
python app.py generate --input-image-file-path=./images_with_text/sample_images/Hotel-thumbnail.jpg --output-dir-path=./results/ --driver-config-file-path="./sample/sample_conf_generator_driver/azure.json"
Sample images are located at images/sample_images
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
Built Distributions
File details
Details for the file alternat-0.0.2.tar.gz
.
File metadata
- Download URL: alternat-0.0.2.tar.gz
- Upload date:
- Size: 25.7 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.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eab050dd3db41bc43b9e4f33fe4708f60b76cdcb34c249a4af913a560b045ed3 |
|
MD5 | 65b5024c3bcd1b79787f508f9bfe3905 |
|
BLAKE2b-256 | a4ebd1ea4e585d352761c20b2f8f4cefca83e732b8281bfc730c0dba45e6756a |
File details
Details for the file alternat-0.0.2-py3.7.egg
.
File metadata
- Download URL: alternat-0.0.2-py3.7.egg
- Upload date:
- Size: 75.9 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.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16fc5ab2dd5bfc085fa5d8b759920c2a35579a7ec25f8f4afdd4eba04b64ab16 |
|
MD5 | 24214baccc4c7fca8c093d7176a6b049 |
|
BLAKE2b-256 | 4621caf2d2988d3ce435e14083ba3f43b6a822e6e479e105602072c8321d27c1 |
File details
Details for the file alternat-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: alternat-0.0.2-py3-none-any.whl
- Upload date:
- Size: 36.1 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.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e4440886988ccbf5a19ccef1ee6e7aae7c084fcd7ded8c654ba2281505ea1b7 |
|
MD5 | a4abe122b641980e94c717d9e15ebe67 |
|
BLAKE2b-256 | dd9f0a8ca2431db972d3b47d4c8de1eae04c96d88a891bd6c6ca30e4240c9370 |