Test the model trained previously on a aws ec2 instance. More details here
Result
curl -w '\n' -F image=@helmet.jpg http://ip:8080/predict -w "\n %{time_connect}:%{time_starttransfer}:%{time_total} \n"
Ec2 instance
I will post here the main configuration for the application, such as how to open the port
In the security group, open the 8080 port
Set up
Access the machine through SSH
- clone this repository
- create an environment with conda env
- in the root folder, execute
pip install -r requirements.txt
- in the root folder, execute
gunicorn --bind=0.0.0.0:8080 server:app
- you should see
[2021-09-09 12:52:20 +0000] [45903] [INFO] Starting gunicorn 20.1.0
[2021-09-09 12:52:20 +0000] [45903] [INFO] Listening at: http://0.0.0.0:8080 (45903)
[2021-09-09 12:52:20 +0000] [45903] [INFO] Using worker: sync
[2021-09-09 12:52:20 +0000] [45904] [INFO] Booting worker with pid: 45904
Our app is now listening to port 8080. The IP? Let’s find out on the ec2 dasboard
- select your instance on ec2 dashboard
- select ipv4 address
Call the endpoint
curl -F image=@helmet.jpg http://your_ipv4_address:8080/predict