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

二分类怎么做? #11

Closed
ahuxjz opened this issue Sep 11, 2019 · 12 comments
Closed

二分类怎么做? #11

ahuxjz opened this issue Sep 11, 2019 · 12 comments

Comments

@ahuxjz
Copy link

ahuxjz commented Sep 11, 2019

No description provided.

@yassouali
Copy link
Owner

Hi, can you provide more information about your issue ?

@ahuxjz
Copy link
Author

ahuxjz commented Sep 12, 2019

Hi, can you provide more information about your issue ?
I have two categories, including background, background pixel value (0,0,0) and target pixel value (255,255,255). How can I modify the code? What are the specific changes? Thank you for your answer!

@ahuxjz
Copy link
Author

ahuxjz commented Sep 12, 2019

嗨,您能提供有关您的问题的更多信息吗?
我有两个类别,包括背景,背景像素值(0,0,0)和目标像素值(255,255,255)。我该如何修改代码?有哪些具体变化?谢谢您的回答!

Because one of my class pixels is (255, 255, 255), is it feasible to set my ignore_index to 255 and palette to a picture? Are there any other details?
TIM图片20190912110247

@ahuxjz
Copy link
Author

ahuxjz commented Sep 12, 2019

嗨,您能提供有关您的问题的更多信息吗?
我有两个类别,包括背景,背景像素值(0,0,0)和目标像素值(255,255,255)。我该如何修改代码?有哪些具体变化?谢谢您的回答!

因为我的一个像素像素是(255,255,255),将ignore_index设置为255并将调色板设置为图片是否可行?还有其他细节吗? TIM图片20190912110247

I modified the code and asked him to do two classifications, including the background, prompting the error Runtime Error: Cuda Runtime Error (59): Device-Side Asset Triggered, as if label overflowed. How should I modify it?

@yassouali
Copy link
Owner

From what I understood, your labels are in RGB format, first, palette is not used to train the model, just for visualization, ignore it completely. Now what you need to do is write your dataloader, and in it you need to transform you labels from shape [H, W ,3 ] into [H, W], where each element is the class label, so what you can do simply take one of the channels (given that you only have two colors, so R=G=B) the labels labels = labels[0] and then change the index of 255 to one labels[labels == 255] 1. I hope I answered your question.

@ahuxjz
Copy link
Author

ahuxjz commented Sep 12, 2019

From what I understood, your labels are in RGB format, first, palette is not used to train the model, just for visualization, ignore it completely. Now what you need to do is write your dataloader, and in it you need to transform you labels from shape [H, W ,3 ] into [H, W], where each element is the class label, so what you can do simply take one of the channels (given that you only have two colors, so R=G=B) the labels labels = labels[0] and then change the index of 255 to one labels[labels == 255] 1. I hope I answered your question.

I don't know if I understand the error. in your code, as shown in the figure, label reads directly the pixel value in the picture. I don't see the code that sets label to the corresponding serial number. can you tell me where to set label[label==255] 1 and what is the function of ignore_index in the code? I am a beginner, thank you for your answer just now.
TIM图片20190912200822

your code : label = np.asarray(Image.open(label_path), dtype=np.int32)

@yassouali
Copy link
Owner

If your label are RBG images, you need to transform them into 1D arrays, after loading the labels do label = label[0] then label[label == 255] = 1

@ahuxjz
Copy link
Author

ahuxjz commented Sep 12, 2019

如果您的标签是RBG图像,你需要将它们转换成一维数组,加载后的标签做label = label[0]那么label[label == 255] = 1
Where is your code set the label number of the label? For example: voc2012 data set 1 represents the aircraft.

@yassouali
Copy link
Owner

Just set the number of classes in the loader to 2 and you're set, you'll have two labels, one and zero.

@ahuxjz
Copy link
Author

ahuxjz commented Sep 14, 2019

只需将加载器中的类数设置为2即可设置,您将拥有两个标签,一个和零。

Thank you for your answer. I trained once yesterday, 5 epochs, no data enhancements. The predictions are all black images. Is my code error or poor performance?

@yassouali
Copy link
Owner

Yeah, I think there is some problem with your labels, see if the masks in tensorboard are correct.

@GewelsJI
Copy link

只需将加载器中的类数设置为2即可设置,您将拥有两个标签,一个和零。

Thank you for your answer. I trained once yesterday, 5 epochs, no data enhancements. The predictions are all black images. Is my code error or poor performance?

Could you share your code what you edit? I face the same problem now

Thanks

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