-
Notifications
You must be signed in to change notification settings - Fork 6
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
Size mismatch in final layer #1
Comments
I've just tested the docker with: (base) kidzik@kidzik-XPS-8900:~/workspace/kneenet-docker$ bash run.sh and it seems to be working fine /opt/conda/lib/python3.6/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
/opt/conda/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/models/densenet.py:212: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
Processing file input/example.jpg...
tensor([ 0.4120, -0.3240, -0.0705, -0.6524, -1.2485])
Processing finished.
-- RESULTS (in output/prediction.csv) --
filename prediction
input/example.jpg 0 The only problem was that after downloading the model it was stored in the main directory rather than in
|
I'm also facing the same issue ,would you please expalin it clearly . how to run on Docker |
Hi, you just need to install docker and run |
I'm using docker desktop, I have followed the same procedure but no use . Is I need the to build the Docker? |
No there is no need for building the docker you just need to run the |
if [ ! -f models/KneeNet.0 ]; then is this script is ok for windows? Really thanks alot @kidzik for the support |
That's linux. For Windows you probably need to change paths, replace ${PWD} with the directory where you cloned the github repo, download the model https://s3-eu-west-1.amazonaws.com/kidzinski/models/KneeNet/KneeNet.0 manually to models/KneeNet.0 and that's essentially it |
Hi @kidzik, Do you have any idea to deploy this model on a url |
Sure, you can try it here http://kl.stanford.edu/ |
@kidzik Really thanks alot. where Can I find source code for http://kl.stanford.edu/ |
It uses the same DenseNet as in this docker and it's converted to tensorflow-js. We are not releasing the code of the website at the moment. |
Size mismatch when running inference:
Traceback (most recent call last): File "scripts/predict.py", line 106, in <module> probs = pretrained_model(sample_input)[0] File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in __call__ result = self.forward(*input, **kwargs) File "/opt/conda/lib/python3.7/site-packages/torchvision/models/densenet.py", line 198, in forward out = self.classifier(out) File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in __call__ result = self.forward(*input, **kwargs) File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 87, in forward return F.linear(input, self.weight, self.bias) File "/opt/conda/lib/python3.7/site-packages/torch/nn/functional.py", line 1370, in linear ret = torch.addmm(bias, input, weight.t()) RuntimeError: size mismatch, m1: [1 x 1664], m2: [14976 x 5] at /opt/conda/conda-bld/pytorch_1579022060824/work/aten/src/TH/generic/THTensorMath.cpp:136
I ran into your
predict.py
script and saw you load torchvision densenet169, and replace the final linear layer to match the number of desired output (5). However, you also change the input features to 14976 instead of 1664. With an input image of size 299x299, the input features for that final layer has shape 1x1664. Where does this 14976 come from ?I tried changing this back to 1664 but now your pretrained weights don't match.
Thanks for your help.
The text was updated successfully, but these errors were encountered: