Commit 390e41e0 authored by 赵威's avatar 赵威

update request f

parent b773aebf
......@@ -10,17 +10,20 @@ from PIL import Image
def url_to_ndarray(url):
result = requests.get(url, timeout=30)
if result.ok:
img = Image.open(io.BytesIO(result.content))
img = img.convert("RGB")
data = np.array(img)
return data
else:
print("http get: {}".format(result.status_code))
try:
result = requests.get(url, timeout=30)
if result.ok:
img = Image.open(io.BytesIO(result.content))
img = img.convert("RGB")
data = np.array(img)
return data
else:
print("http get: {}".format(result.status_code))
return np.array([])
except Exception as e:
print(e)
return np.array([])
def file_to_ndarray(path):
result = cv2.imread(path)
img = Image.fromarray(result).convert("RGB")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment