google-research / mixmatch

Apache License 2.0
1.13k stars 163 forks source link

How to verify my trained model with a picture? #2

Closed angryhen closed 5 years ago

david-berthelot commented 5 years ago

There's no code for processing a single picture. That being said it should be easy to write code for your needs by looking, for example, at how the eval_ckpt flag is implemented: https://github.com/google-research/mixmatch/blob/master/libml/train.py#L37

Here's some mock-up code, I didn't test it, it just to give you an idea where to start:

mm = MixMatch(<...list of parameters used when training...>)
mm.eval_mode(<checkpoint_filename or None for the latest one>)
logits = mm.session.run(mm.ops.classify_op, feed_dict={mm.ops.x: images})
# Where images is of dimensions (batch, height, width, colors)
# The predicted classes would be np.argmax(logits)
# To compute distribution would require you to compute the softmax of the logits.

Hope this helps.

angryhen commented 5 years ago

Thank you very much, I have run it successfully according to your prompts.