A python script that converts Caffe trained model to CoreML in order to use natively with Swift CoreML
The project uses Oxford102.caffemodel as trained model. This model contains flowers and labels and give the ability to classify images and recognize the fauna.
Python trained model available here: https://www.tensorflow.org/datasets/catalog/oxford_flowers102
As iOS only supports python v2.7, in order to run the scipt the following steps needs to be taken:
- Download PIP for Python : https://pip.pypa.io/en/stable/installing/
- Install PIP:
sudo python get-pip.py
- Install virtualEnv:
pip install virtualenv
- Create virtualEnv with python 2.7:
virtualenv --python=/usr/bin/python2.7 python27
- If step 4. fails, then install virtualEnv like this:
sudo /usr/bin/easy_install virtualenv
- Go into the environments folder where the environment was set up and run:
source python27/bin/activate
- If everything goes well, the prompt should show (python27). Now run:
pip install -U coremltools
- After installing coremltools, head to the folder and run the converter script:
python convert-script.py