Skip to content

A python program that uses a trained AI to recognize food in images.

License

Notifications You must be signed in to change notification settings

IbrahimNM/iSeefood

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Requirements Status

What Is This?

A python module to recognize the existence of food in images by using a trained AI - SFCA.

Dependencies

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

How To Use This

  1. 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:

    1. Manualy through the repository.

    2. By running the following command:

      $ git lfs pull
  2. 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
  3. Import the package to your main.py file.

      from iSeefood import SeefoodAI
  4. Instantiate a new object.

      example = SeefoodAI()
  5. Pass an image to be processed (.png and .jpg only).

      example.process('../image.png')
  6. Get the processing statistics.

      statistics = example.getScore()
  7. Evaluate the statistics.

      result = example.getResult(statistics)

Example

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

Output

Does the image contains food:  True

⚠️ Notes

  • 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/'))
      ......

📃 Documentation

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.

Built With

Versioning

We use Github for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see LICENSE for details.

Acknowledgments

  • Machine Learning and Complex Systems Lab at Wright State University - GitHub repo