-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
when running data.py,a problem occured. #11
Comments
Seems that |
This is the source of 'total',i can not find why it is None. def create_train_data():
|
Maybe there's no image under train_data_path
…On Thu, Jan 18, 2018 at 9:08 PM dong-zhang1 ***@***.***> wrote:
This is the source of 'total',i can not find why it is None.
Can you give me some suggests?
def create_train_data():
train_data_path = os.path.join(data_path, 'train')
images = os.listdir(train_data_path)
*total* = len(images) / 2
imgs = np.ndarray((total, 1, image_rows, image_cols), dtype=np.uint8)
imgs_mask = np.ndarray((total, 1, image_rows, image_cols), dtype=np.uint8)
i = 0
print('-'*30)
print('Creating training images...')
print('-'*30)
for image_name in images:
if 'mask' in image_name:
continue
image_mask_name = image_name.split('.')[0] + '_mask.tif'
img = cv2.imread(os.path.join(train_data_path, image_name), cv2.IMREAD_GRAYSCALE)
img_mask = cv2.imread(os.path.join(train_data_path, image_mask_name), cv2.IMREAD_GRAYSCALE)
img = np.array([img])
img_mask = np.array([img_mask])
imgs[i] = img
imgs_mask[i] = img_mask
if i % 100 == 0:
print('Done: {0}/{1} images'.format(i, total))
i += 1
print('Loading done.')
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AJkBS0KRLDCeJCedX2OUGqmChDC1eOLsks5tL0I7gaJpZM4Ri1n->
.
--
Best,
Yihui He
yihui-he.github.io
|
The path has images on it. |
I have changed all 'total' as '5635',but the same error still occurs......
|
Here is my 'data.py'. from future import print_function import os import cv2 data_path = 'raw/' def create_train_data():
def load_train_data(): def preprocess(imgs, img_rows,img_cols): def detseg():
def create_test_data():
def load_test_data(): if name == 'main':
|
Creating training images...
Done: 0/5635 images
Done: 100/5635 images
Traceback (most recent call last):
File "data.py", line 186, in
create_train_data()
File "data.py", line 51, in create_train_data
imgs_mask[i] = img_mask
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
I have tryed 'int(total)',then this problem occured.
"imgs = np.ndarray((int(total), 1, image_rows, image_cols), dtype=np.uint8)
imgs_mask = np.ndarray((int(total), 1, image_rows, image_cols), dtype=np.uint8)
"
The text was updated successfully, but these errors were encountered: