Deploying a YOLOv5 Model with Flask
The following repository was helpful for deploying a YOLOv5 model using Flask.
It provides a simple web application with an image upload form, as well as REST API samples.
Loading a Custom Model
By modifying the arguments of the load function as follows, it was possible to load a locally trained custom model.
model = torch.hub.load("ultralytics/yolov5", "custom", path='model/best.pt', force_reload=True, autoshape=True)
yolov5-flask/webapp.py at f1ee21bc3b14cdf1a1ea3bc95111a8db31172216 · robmarkcole/yolov5-flask
Official implementation at https://github.com/ultralytics/yolov5/tree/master/utils/flask_rest_api - robmarkcole/yolov5-flask
Adjust the path value as needed. The force_reload and autoshape options are optional, and in my environment it worked without specifying them.
Comments
…