diff --git a/utils/downloads.py b/utils/downloads.py index 2e0c00cc..24a17609 100644 --- a/utils/downloads.py +++ b/utils/downloads.py @@ -66,7 +66,7 @@ def attempt_download(file, repo="Oneflow-Inc/one-yolov5", release="v1.2.0"): # Attempt file download from GitHub release assets if not found locally. release = 'latest', 'v7.0', etc. from utils.general import LOGGER - if file.endswith(".pt"): + if str(file).endswith(".pt"): repo, release = "ultralytics/yolov5", "v7.0" def github_assets(repository, version="latest"): diff --git a/utils/flask_rest_api/README.md b/utils/flask_rest_api/README.md index a726acbd..d1b58f53 100644 --- a/utils/flask_rest_api/README.md +++ b/utils/flask_rest_api/README.md @@ -2,7 +2,7 @@ [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) [API](https://en.wikipedia.org/wiki/API)s are commonly used to expose Machine Learning (ML) models to other services. This folder contains an example REST API -created using Flask to expose the YOLOv5s model from [PyTorch Hub](https://pytorch.org/hub/ultralytics_yolov5/). +created using Flask to expose the YOLOv5s model from [OneFlow Hub](https://oneflow.readthedocs.io/en/master/hub.html). ## Requirements diff --git a/utils/flask_rest_api/restapi.py b/utils/flask_rest_api/restapi.py index 83843ae5..013c3e7f 100644 --- a/utils/flask_rest_api/restapi.py +++ b/utils/flask_rest_api/restapi.py @@ -5,11 +5,14 @@ import argparse import io - +import ssl import oneflow as torch from flask import Flask, request from PIL import Image +# https://stackoverflow.com/questions/50236117/scraping-ssl-certificate-verify-failed-error-for-http-en-wikipedia-org +ssl._create_default_https_context = ssl._create_unverified_context + app = Flask(__name__) models = {} @@ -41,8 +44,7 @@ def predict(model): parser.add_argument("--port", default=5000, type=int, help="port number") parser.add_argument("--model", nargs="+", default=["yolov5s"], help="model(s) to run, i.e. --model yolov5n yolov5s") opt = parser.parse_args() - for m in opt.model: - models[m] = torch.hub.load("ultralytics/yolov5", m, force_reload=True, skip_validation=True) + models[m] = torch.hub.load("Oneflow-Inc/one-yolov5", "custom", m, force_reload=True, skip_validation=True) app.run(host="0.0.0.0", port=opt.port) # debug=True causes Restarting with stat