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

Error: all input arrays must have the same shape #39

Closed
einfachluki opened this issue Jan 12, 2022 · 4 comments
Closed

Error: all input arrays must have the same shape #39

einfachluki opened this issue Jan 12, 2022 · 4 comments

Comments

@einfachluki
Copy link

Unfortunately, when following your steps, i get the error: "all input arrays must have the same shape"

@hanxiao
Copy link
Member

hanxiao commented Jan 12, 2022

when following your steps,

could you elaborate it by copy-paste your code here, thanks

@einfachluki
Copy link
Author

Bildschirmfoto 2022-01-12 um 12 25 06

@hanxiao
Copy link
Member

hanxiao commented Jan 12, 2022

based on the part of your code, I'm guessing your input images are not in the same shape, instead they are arbitrary size images. And if I'm correct about it, you need to add a preprocessing step to resize the images. You can do it by:

d = Document()
d.set_image_blob_shape(shape=(128, 128))

If you are working with DocumentArray as in README, then

from docarray import Document

def preproc(d: Document):
    return (d.load_uri_to_image_blob()  # load
             .set_image_blob_shape(shape=(128, 128))  # <----- ADD to unify the shape, 128 is just an example, use whatever makes sense to you
             .set_image_blob_normalization()  # normalize color 
             .set_image_blob_channel_axis(-1, 0))  # switch color axis for the pytorch model later

@einfachluki
Copy link
Author

Thank you!

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

2 participants