How To Create Flask API For YOLO Deep Learning Model.
In this blog we are implement flask api for yolo deep learning model
According to wikipedia
An application programming interface is a computing interface which defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow, etc.
we are create Flask api for this.
Flask is a web application framework written in Python. It has multiple modules that make it easier for a web developer to write applications without having to worry about the details like protocol management, thread management, etc.
Flask gives is a variety of choices for developing web applications and it gives us the necessary tools and libraries that allow us to build a web application.
Now come to the python code.
First we need to clone my project then download pre-trained machine learning model for detection
One more point guys we are using cpu for this. you can also Deploy your model on GPU or any other server machine.
Source Code : git clone https://github.com/Manishsinghrajput98/ML_Flask_APIs.git
cmd : - cd ML_Flask_APIs
In clone project i have mentioned 3 requirement txt file according our need in project
cmd :- cd yolo_ml_flask_api
You can create virtual environment for this
cmd :- virtual myvenv
After this you have to activate the virtual environment
cmd :- source local/bin/myvenv
cmd :- pip install -r requirements.txt
After this you need to download pre-trained model i have providing. you can download easily.
Download Pre-Trained Model
cmd :- wget https://pjreddie.com/media/files/yolov3.weights
After download you need to copy your downloaded model in our clone project
And also we need a Postman software to test our API. you need to download postman and then sign up Login.Postman is a scalable API testing tool that quickly integrates into CI/CD pipeline
After this. we are ready to test our api on Postman.
Step by step how to use Click Here
The project structure looks like
cmd :- python yolo_ml_flask_api.py --port 8080
looks like
After this you need to open postman to hit our api
The address of our server to past in postman
Address :- http://localhost:8080/start (This is my local system address. If you have any other server so past these address)
Also we need parameter of our api
Also you can see the images. i have write the detected images in our project.
Note :- Friends this is the complete Flask API with real time Project. you can use these api for your project. in real time project we need a class name of images, this api also return class name and detected images save in our project also you can try this api on videos with FFMPEG (need to some changes)..
just copy your model path,cfg file, class name txt, and past these api.
If you have any doubt so please comment
Thanks
No comments:
Post a Comment
If you have any doubts. Please let me know