Context manager open(file) as f fixes (#7289)

* Flask context manager `open()` fix

* Additional read context manager fixes
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-04-05 12:54:25 +02:00
1 parent 2181ef371e
commit 5f97001ed4
5 files changed
+17 -6

No files matched your search

+9 -3
View File
@@ -1,12 +1,18 @@
"""Perform test request"""
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
"""
Perform test request
"""
import pprint
import requests
DETECTION_URL = "http://localhost:5000/v1/object-detection/yolov5s"
TEST_IMAGE = "zidane.jpg"
IMAGE = "zidane.jpg"
image_data = open(TEST_IMAGE, "rb").read()
# Read image
with open(IMAGE, "rb") as f:
image_data = f.read()
response = requests.post(DETECTION_URL, files={"image": image_data}).json()