PHPackages                             funcai/funcai-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. funcai/funcai-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

funcai/funcai-php
=================

High performance, state of the art machine learning in php

v0.5.4(4y ago)51581MITCPHP ^7.4.0|^8.0

Since Apr 2Pushed 4y ago2 watchersCompare

[ Source](https://github.com/funcai/funcai-php)[ Packagist](https://packagist.org/packages/funcai/funcai-php)[ RSS](/packages/funcai-funcai-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (3)Versions (25)Used By (0)

🌟 FuncAI PHP 🌟
===============

[](#-funcai-php-)

####  FuncAI is a high performance, state of the art machine learning library for PHP.
 It has no dependencies and can run everywhere PHP can run.

[](#----funcai-is-a-high-performance-state-of-the-art-machine-learning-library-for-php----it-has-no-dependencies-and-can-run-everywhere-php-can-run)

[ ![If you can spare 2 minutes, please give me some feedback](https://raw.githubusercontent.com/funcai/funcai-php/main/.github/img/feedback.png)](https://sopamo.typeform.com/to/TjmZPnFo)

---

### 🖼️ Image stylization 🖼️

[](#️-image-stylization-️)

Apply the style of one image to another image. #### Example

[](#example)

[![Shows mona lisa and a comic character which combined result in a third image of mona lisa in the style of the comic character](https://raw.githubusercontent.com/funcai/funcai-php/main/.github/img/php-ai-image-stylization.jpg)](https://raw.githubusercontent.com/funcai/funcai-php/main/.github/img/php-ai-image-stylization.jpg)

#### Use it for:

[](#use-it-for)

- Generating artistic versions of user provided images
- Ensuring a consistent style of cover images
- For anonymizing avatars

#### Credits

[](#credits)

- [The Tensorflow model](https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2)
- [The Paper](https://arxiv.org/abs/1705.06830)

---

### 🏷️ Image classification 🏷️

[](#️-image-classification-️)

Find out what's in an image. Returns the top 5 classes out of a list of 21.825 classes. #### Example

[](#example-1)

[![An image of a butterfly and 5 matching labels next to it](https://raw.githubusercontent.com/funcai/funcai-php/main/.github/img/php-ai-image-classification.jpg)](https://raw.githubusercontent.com/funcai/funcai-php/main/.github/img/php-ai-image-classification.jpg)

#### Use it for:

[](#use-it-for-1)

- Making your images searchable by content
- Automatically generating image names or alt attributes
- Grouping your images by content

#### Credits

[](#credits-1)

- [The Tensorflow model](https://tfhub.dev/google/bit/m-r50x1/imagenet21k_classification/1)
- [The Paper](https://arxiv.org/abs/1912.11370)

---

### Future applications

[](#future-applications)

- **Image recognition** - Get a label for a given image (in progress)
- **Image upscaling** - Increase the size of your images (in progress)
- **Sentiment analysis** - Find out if a user generated text is positive or negative (in progress)
- **Time series forecasting** - Predict what will happen in the future based on past events (planned)
- **Text summary** - Generate a summary from a given text (in progress)
- **Translation** - Translate your text from one language to another (planned, , , )

If you have a usecase that's not listed above, please create an [issue](https://github.com/funcai/funcai-php/issues/new) and explain what you would like to do.

Features
--------

[](#features)

- **Runs everywhere** - You only need PHP, **nothing else**
- **Super simple API** - No machine learning knowledge required
- **Many applications** - Wide range of machine learning applications ready to use

Installation
------------

[](#installation)

#### 1. Install the package via [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos):

[](#1-install-the-package-via-composer)

```
composer require funcai/funcai-php

```

#### 2. Download the tensorflow library:

[](#2-download-the-tensorflow-library)

```
php vendor/funcai/funcai-php/install.php

```

This downloads tensorflow to `./tensorflow`.

#### 3. Download a model

[](#3-download-a-model)

```
php vendor/funcai/funcai-php/install-stylization.php

```

This downloads the stylization model to `./models`

#### 4. Configure the models folder

[](#4-configure-the-models-folder)

You will need to move the models folder to a permanent location. For example, move it to `/var/www/models` on your server. In that case make sure to set the base path accordingly:

```
\FuncAI\Config::setModelBasePath('/var/www/models');

```

You can also move the folder directly into your project and check them into git, but the folder might get quite big (100 Mb up to multiple Gb).

Usage
-----

[](#usage)

After you've completed the installation steps you can run your first prediction:

```
\FuncAI\Config::setLibPath('./tensorflow/'); // This should point to the path from step 2
\FuncAI\Config::setModelBasePath('./models'); // This should point to the path from step 4
$model = new \FuncAI\Models\Stylization();
$model->predict([
__DIR__ . '/sample_data/prince-akachi.jpg',
__DIR__ . '/sample_data/style.jpg',
]);

```

This will output the stylized image to `./out.jpg`.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4 on Linux

### About machine learning

[](#about-machine-learning)

todo

- Pick the correct tasks (easy for computer, hard / repetitive for humans)
- Responsibility ([https://www.tensorflow.org/responsible\_ai](https://www.tensorflow.org/responsible_ai))
- Uncertainty
- Specific tasks

### How to run the docker file

[](#how-to-run-the-docker-file)

- Run `docker-compose up -d`
- Run `docker-compose exec app bash`
- Run `php example.php`

### Architecture

[](#architecture)

- Uses [FFI](https://www.php.net/manual/en/class.ffi.php) to talk to tensorflow for predictions
- Uses a custom written c++ program for training (in progress)
- Currently runs on linux with CPU support

### Todo

[](#todo)

- Fix path of libtensorflow.so in tf\_singlefile.h
- Find a better way to download/host models
- Check for memory leaks

### Development

[](#development)

#### Docker (optional, but recommended)

[](#docker-optional-but-recommended)

Install [Docker](https://docs.docker.com/get-docker/).

#### Download the efficientnet model

[](#download-the-efficientnet-model)

To be able to run the example file you need to run the following docker command which will download the efficientnet model and save it in the correct file format:

```
docker run -it --rm -v $PWD:/code -w /code tensorflow/tensorflow:2.3.0 python scripts/generate/efficientnet.py

```

Alternatively, if you already have python3 installed you can directly run:

```
pip3 install tensorflow
python3 scripts/generate/efficientnet.py

```

#### Run the provided Docker container (optional)

[](#run-the-provided-docker-container-optional)

To start the provided Docker container which provides you with a working php7.4 installation run:

```
docker-compose up -d

```

Afterwards run:

```
docker-compose exec app bash

```

to get a Terminal inside of the docker container.

Alternatively you can setup a PHP 7.4 environment locally and use that.

#### Better phpstorm support (optional)

[](#better-phpstorm-support-optional)

Go to your settings and open "Languages &amp; Frameworks -&gt; PHP -&gt; PHP Runtime -&gt; Others". Make sure "FFI" is checked.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~19 days

Total

19

Last Release

1634d ago

PHP version history (2 changes)v0.1.1PHP ^7.4.0

v0.1.5PHP ^7.4.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2770f12db29ebb2434ff9f1368dc67fe97985260c8c4f1cc4042caf2e2327e96?d=identicon)[Sopamo](/maintainers/Sopamo)

---

Top Contributors

[![Sopamo](https://avatars.githubusercontent.com/u/1202596?v=4)](https://github.com/Sopamo "Sopamo (52 commits)")

---

Tags

aiffifuncai-phpimage-recognitionimage-style-transfermachine-learningphptensorflowtensorflow2aimachine learningpredictionimage recognitionffitensorflow

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/funcai-funcai-php/health.svg)

```
[![Health](https://phpackages.com/badges/funcai-funcai-php/health.svg)](https://phpackages.com/packages/funcai-funcai-php)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[codewithkyrian/transformers

State-of-the-art Machine Learning for PHP. Run Transformers in PHP

749231.8k5](/packages/codewithkyrian-transformers)[davmixcool/php-sentiment-analyzer

PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).

138151.7k1](/packages/davmixcool-php-sentiment-analyzer)[denissimon/prediction-builder

A library for machine learning that builds predictions using a linear regression.

1146.7k](/packages/denissimon-prediction-builder)[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

632.3k](/packages/rubix-server)[salehhashemi/laravel-intelli-git

An intelligent Git helper package for Laravel applications. It utilizes OpenAI's GPT to analyze your Git repository, providing features such as automatic generation of commit messages based on staged changes.

131.5k](/packages/salehhashemi-laravel-intelli-git)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
