STEP 1 : Create a virtual environment in model folder
- Change working directory to model :
cd model
- Install virtualenv package if it is not installed already :
pip install virtualenv
- Create virtual environment :
virtualenv venv
STEP 2 : Activate virtual environment :
venv\Scripts\activate
This command need administrative permissions. Use command prompt to execute this Will not work in powershell
STEP 3 : Install required libraries
pip install -r requirements.txt
STEP 4 : Run flask app
python app.py
After this the api will be up and running on : localhost:8080 You can now give api calls from react frontend.
API ROUTES :
- '/predict_pose' : To predict head pose
- '/predict_people' : To predict number of people in input image
NOTE :
- Both of these function takes as input a b64 encoded string which is sent via react webcam.
- For testing purposes you will find a sample encoded string of foward pose image given below in sample_input.txt file .
NOTE :
- Here we are detecting only 3 directions (forward, left , right) because that is all we need.
- The number of detected directions can be increased.
- To detect more directions go to draw annotations function in pose_estimator.py file and elif conditions for more angles.
if angles[1] < -15:
GAZE = "Looking: Left"
elif angles[1] > 15:
GAZE = "Looking: Right"
else:
GAZE = "Forward"
NOTE :
The number of people detected can be changed via lowering the threshold To do that go to predict funtion in app.py and change the variable threshold Our default value is 0.5
threshold = 0.5
- Original repo for pose-estimation-model 👉 REPO_LINK
- Link for object detection model 👉 MODEL_LINK