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

model.predict() on exported model #109

Open
GaganaB opened this issue May 11, 2020 · 1 comment
Open

model.predict() on exported model #109

GaganaB opened this issue May 11, 2020 · 1 comment

Comments

@GaganaB
Copy link

GaganaB commented May 11, 2020

Hi,

As I explained in this issue here: #95
I was able to resolve exporting the model and trained weights.

test_dicoms = ['test1.png','test2.png','test3.png','test4.png','test5.png','test6.png']
for img in test_dicoms: 
        full_size_image = io.imread(img, as_gray=True)
        model.predict(np.asarray(full_size_image))

throws the following error:
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays: [array([[115, 164, 173, 170, 174, 167, 148, 125, 124, 126, 150, 191, 198,
206, 205, 209, 191, 180, 128, 109, 99, 67, 63, 58, 50, 41,
32, 41],
[150, 173, 191, 188, 191, 1...

Any help is appreciated. Thanks.

Note: test_dicoms has the correct path and images are already 28 * 28 (verified with image.shape).

@XifengGuo
Copy link
Owner

@GaganaB Did you use the model or eval_model?

CapsNet-Keras/capsulenet.py

Lines 242 to 244 in 2f6d47d

model, eval_model, manipulate_model = CapsNet(input_shape=x_train.shape[1:],
n_class=len(np.unique(np.argmax(y_train, 1))),
routings=args.routings)

If you use model, which is 2-in-2-out model, you should feed a tuple with 2 arrays, like outputs = model.predict(x, y).

train_model = models.Model([x, y], [out_caps, decoder(masked_by_y)])

If you use eval_model, which is a 1-in-2-out model, you should feed an array, like outputs = model.predict(x)

eval_model = models.Model(x, [out_caps, decoder(masked)])

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