Image Recognition
This example demonstrates how you can deploy a function that performs secure image recognition using a TensorFlow Lite model. By using Cape, the model is protected because it can only be accessed within a secure enclave. The input data is also protected because it is encrypted prior to being uploaded, and is sent over TLS into the Cape enclave.
Code
Clone the capeprivacy/functions public repository:
git clone git@github.com:capeprivacy/functions.git
Navigate into the folder containing the code for the image recognition function:
cd image_recognition
Install the required dependencies into a target folder (named deploy
in our example):
docker run -v `pwd`:/build -w /build --rm -it python:3.9-slim-bullseye pip install -r requirements.txt --target ./deploy/
Note: sudo
may be required when running this command.
Login
Log in to Cape using:
cape login
Which produces:
Your CLI confirmation code is: <SOME_CODE>
Visit this URL to complete the login process: https://login.capeprivacy.com/activate?user_code=<SOME_CODE>
Congratulations, you're all set!
Deploy
Deploy your function to Cape using:
cape deploy ./deploy
Which produces:
Deploying function to Cape ...
Success! Deployed function to Cape
Function ID ➜ jjAxk3CFnRx7whdi5oPffQ
Checksum ➜ 00f617b57eebfaa29b7f091b3dab104fc690b2173d0de8fa46dc5d426bf6a2e1
Run
Invoke your function using:
cape run jjAxk3CFnRx7whdi5oPffQ -f cat.jpg
Which produces:
Image Label is : 'Egyptian cat' with Accuracy : 72.27 %.
Feel free to try with other images:
cape run jjAxk3CFnRx7whdi5oPffQ -f coffee.jpg
cape run jjAxk3CFnRx7whdi5oPffQ -f lizzard.jpg