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

"train_sample_1.pickle" in code #3

Open
Doris1039 opened this issue Dec 21, 2020 · 9 comments
Open

"train_sample_1.pickle" in code #3

Doris1039 opened this issue Dec 21, 2020 · 9 comments

Comments

@Doris1039
Copy link

Hi Authors,
I'm getting the following error when running 'train_my_model' file., 'No such file or directory: 'data/ACD/Szada/train_sample_1.pickle''
I noticed that in your code there is a load_train_data and load_test data function.
image

Could you please help with that? Thanks a lot.

@ChenHongruixuan
Copy link
Owner

The pickle file we generated contains the images for training and testing. You can generate the dataset in any form as your wish. We will upload the python script for generating pickle file.

@Doris1039
Copy link
Author

The pickle file we generated contains the images for training and testing. You can generate the dataset in any form as your wish. We will upload the python script for generating pickle file.

Thanks a lot!

@ranch-hands
Copy link

Hi Authors,
I'm getting the following error when running 'train_my_model' file., 'No such file or directory: 'data/ACD/Szada/train_sample_1.pickle''
I noticed that in your code there is a load_train_data and load_test data function.
image

Could you please help with that? Thanks a lot.

dear DORIS
IM stocked in this ditch like problem. did u find an answer?

@aishiliu
Copy link

aishiliu commented Feb 6, 2021

Hi Authors,
I'm getting the following error when running 'train_my_model' file., 'No such file or directory: 'data/ACD/Szada/train_sample_1.pickle''
I noticed that in your code there is a load_train_data and load_test data function.
image

Could you please help with that? Thanks a lot.

Hi.I still haven't found the python script for generating pickle file.Could you please tell me how you solved this problem?thanks a lot!

@ktncktnc
Copy link

ktncktnc commented Feb 27, 2021

Hi, I met the same problem and I solved this. You can read all train data and dump it into a pickle file using file get_sample.py inside folder Supervised.

@ChenHongruixuan
Copy link
Owner

ChenHongruixuan commented Feb 27, 2021 via email

@asfak-kayamkhani
Copy link

def load_test_data():
file = open("data/Szada/test_sample_1.pickle", "rb")
test_X = pickle.load(file)
file.close()
file = open("data/Szada/test_sample_2.pickle", "rb")
test_Y = pickle.load(file)
file.close()
file = open("data/Szada/test_label.pickle", "rb")
test_label = pickle.load(file)
file.close()
return test_X, test_Y, test_label

Try this code...It worked for me.
->Another way to load pickle data
->Once check your pickle format where you write and read pickle data
->It should be .pkl or .pickle but should be same at both places

@aishiliu
Copy link

aishiliu commented Mar 12, 2021 via email

@asfak-kayamkhani
Copy link

Hello! Thank you very much for your sharing!But one of my problems is that I don't know how to save the images in the data set as pickle files.How do you solve this problem?Can you give me some Pointers?Thank you very much!

------------------ 原始邮件 ------------------ 发件人: "I-Hope-Peace/DSMSCN" @.>; 发送时间: 2021年3月12日(星期五) 上午7:38 @.>; @.@.>; 主题: Re: [I-Hope-Peace/DSMSCN] "train_sample_1.pickle" in code (#3) def load_test_data(): file = open("data/Szada/test_sample_1.pickle", "rb") test_X = pickle.load(file) file.close() file = open("data/Szada/test_sample_2.pickle", "rb") test_Y = pickle.load(file) file.close() file = open("data/Szada/test_label.pickle", "rb") test_label = pickle.load(file) file.close() return test_X, test_Y, test_label Try this code...It worked for me. ->Another way to load pickle data ->Once check your pickle format where you write and read pickle data ->It should be .pkl or .pickle but should be same at both places — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

There are two ways to save pickle data

=>1st:
def read_data():
path = 'data/Szada/train'
test_img_1 = []
test_img_2 = []
test_label = []
file_names = sorted(os.listdir(path))
for file_name in file_names:
if file_name[-4:].upper() == '.BMP':
img = cv.imread(os.path.join(path, file_name))
if img.shape[0] > img.shape[1]:
img = img[0:784, :, :]
elif img.shape[0] < img.shape[1]:
img = img[:, 0:784, :]
if 'gt.bmp' in file_name.lower():
img = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
train_label.append(img)
elif 'im1.bmp' in file_name.lower():
train_img_1.append(img)
elif 'im2.bmp' in file_name.lower():
train_img_2.append(img)
file = open("data/Szada/train_sample_1.pickle", "wb")
pickle.dump(train_img_1, file)
file.close()
file = open("data/Szada/train_sample_2.pickle", "wb")
pickle.dump(train_img_2, file)
file.close()
file = open("data/Szada/train_label.pickle", "wb")
pickle.dump(train_label, file)
file.close()
return train_img_1, train_img_2, train_label

=>2nd:

def read_data():
path = 'data/Szada/train'
train_img_1 = []
train_img_2 = []
train_label = []
file_names = sorted(os.listdir(path))
for file_name in file_names:
if file_name[-4:].upper() == '.BMP':
img = cv.imread(os.path.join(path, file_name))
if img.shape[0] > img.shape[1]:
img = img[0:784, :, :]
elif img.shape[0] < img.shape[1]:
img = img[:, 0:784, :]
if 'gt.bmp' in file_name.lower():
img = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
train_label.append(img)
elif 'im1.bmp' in file_name.lower():
train_img_1.append(img)
elif 'im2.bmp' in file_name.lower():
train_img_2.append(img)
with open('data/Szada/train_sample_1.pickle', 'wb') as file:
pickle.dump(train_img_1, file)
print(train_img_1)
with open('data/Szada/train_sample_2.pickle', 'wb') as file:
pickle.dump(train_img_2, file)
with open('data/Szada/train_label.pickle', 'wb') as file:
pickle.dump(train_label, file)
return train_img_1, train_img_2, train_label

steps=>
1 create a folder name data/Szada
2 give path to data set which you are taking for modeling
3 define these function
4 call these function by ----> read_data() or xm,ym,zm=read_data1()
where xm,ym,zm are three pickle files to visualize
5 check in folder there should be pickle files

Note: Dont forget to import pickle

Hope this will solve your issue!!!!

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

6 participants