'(Closed)openCV AttributeError: 'NoneType' object has no attribute 'shape'
I am reading a dataset of 1500 images as follows:
def readImage(img_path):
img = cv2.imread(img_path,0)
print(img.shape)
if img is None:
print('Wrong path:', img_path)
else:
return cv2.resize(img, (150,150), interpolation = cv2.INTER_AREA)
I have tried my code using a lower number of images and it works. But when I use the full dataset I get this error:
AttributeError: 'NoneType' object has no attribute 'shape'
Could anyone please help me to solve this issue?
Thanks a lot in advance.
Solution 1:[1]
You can apply Jinja templating in the given path, which means code between double curly braces is evaluated at runtime. For example:
destination_cloud_storage_uris=['gs://bucket/{{ ds }}/tablename']
(note: no f-string)
In this example, ds is a variable available in Airflow at runtime, which represents the start date of the interval, formatted as YYYY-MM-DD, e.g. 2021-01-01. So the full path is evaluated at runtime as 'gs://bucket/2021-01-01/tablename'.
Airflow provides several variables at runtime which you can use for templating, see the full list here: https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bas Harenslak |
