Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'shape' #155

Closed
khanbhai0078 opened this issue Mar 27, 2021 · 3 comments
Closed

AttributeError: 'NoneType' object has no attribute 'shape' #155

khanbhai0078 opened this issue Mar 27, 2021 · 3 comments

Comments

@khanbhai0078
Copy link

khanbhai0078 commented Mar 27, 2021

@LindenY Kindly help
def crop_top(img, percent=0.15):
offset = int(img.shape[0] * percent)
return img[offset:]

def central_crop(img):
size = min(img.shape[0], img.shape[1])
offset_h = int((img.shape[0] - size) / 2)
offset_w = int((img.shape[1] - size) / 2)
return img[offset_h:offset_h + size, offset_w:offset_w + size]

def process_image_file(filepath, top_percent, size):
img = cv2.imread(filepath)
img = crop_top(img, percent=top_percent)
img = central_crop(img)
img = cv2.resize(img, (size, size))
return img

ERROR

File "C:\Users\KB\Desktop\COVID-Net-master\data.py", line 15, in crop_top
offset = int(img.shape[0] * percent)
AttributeError: 'NoneType' object has no attribute 'shape'

@mayaliliya
Copy link
Collaborator

Hi @khanbhai0078,
This error occurs when the image is not found at the passed-in file path. Please verify that the passed-in data directory is correct and that the image file path is correct (this can be done by printing out the file path passed into the function process_image_file()).

@haydengunraj
Copy link
Collaborator

@khanbhai0078 , this may also be related to #158 , and so if you're using Version 4 of the COVID-19 Radiography Database please try using Version 3.

If you were already using Version 3, please let us know so we can dig a bit deeper.

@khanbhai0078
Copy link
Author

Let me try with version 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants