Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ankitpokhrel/alt
[EXPERIMENTAL] Facebook-like automatic alternative (alt) text for images using object detection with pre-trained model.
https://github.com/ankitpokhrel/alt
autotext deep-neural-network made-in-nepal object-detection opencv php-library php-opencv php7 single-shot-detection
Last synced: 13 days ago
JSON representation
[EXPERIMENTAL] Facebook-like automatic alternative (alt) text for images using object detection with pre-trained model.
- Host: GitHub
- URL: https://github.com/ankitpokhrel/alt
- Owner: ankitpokhrel
- License: mit
- Created: 2019-02-25T16:23:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T19:13:33.000Z (about 1 year ago)
- Last Synced: 2024-05-28T13:24:11.010Z (6 months ago)
- Topics: autotext, deep-neural-network, made-in-nepal, object-detection, opencv, php-library, php-opencv, php7, single-shot-detection
- Language: PHP
- Homepage: https://captionai.co
- Size: 32.1 MB
- Stars: 83
- Watchers: 5
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# This project is now available at [captionai.co](https://captionai.co)
> [CaptionAI](https://captionai.co) effortlessly generates automatic image captions (alternate text), description, tags, and helps you categorize images using the power of AI.
# alt [![Build Status](https://img.shields.io/travis/ankitpokhrel/alt/master.svg?style=flat-square)](https://travis-ci.org/ankitpokhrel/alt)
> This project is no longer maintained.
_Automatic alternative (alt) text for images using object detection with pre-trained model._
### Overview
A very simple PHP library to generate alternative (alt) text for images using pre-trained tensorflow model to detect objects in an image. These texts can provide context about image to visitors who are unable to see images in their browser for whatever reasons. Alt texts can also be picked up by screen readers to convert it to speech, thus, providing additional context to visually impaired people and enhancing our user experience.
> This nifty little tool is inspired by [facebook alt text generation](https://code.fb.com/ios/under-the-hood-building-accessibility-tools-for-the-visually-impaired-on-facebook/) process.
### Example
| | | | |
|-|-|-|-|
|
_Image may contain: cup, potted, laptop_ |
_Image may contain: 6 person, cup, laptop_ |
_Image may contain: 5 person, car, motorcycle_ |
_Image may contain: 1 person, car, bus, truck, traffic light_ |
|
_Image may contain: chair, couch_ |
_Image may contain: pizza, dining table_ |
_Image may contain: dog_ |
_Image may contain: bird_ |### Installation
> Requires: PHP 7.1.3+, [OpenCV](https://opencv.org/), [PHP OpenCV](https://github.com/php-opencv/php-opencv)
> Model used: [SSDLite COCO v2](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md)Pull the package via composer.
```shell
$ composer require ankitpokhrel/alt
```### Usage
```php
$alt = new \Alt\Alt('/path/to/image.ext');echo $alt->alt(); // Image may contain: 6 person, cup, laptop
$alt->setImage('/path/to/image.ext')->alt(); // Image may contain: car, motorcycle
```### Threshold
The classification threshold is set to `30` by default. You can adjust it as your need.
```php
$alt->setThreshold(25);
```### Prefix
By default the alt is prefixed with `Image may contain: `. You can change this as below:
```php
$alt->setPrefix('Image has: ');
```### Countable
If you want to display the count of an object, you can do so by setting `countable` array. `person` is countable by default.
```php
$alt->setImage('/path/to/image.ext')->alt(); // Image may contain: 5 person, dog, cup// Adding dog as countable
$alt->setCountable(['person', 'dog'])->alt(); // Image may contain: 5 person, 2 dog, cup
```### Default text
Default text is used if the model is not able to predict any objects within a given threshold. Default default text is `No photo description available.`.
```php
$alt->setDefaultText('Some scenery.');
```