Skip to content

Commit 29a8e95

Browse files
committed
Improve readme
1 parent 0e846c8 commit 29a8e95

File tree

2 files changed

+47
-18
lines changed

2 files changed

+47
-18
lines changed

Readme.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,24 @@ High performance, state of the art machine learning in php.
1212

1313
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.
1414

15-
### Features
15+
## Features
1616

1717
- **Runs everywhere** - You only need PHP, **nothing else**
1818
- **Super simple API** - No machine learning knowledge required
1919
- **Maximum performance** - Preloads the machine learning core, so predictions are super fast
2020

21-
### Installation
22-
Install the package via composer:
21+
## Installation
22+
#### 1. Install the package via composer:
2323

2424
composer require funcai/funcai-php
2525

26+
#### 2. Download the tensorflow library:
27+
28+
php vendor/funcai/funcai-php/install.php
29+
30+
This downloads tensorflow to `./tensorflow`.
31+
32+
#### 3. Download the required models
2633
Until we've figured out a solution for how to host the final models, the following step is a bit more difficult than we'd like it to be.
2734

2835
You'll need to have python installed (locally), and some sort of way to host the model files yourself.
@@ -32,27 +39,39 @@ To generate the model, run:
3239
pip3 install tensorflow
3340
python3 vendor/funcai/funcai-php/scripts/generate/efficientnet.py
3441

35-
The model will be placed in vendor/funcai/funcai-php/models/efficientnet. You will need to have access to this folder from your webserver. For example, if you've uploaded the folder to /var/www/models/efficientnet, you should set the path like this:
42+
The model will be placed in vendor/funcai/funcai-php/models.
43+
44+
#### 4. Configure the models folder
45+
You will need to move the models folder to a permanent location.
46+
For example, move it to `/var/www/models` on your server. In that case make sure to set the base path accordingly:
3647

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

50+
You can also just 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).
3951

40-
### Requirements
41-
- Either the provided dockerfile
42-
- Or PHP >= 7.4 on Linux
52+
## Usage
53+
After you've completed the installation steps you can run your first prediction:
4354

44-
### Run with docker
55+
\FuncAI\Config::setLibPath('./tensorflow/'); // This should point to the path from step 2
56+
$model = new \FuncAI\Models\EfficientNet();
57+
$output = $model->predict('./vendor/funcai/funcai-php/sample_data/butterfly.jpg');
4558

46-
- Run `docker-compose up -d`
47-
- Run `docker-compose exec app bash`
48-
- Run `php example.php`
59+
## Requirements
60+
- PHP >= 7.4 on Linux
61+
- Or use the provided Dockerfile
4962

5063
### About machine learning
5164
todo
52-
- Pick the correct tasks (easy for computer, hard / repetitive for humans)
53-
- Training bias dilemma
54-
- Uncertainty
55-
- Specific tasks
65+
- Pick the correct tasks (easy for computer, hard / repetitive for humans)
66+
- Training bias dilemma
67+
- Uncertainty
68+
- Specific tasks
69+
70+
### How to run the docker file
71+
72+
- Run `docker-compose up -d`
73+
- Run `docker-compose exec app bash`
74+
- Run `php example.php`
5675

5776
### Architecture
5877

@@ -68,14 +87,14 @@ todo
6887
### Development
6988

7089
#### Docker (optional, but recommended)
71-
Install [Docker](https://docs.docker.com/get-docker/) if you do not have it already.
90+
Install [Docker](https://docs.docker.com/get-docker/).
7291

7392
#### Download the efficientnet model
7493
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:
7594

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

78-
Alternatively, if you already have python3 installed you can run:
97+
Alternatively, if you already have python3 installed you can just run:
7998

8099
pip3 install tensorflow
81100
python3 scripts/generate/efficientnet.py
@@ -89,7 +108,9 @@ Afterwards run:
89108

90109
docker-compose exec app bash
91110

92-
to get a Terminal inside of the docker container
111+
to get a Terminal inside of the docker container.
112+
113+
Alternatively you can just setup a PHP 7.4 environment locally and use that.
93114

94115
#### Better phpstorm support (optional)
95116
Go to your settings and open "Languages & Frameworks -> PHP -> PHP Runtime -> Others". Make sure "FFI" is checked.

install.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
require __DIR__.'/vendor/autoload.php';
3+
4+
// Specify where tensorflow should be downloaded to
5+
\FuncAI\Config::setLibPath('./tensorflow/');
6+
7+
$tfi = new \FuncAI\Install\TensorflowInstaller();
8+
$tfi->install();

0 commit comments

Comments
 (0)