MiDaS
MiDaS copied to clipboard
How to upload my picture correctly ????
When I include my picture in the code in the second step
import cv2
import torch
import urllib.request
import matplotlib.pyplot as plt
url, filename = ("https://github.com/lednevandrey04/hellow-world/blob/main/Gerl.jpg", "Gerl.jpg")
urllib.request.urlretrieve(url, filename)
I get an answer
('Gerl.jpg', <http.client.HTTPMessage at 0x7fc71448d9d0>)
But when executing the code in the sixth step
img = cv2.imread(filename)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
input_batch = transform(img).to(device)
I get an error
error Traceback (most recent call last)
<ipython-input-9-c79ee4175c1e> in <module>()
1 img = cv2.imread(filename)
----> 2 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 3 4 input_batch = transform(img).to(device)
error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Thus ... This error happened because the image didn't load properly
How to upload my picture correctly ????
url, filename = ("https://github.com/lednevandrey04/hellow-world/raw/main/Gerl.jpg", "Gerl.jpg")