Skip to main content

Sentiment Analysis

This example demonstrates how you can deploy a function that performs secure sentiment analysis 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.


Clone the capeprivacy/functions public repository:

git clone

Navigate into the folder containing the code for the sentiment analysis function:

cd sentiment_analysis

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.


Log in to Cape using:

cape login

Which produces:

Your CLI confirmation code is: <SOME_CODE>
Visit this URL to complete the login process:<SOME_CODE>
Congratulations, you're all set!


Deploy your function to Cape using:

cape deploy ./deploy

Which produces:

Deploying function to Cape ...
Success! Deployed function to Cape
Function ID ➜ QF7NRfns5o4qWC9sjxhfB5
Checksum ➜ eb989a5ef2fabf377a11ad5464b81b67757fada90a268c8c6d8f2d95013c4681


Invoke your function using:

cape run QF7NRfns5o4qWC9sjxhfB5 "This was a great film"

Which produces:

78.08% positive

Feel free to try with other phrases:

cape run QF7NRfns5o4qWC9sjxhfB5 "This was a terrible film"


We are actively soliciting feedback from our beta. Please use this form to provide feedback.