MNM
MNM

Reputation: 2743

ImageGenerator using Resnet

I am trying to build a image generator that will:

  1. Take in a raw image
  2. Read in the image and resize it to (224,224,3) for resnet50
  3. Perform data augmentation on it (rotation, flipping, etc.)
  4. Create a Resnet50 feature for it (using model.predict)
  5. Then output this in the image generator via yield method

What I cannot figure out is how to actually do this. I am making this as a triple loss so one image is an anchor, positive, and negative image.

It says:

TypeError: len() of unsized object

Updates

I have changed the code a bit but now it is giving me this error.

Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (224, 224, 3)

Upvotes: 1

Views: 615

Answers (1)

TheLoneDeranger
TheLoneDeranger

Reputation: 1199

remember that a network expects a batch size. if you're submitting only one image of shape (244,244,3), you'll need to first np.expand_dims(image, axis=0) to achieve shape (1,244,244,3) prior to prediction. That will be 1 image of 244 by 244 with 3 layers, i.e. (1,244,244,3).

It seems like you have some other dimensions, but the point remains, get that batch size dimension in there; that's what your recent error is saying.

Upvotes: 1

Related Questions