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

ValueError: all input arrays must have the same shape in metrics.py (Training with new dataset) #89

Open
R-Ayanami opened this issue Nov 1, 2023 · 3 comments

Comments

@R-Ayanami
Copy link

Thank you for your kind tutorial and framework.
I'm trying to create a new model with my dataset, but "ValueError: all input arrays must have the same shape" occurs in metrics.py. I printed out the output of that part, and I found the input list to np.stack is incorrect. Some lists have 1 element and others have 3 elements. The number of former lists is same as "good" label data. Maybe I mistaked around this part. How can I fix this problem?

@Fritzyuan
Copy link

Hello! I have the same problem so I was wondering how did you solve it?

@R-Ayanami
Copy link
Author

R-Ayanami commented Dec 13, 2023

I thought the metrics.py outputs the zero matrices, so I changed the shape at the point where error is occured.
I added following part in compute_pixelwise_retrieval_metrics() of metrics.py, and the model training has been started:

if isinstance(ground_truth_masks, list):  
    for i in range(len(ground_truth_masks)):
        if len(ground_truth_masks[i]) == 3:
            ground_truth_masks[i] = [ground_truth_masks[i][0]]

This is just a quick fix, so the discussion about metrics.py will help you, I think.
And accutually, I want to know the correct solution about this problem :-)

@MarcSaghir
Copy link

Hey, I had a similar issue when trying to train on my own dataset. The masks of the mvtec dataset are grayscale images, whereas the masks I created by myself had 3 channels/were RGB images. You have to save your masks as grayscale images aswell, and this error shouldn't occurr anymore.

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