A python module to recognize the existence of food in images by using a trained AI - SFCA.
In order to run the iSeefood module, you need to install the following packages:
- Numpy
- Tensorflow
- Pillow
- Nose
- Tornado
- You can just run the following command to install all required packages:
$ pip install -r requirements.txt
-
Download/ Clone the source code.
NOTE: Make sure that you download all the saved_model data file (≈217MB).
You can download the saved_model files:
-
Manualy through the repository.
-
By running the following command:
$ git lfs pull
-
-
Copy the iSeefood file to your project directory.
Recommended file structure:
yourProject/ ├── iSeefood/ │ ├── README.md │ ├── SeefoodAI.py │ ├── __init__.py │ ├── samples/ │ └── saved_model/ │ ├── checkpoint │ ├── model_epoch5.ckpt.data-00000-of-00001 │ ├── model_epoch5.ckpt.index │ └── model_epoch5.ckpt.meta ├── __init__.py └── main.py
-
Import the package to your main.py file.
from iSeefood import SeefoodAI
-
Instantiate a new object.
example = SeefoodAI()
-
Pass an image to be processed (.png and .jpg only).
example.process('../image.png')
-
Get the processing statistics.
statistics = example.getScore()
-
Evaluate the statistics.
result = example.getResult(statistics)
from iSeefood.SeefoodAI import SeefoodAI
example = SeefoodAI()
example.process("../cookies.png")
statistics = example.getScores()
result = example.getResult(statistics)
print 'Does the image contains food: ', result
Does the image contains food: True
-
SeefoodAI class assumes that the saved_models are stored in the following path:
yourWorkingDirectory/iSeefood/saved_model/
-
If you try to run your project from any location other than the project-base-path, the SeefoodAI class will not be able to find the saved_model directory!
-
If you would like to manipulate the directory location, you will have to update saved_models/ direcotry path inside the SeefoodAI.py class. The saved_models directory is specified inside the __setup() function.
def __setup(self): ...... saver = tf.train.import_meta_graph( 'yourCustomizedPath/iSeefood/saved_model/model_epoch5.ckpt.meta') saver.restore(self.sess, tf.train.latest_checkpoint('yourCustomizedPath/iSeefood/saved_model/')) ......
Function | Parameter | Return value | Description |
---|---|---|---|
process() | image_path:String | True/False:bool | If the image has been processed, then True. Else, then False. |
getScores() | --- | numpy.ndarray | Returns the data of the last processed image. |
getResult() | scores:numpy.ndarray | True/False:bool | If there is food in the image, then True. Else, then False. |
- Tensorflow - An E2E open source machine learning platform.
- Pytest - Testing framework.
- Travis CI - CI service.
- CodeFactor - Automated code review tool.
- Codecov - A code coverage measurement tool
We use Github for versioning. For the versions available, see the tags on this repository.
- Ibrahim Almohaimeed - Github account
This project is licensed under the MIT License - see LICENSE for details.
- Machine Learning and Complex Systems Lab at Wright State University - GitHub repo