Code Monkey home page Code Monkey logo

spn.pytorch's People

Contributors

yeezhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spn.pytorch's Issues

inconsistent tensor size error

When I run bash runme.sh, I encounter the exception below.

Traceback (most recent call last):
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/mukai/SPN.pytorch/demo/experiment/demo_voc2007.py", line 63, in
main_voc2007()
File "/home/mukai/SPN.pytorch/demo/experiment/demo_voc2007.py", line 59, in main_voc2007
engine.multi_learning(model, criterion, train_dataset, val_dataset)
File "/home/mukai/SPN.pytorch/demo/experiment/engine.py", line 108, in multi_learning
state_dicts.append(self.learning(model, criterion, train_dataset, val_dataset, optimizer))
File "/home/mukai/SPN.pytorch/demo/experiment/engine.py", line 184, in learning
self.train(train_loader, model, criterion, optimizer, epoch)
File "/home/mukai/SPN.pytorch/demo/experiment/engine.py", line 211, in train
for i, (input, target) in enumerate(data_loader):
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/tqdm/_tqdm.py", line 862, in iter
for obj in iterable:
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 212, in next
return self._process_next_batch(batch)
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 239, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 41, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 41, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/mukai/SPN.pytorch/demo/experiment/voc.py", line 247, in getitem
img = self.transform(img)
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/torchvision/transforms.py", line 34, in call
img = t(img)
File "/home/mukai/SPN.pytorch/demo/experiment/engine.py", line 120, in
lambda x: x - torch.Tensor(model.image_normalization_mean).view(3, 1, 1),
File "/home/mukai/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/tensor.py", line 274, in sub
return self.sub(other)
RuntimeError: inconsistent tensor size at /opt/conda/conda-bld/pytorch_1501969512886/work/pytorch-0.1.12/torch/lib/TH/generic/THTensorMath.c:831

It may send a inconsistent tensor to the function enumerate(data_loader).
I don't know how to fix it.
Hope your help.

Transfer matrix definition

In the paper and the code you define D as: D(ij, pq) = ||u_ij - u_pq|| * exp(-((i - p)**2 + (j - q)**2)/(2 * sigma**2)) where u is the features tensor, and i,j,p,q are coordinates of two feature vectors.

The first term is dissimilarity (when it's large, features are very dissimilar), the second is similarity (when it's large, features are very close geometrically). Please correct me if I'm getting it wrongly.

During update of objectness vector:
M_i = \sum_j M_j * D_ji, i.e. M_i will have high objectness if locations j have high objectness and are dissimilar to i.

Does it make sense to mix dissimilarity and similarity?

Thanks!

no '_libspn'?

hey, i have finished maks.sh, and now trying to run the code, but in /spnlib/spn/_ext/libspn/init.py
there is a from ._libspn import lib as _lib, which occurs the error. I found there is no file or module callled '._libspn'?
I am so confused, and will really appreciate your help!
@yeezhu

Training on new dataset

Hi @yeezhu,

Are you able to provide a generic script that allows for training on a custom dataset other than PASCAL VOC, assuming that the images for each class are stored in their respective folders?

Thanks,
Sam

pretrained model

Hi,

Would you release pretrained models on pascal voc?

Thanks!

Make Error

I got this error for the install, could you provide any solution?

sdy@vig101799:~/SPN.pytorch/spnlib$ bash make.sh
Compiling cuda kernels...
rm: cannot remove 'libspn_kernel.cu.o': No such file or directory
make.sh: line 6: nvcc: command not found
Installing extension...
Including CUDA code.
running clean
removing 'build/temp.linux-x86_64-3.6' (and everything under it)
Including CUDA code.
running install
running bdist_egg
running egg_info
writing spn.egg-info/PKG-INFO
writing dependency_links to spn.egg-info/dependency_links.txt
writing requirements to spn.egg-info/requires.txt
writing top-level names to spn.egg-info/top_level.txt
reading manifest file 'spn.egg-info/SOURCES.txt'
writing manifest file 'spn.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying spn/_ext/libspn/init.py -> build/lib.linux-x86_64-3.6/spn/_ext/libspn
running build_ext
generating cffi module 'build/temp.linux-x86_64-3.6/spn._ext.libspn._libspn.c'
creating build/temp.linux-x86_64-3.6
building 'spn._ext.libspn._libspn' extension
creating build/temp.linux-x86_64-3.6/build
creating build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/home
creating build/temp.linux-x86_64-3.6/home/sdy
creating build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch
creating build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib
creating build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib/spn
creating build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib/spn/src
gcc -pthread -B /home/sdy/anaconda3/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/home/sdy/anaconda3/include/python3.6m -c build/temp.linux-x86_64-3.6/spn._ext.libspn._libspn.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/spn._ext.libspn._libspn.o -fopenmp
gcc -pthread -B /home/sdy/anaconda3/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/home/sdy/anaconda3/include/python3.6m -c /home/sdy/SPN.pytorch/spnlib/spn/src/libspn.c -o build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib/spn/src/libspn.o -fopenmp
gcc -pthread -B /home/sdy/anaconda3/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/home/sdy/anaconda3/include/python3.6m -c /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c -o build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.o -fopenmp
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:14:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Float_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:67:11: warning: unused variable ‘sumOver_debug’ [-Wunused-variable]
float sumOver_debug;
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:107:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
transferMatrix_data,
^
In file included from /home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:1:
/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, floa
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:109:17: warning: passing argument 8 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
proposal_data,
^
In file included from /home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:1:
/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, floa
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:112:17: warning: passing argument 11 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
proposalBuffer_data,
^
In file included from /home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:1:
/home/sdy/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, floa
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:67:11: warning: unused variable ‘sumOver_debug’ [-Wunused-variable]
float sumOver_debug;
^
gcc -pthread -shared -B /home/sdy/anaconda3/compiler_compat -L/home/sdy/anaconda3/lib -Wl,-rpath=/home/sdy/anaconda3/lib,--no-as-needed build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/spn._ext.libspn._libspn.o build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib/spn/src/libspn.o build/temp.linux-x86_64-3.6/home/sdy/SPN.pytorch/spnlib/spn/src/libspn_cuda.o spn/src/libspn_kernel.cu.o -L/home/sdy/anaconda3/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/spn/_ext/libspn/_libspn.abi3.so
gcc: error: spn/src/libspn_kernel.cu.o: No such file or directory
error: command 'gcc' failed with exit status 1

No module named 'spn.spnlib.spn._ext.libspn._libspn'

I compile the spnlib part and meet this problem when running code:
File "/home/zhangyu/codes/weakly_localization/spn/__init__.py", line 1, in <module> from .models import vgg16_sp File "/home/zhangyu/codes/weakly_localization/spn/models.py", line 5, in <module> from spn.spnlib.spn.modules import SoftProposal File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/modules/__init__.py", line 1, in <module> from .SoftProposal import SoftProposal File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/modules/SoftProposal.py", line 5, in <module> from ..functions import sp_generate File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/functions/__init__.py", line 1, in <module> from .SPG import SPGenerate File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/functions/SPG.py", line 5, in <module> from .._ext import libspn File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/_ext/libspn/__init__.py", line 3, in <module> from ._libspn import lib as _lib, ffi as _ffi ImportError: No module named 'spn.spnlib.spn._ext.libspn._libspn'

the problem come from this code spnlib/spn/_ext/libspn/init.py:

from torch.utils.ffi import _wrap_function
from ._libspn import lib as _lib, ffi as _ffi
all = []
def _import_symbols(locals):
for symbol in dir(_lib):
fn = getattr(_lib, symbol)
locals[symbol] = _wrap_function(fn, _ffi)
all.append(symbol)
_import_symbols(locals())

I checked, there are no file except a init.py in /spnlib/spn/_ext/libspn, so I think it may be something wrong while compliing.
Here is my compiling information:

zhangyu@GPUServer2:~/codes/weakly_localization/spn/spnlib$ sudo sh make.sh
Compiling cuda kernels...
Installing extension...
Including CUDA code.
running clean
Including CUDA code.
running install
running bdist_egg
running egg_info
writing requirements to spn.egg-info/requires.txt
writing spn.egg-info/PKG-INFO
writing top-level names to spn.egg-info/top_level.txt
writing dependency_links to spn.egg-info/dependency_links.txt
reading manifest file 'spn.egg-info/SOURCES.txt'
writing manifest file 'spn.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/spn
copying spn/init.py -> build/lib.linux-x86_64-2.7/spn
creating build/lib.linux-x86_64-2.7/spn/modules
copying spn/modules/init.py -> build/lib.linux-x86_64-2.7/spn/modules
copying spn/modules/SoftProposal.py -> build/lib.linux-x86_64-2.7/spn/modules
creating build/lib.linux-x86_64-2.7/spn/_ext
copying spn/_ext/init.py -> build/lib.linux-x86_64-2.7/spn/_ext
creating build/lib.linux-x86_64-2.7/spn/functions
copying spn/functions/init.py -> build/lib.linux-x86_64-2.7/spn/functions
copying spn/functions/SPG.py -> build/lib.linux-x86_64-2.7/spn/functions
copying spn/functions/utils.py -> build/lib.linux-x86_64-2.7/spn/functions
creating build/lib.linux-x86_64-2.7/spn/_ext/libspn
copying spn/_ext/libspn/init.py -> build/lib.linux-x86_64-2.7/spn/_ext/libspn
running build_ext
generating cffi module 'build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.c'
creating build/temp.linux-x86_64-2.7
building 'spn._ext.libspn._libspn' extension
creating build/temp.linux-x86_64-2.7/build
creating build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/home
creating build/temp.linux-x86_64-2.7/home/zhangyu
creating build/temp.linux-x86_64-2.7/home/zhangyu/codes
creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization
creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn
creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib
creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn
creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.o -fopenmp
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/usr/include/python2.7 -c /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn.c -o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn.o -fopenmp
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/usr/include/python2.7 -c /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c -o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.o -fopenmp
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:14:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Float_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:67:11: warning: unused variable ‘sumOver_debug’ [-Wunused-variable]
float sumOver_debug;
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:113:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [enabled by default]
1);
^
In file included from /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:1:
/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, float alpha, float *a, long lda, float *x, long incx, float beta, float *y, long incy);
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:113:17: warning: passing argument 8 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [enabled by default]
1);
^
In file included from /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:1:
/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, float alpha, float *a, long lda, float *x, long incx, float beta, float *y, long incy);
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:113:17: warning: passing argument 11 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [enabled by default]
1);
^
In file included from /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:1:
/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, float alpha, float *a, long lda, float *x, long incx, float beta, float *y, long incy);
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:67:11: warning: unused variable ‘sumOver_debug’ [-Wunused-variable]
float sumOver_debug;
^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn.o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.o spn/src/libspn_kernel.cu.o -o build/lib.linux-x86_64-2.7/spn/_ext/libspn/_libspn.so
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/spn
copying build/lib.linux-x86_64-2.7/spn/init.py -> build/bdist.linux-x86_64/egg/spn
creating build/bdist.linux-x86_64/egg/spn/modules
copying build/lib.linux-x86_64-2.7/spn/modules/init.py -> build/bdist.linux-x86_64/egg/spn/modules
copying build/lib.linux-x86_64-2.7/spn/modules/SoftProposal.py -> build/bdist.linux-x86_64/egg/spn/modules
creating build/bdist.linux-x86_64/egg/spn/_ext
copying build/lib.linux-x86_64-2.7/spn/_ext/init.py -> build/bdist.linux-x86_64/egg/spn/_ext
creating build/bdist.linux-x86_64/egg/spn/_ext/libspn
copying build/lib.linux-x86_64-2.7/spn/_ext/libspn/init.py -> build/bdist.linux-x86_64/egg/spn/_ext/libspn
copying build/lib.linux-x86_64-2.7/spn/_ext/libspn/_libspn.so -> build/bdist.linux-x86_64/egg/spn/_ext/libspn
creating build/bdist.linux-x86_64/egg/spn/functions
copying build/lib.linux-x86_64-2.7/spn/functions/init.py -> build/bdist.linux-x86_64/egg/spn/functions
copying build/lib.linux-x86_64-2.7/spn/functions/SPG.py -> build/bdist.linux-x86_64/egg/spn/functions
copying build/lib.linux-x86_64-2.7/spn/functions/utils.py -> build/bdist.linux-x86_64/egg/spn/functions
byte-compiling build/bdist.linux-x86_64/egg/spn/init.py to init.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/modules/init.py to init.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/modules/SoftProposal.py to SoftProposal.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/_ext/init.py to init.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/_ext/libspn/init.py to init.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/functions/init.py to init.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/functions/SPG.py to SPG.pyc
byte-compiling build/bdist.linux-x86_64/egg/spn/functions/utils.py to utils.pyc
creating stub loader for spn/_ext/libspn/_libspn.so
byte-compiling build/bdist.linux-x86_64/egg/spn/_ext/libspn/_libspn.py to _libspn.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying spn.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying spn.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying spn.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying spn.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying spn.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/spn-1.0-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing spn-1.0-py2.7-linux-x86_64.egg
Removing /usr/local/lib/python2.7/dist-packages/spn-1.0-py2.7-linux-x86_64.egg
Copying spn-1.0-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
spn 1.0 is already the active version in easy-install.pth
Installed /usr/local/lib/python2.7/dist-packages/spn-1.0-py2.7-linux-x86_64.egg
Processing dependencies for spn==1.0
Searching for cffi==1.11.2
Best match: cffi 1.11.2
Processing cffi-1.11.2-py2.7-linux-x86_64.egg
cffi 1.11.2 is already the active version in easy-install.pth
Using /home/zhangyu/codes/paperCode/SPN.pytorch-master/spnlib/.eggs/cffi-1.11.2-py2.7-linux-x86_64.egg
Searching for pycparser==2.18
Best match: pycparser 2.18
Processing pycparser-2.18-py2.7.egg
pycparser 2.18 is already the active version in easy-install.pth
Using /home/zhangyu/codes/paperCode/SPN.pytorch-master/spnlib/.eggs/pycparser-2.18-py2.7.egg
Finished processing dependencies for spn==1.0

How can I solve this and make the codes run?

Which python version?

I tried python3.5.4 & python3.6.2, but failed to install torchnet:

  Could not find a version that satisfies the requirement torchnet (from versions: )
No matching distribution found for torchnet

make error

I got these warnings during installation. I went through a closed issue that showed the same warnings. I upgraded pytorch to pytorch 0.3.0, but the warning still exist. It looks like it is from the incompatibility of some packages. Does anyone know a solution ?

I'm using CUDA8.0, and cuDNN 5.1
......
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/jun/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:106:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
transferMatrix_data,
^
In file included from /home/jun/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/jun/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:1:
/home/jun/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, floa
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/jun/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:108:17: warning: passing argument 8 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
proposal_data,
^
In file included from /home/jun/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/jun/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:1:
/home/jun/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, floa
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/jun/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:111:17: warning: passing argument 11 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
proposalBuffer_data,
^
In file included from /home/jun/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/jun/SPN.pytorch/spnlib/spn/src/libspn_cuda.c:1:
/home/jun/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, long m, long n, floa
^
......

The mAP for classification on voc2007 is low after training

As I run the runme.sh, only 20 epochs are specified on VOC2007, but after 20 epoch, the mAP for classification is only 20%, far away from 80% reported in paper. And now I have iterate over 300 epoch, the mAP on trainval is only 53%, the mAP on test is 42%. So how many epochs should I train here?

bash make.sh wrong

(py3.5) ltc@ltcpc:~/PycharmProjects/SPN.pytorch-master/spnlib$ python setup.py
Including CUDA code.
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied
(py3.5) ltc@ltcpc:~/PycharmProjects/SPN.pytorch-master/spnlib$ python setup.py --help
Including CUDA code.
Common commands: (see '--help-commands' for more)

setup.py build will build the package underneath 'build/'
setup.py install will install the package

Global options:
--verbose (-v) run verbosely (default)
--quiet (-q) run quietly (turns verbosity off)
--dry-run (-n) don't actually do anything
--help (-h) show detailed help message
--no-user-cfg ignore pydistutils.cfg in your home directory
--command-packages list of packages that provide distutils commands

Information display options (just display information, ignore any commands)
--help-commands list all available commands
--name print package name
--version (-V) print package version
--fullname print -
--author print the author's name
--author-email print the author's email address
--maintainer print the maintainer's name
--maintainer-email print the maintainer's email address
--contact print the maintainer's name if known, else the author's
--contact-email print the maintainer's email address if known, else the
author's
--url print the URL for this package
--license print the license of the package
--licence alias for --license
--description print the package description
--long-description print the long package description
--platforms print the list of platforms
--classifiers print the list of classifiers
--keywords print the list of keywords
--provides print the list of packages/modules provided
--requires print the list of packages/modules required
--obsoletes print the list of packages/modules made obsolete

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

(py3.5) ltc@ltcpc:/PycharmProjects/SPN.pytorch-master/spnlib$ python setup.py clean
Including CUDA code.
running clean
removing 'build/temp.linux-x86_64-3.5' (and everything under it)
(py3.5) ltc@ltcpc:
/PycharmProjects/SPN.pytorch-master/spnlib$ python setup.py install
Including CUDA code.
running install
running bdist_egg
running egg_info
writing spn.egg-info/PKG-INFO
writing dependency_links to spn.egg-info/dependency_links.txt
writing top-level names to spn.egg-info/top_level.txt
writing requirements to spn.egg-info/requires.txt
reading manifest file 'spn.egg-info/SOURCES.txt'
writing manifest file 'spn.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying spn/_ext/libspn/init.py -> build/lib.linux-x86_64-3.5/spn/_ext/libspn
running build_ext
generating cffi module 'build/temp.linux-x86_64-3.5/spn._ext.libspn._libspn.c'
creating build/temp.linux-x86_64-3.5
building 'spn._ext.libspn._libspn' extension
creating build/temp.linux-x86_64-3.5/build
creating build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/home
creating build/temp.linux-x86_64-3.5/home/ltc
creating build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects
creating build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects/SPN.pytorch-master
creating build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects/SPN.pytorch-master/spnlib
creating build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn
creating build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src
gcc -pthread -B /home/ltc/anaconda3/envs/py3.5/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/home/ltc/anaconda3/envs/py3.5/include/python3.5m -c build/temp.linux-x86_64-3.5/spn._ext.libspn._libspn.c -o build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5/spn._ext.libspn._libspn.o -std=c99 -fopenmp
gcc -pthread -B /home/ltc/anaconda3/envs/py3.5/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/home/ltc/anaconda3/envs/py3.5/include/python3.5m -c /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn.c -o build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn.o -std=c99 -fopenmp
gcc -pthread -B /home/ltc/anaconda3/envs/py3.5/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/home/ltc/anaconda3/envs/py3.5/include/python3.5m -c /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c -o build/temp.linux-x86_64-3.5/home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.o -std=c99 -fopenmp
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:14:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Float_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:39:23: error: dereferencing pointer to incomplete type ‘THTensor {aka struct THTensor}’
uint8 ndim = input->nDimension;
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’:
spn/src/generic/SoftProposalGenerator.cu:106:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
transferMatrix_data,
^
In file included from /home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:1:
/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, int64_t m, int64_t n, float alpha, float *a, int64_t lda, float *x, int64_t incx, float beta,
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:108:17: warning: passing argument 8 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
proposal_data,
^
In file included from /home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:1:
/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, int64_t m, int64_t n, float alpha, float *a, int64_t lda, float *x, int64_t incx, float beta,
^
In file included from generic/SoftProposalGenerator.cu:1:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:17:
spn/src/generic/SoftProposalGenerator.cu:111:17: warning: passing argument 11 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [-Wincompatible-pointer-types]
proposalBuffer_data,
^
In file included from /home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0,
from /home/ltc/PycharmProjects/SPN.pytorch-master/spnlib/spn/src/libspn_cuda.c:1:
/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float *’ but argument is of type ‘double *’
THC_API void THCudaBlas_Sgemv(THCState *state, char trans, int64_t m, int64_t n, float alpha, float *a, int64_t lda, float *x, int64_t incx, float beta,
^
error: command 'gcc' failed with exit status 1

Python2 back compat

On my machine python3 segfaults due some nasty import issues, but python2 still works.

Here are a couple minor fixes to make the code run on python2 if one wishes so:

# in demo/experiment/util.py
import sys
if sys.version_info.major > 2:
    from urllib.request import urlretrieve
else:
    from urllib import urlretrieve

# in demo/experiment/voc.py
import sys
if sys.version_info.major > 2:
    from urllib.parse import urlparse
else:
    from urlparse import urlparse

Need more detail on experiments

Hi, @yeezhu. I have some questions on experiments in the paper:

  1. In section 4.2, Two different methods ("pointing without prediction" and "pointing with prediction") are used to to evaluate pointing localization. They use the same criterion to pick up positive results (the maximum response falls in gt box), as mentioned in [1] and [2]. However, I can't find the difference between "without prediction" and "with prediction". Could you give me some clue about the difference?

  2. You use the method in [2] to evaluate pointing localization, but I can't find the code to compute the metric. The released code of the original paper [2] also doesn't contain the metric calculation. I have examined all related papers but they don't have released codes to compute the metric. Could you give me your implementation, such as pseudo code or python code. I want to re-implement the results in Table 3.

Thanks.

References:
[1] J. Zhang, Z. L. Lin, J. Brandt, X. Shen, and S. Sclaroff. Top-down neural attention by excitation backprop. In ECCV, pages 543–559, 2016.
[2] M. Oquab, L. Bottou, I. Laptev, and J. Sivic. Is object localization for free? - weakly-supervised learning with convolutional neural networks. In CVPR, pages 685–694, 2015.

SP_GoogleNet_ImageNet.pt model error?

model_path = os.path.join(DATA_ROOT, 'SP_GoogleNet_ImageNet.pt')
model_dict = utils.load_model_imagenet(model_path)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-3ddac1dff075> in <module>()
      1 model_path = os.path.join(DATA_ROOT, 'SP_GoogleNet_ImageNet.pt')
----> 2 model_dict = utils.load_model_imagenet(model_path)

~/choas/method/SPN.pytorch/demo/experiment/util.py in load_model_imagenet(filename, scale)
    223 
    224 def load_model_imagenet(filename, scale=224):
--> 225     model = SP_GoogLeNet(state_dict=filename).cuda()
    226     model.inference()
    227     return {scale: model}

~/choas/method/SPN.pytorch/demo/evaluation/SP_GoogLeNet.py in __init__(self, state_dict)
     34         super(SP_GoogLeNet, self).__init__()
     35 
---> 36         state_dict = load_lua(state_dict)
     37         pretrained_model = state_dict[0]
     38         pretrained_model.evaluate()

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in load_lua(filename, **kwargs)
    597     with open(filename, 'rb') as f:
    598         reader = T7Reader(f, **kwargs)
--> 599         return reader.read()

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read(self)
    584             return self.read_object()
    585         elif typeidx == TYPE_TABLE:
--> 586             return self.read_table()
    587         else:
    588             raise T7ReaderException("unknown type id {}. The file may be "

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in wrapper(self, *args, **kwargs)
    512             if index in self.memo:
    513                 return self.memo[index]
--> 514             result = fn(self, *args, **kwargs)
    515             self.memo[index] = result
    516             return result

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read_table(self)
    561         for i in range(size):
    562             k = self.read()
--> 563             v = self.read()
    564             table[k] = v
    565         if self.list_heuristic and self._can_be_list(table):

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read(self)
    584             return self.read_object()
    585         elif typeidx == TYPE_TABLE:
--> 586             return self.read_table()
    587         else:
    588             raise T7ReaderException("unknown type id {}. The file may be "

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in wrapper(self, *args, **kwargs)
    512             if index in self.memo:
    513                 return self.memo[index]
--> 514             result = fn(self, *args, **kwargs)
    515             self.memo[index] = result
    516             return result

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read_table(self)
    561         for i in range(size):
    562             k = self.read()
--> 563             v = self.read()
    564             table[k] = v
    565         if self.list_heuristic and self._can_be_list(table):

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read(self)
    582             return self.read_function()
    583         elif typeidx == TYPE_TORCH:
--> 584             return self.read_object()
    585         elif typeidx == TYPE_TABLE:
    586             return self.read_table()

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in wrapper(self, *args, **kwargs)
    512             if index in self.memo:
    513                 return self.memo[index]
--> 514             result = fn(self, *args, **kwargs)
    515             self.memo[index] = result
    516             return result

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read_object(self)
    535 
    536         if cls_name in reader_registry:
--> 537             return reader_registry[cls_name](self, version)
    538         if self.unknown_classes:
    539             return TorchObject(cls_name, self.read())

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read_tensor(reader, version)
    144         storage_offset = reader.read_long() - 1
    145         # read storage:
--> 146         storage = reader.read()
    147 
    148         if storage is None or ndim == 0 or len(size) == 0 or len(stride) == 0:

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read(self)
    582             return self.read_function()
    583         elif typeidx == TYPE_TORCH:
--> 584             return self.read_object()
    585         elif typeidx == TYPE_TABLE:
    586             return self.read_table()

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in wrapper(self, *args, **kwargs)
    512             if index in self.memo:
    513                 return self.memo[index]
--> 514             result = fn(self, *args, **kwargs)
    515             self.memo[index] = result
    516             return result

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read_object(self)
    535 
    536         if cls_name in reader_registry:
--> 537             return reader_registry[cls_name](self, version)
    538         if self.unknown_classes:
    539             return TorchObject(cls_name, self.read())

~/anaconda/envs/py3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py in read_storage(reader, version)
    163         # https://github.com/torch/torch7/blob/master/generic/Storage.c#L244
    164         size = reader.read_long() * element_size
--> 165         return python_class.from_buffer(reader.f.read(size), 'native')
    166     return read_storage
    167 

ValueError: buffer size (3557762) must be a multiple of element size (4)

I download the model SP_GoogleNet_ImageNet.pt, then run the demo, but meet this error.

bash make.sh wrong

(py3.5) ltc@ltcpc:~/PycharmProjects/SPN.pytorch/spnlib$ bash make.sh
Compiling cuda kernels...
Installing extension...
Including CUDA code.
Traceback (most recent call last):
File "setup.py", line 21, in
os.path.join(os.path.dirname(file), "build.py:ffi")
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/setuptools/init.py", line 140, in setup
return distutils.core.setup(**attrs)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/setuptools/dist.py", line 370, in init
k: v for k, v in attrs.items()
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/distutils/dist.py", line 281, in init
self.finalize_options()
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/setuptools/dist.py", line 529, in finalize_options
ep.load()(self, ep.name, value)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/cffi/setuptools_ext.py", line 204, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "build.py", line 33, in
extra_compile_args=['-fopenmp'],
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 228, in init
super(BuildExtension, self).init(*args, **kwargs)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/site-packages/setuptools/init.py", line 158, in init
_Command.init(self, dist)
File "/home/ltc/anaconda3/envs/py3.5/lib/python3.5/distutils/cmd.py", line 57, in init
raise TypeError("dist must be a Distribution instance")
TypeError: dist must be a Distribution instance

Cuda kernel issues and some build file fixes

I'd like to share some issues (with fixes) that I discovered while trying to use your package:

  1. A bug in spnlib/spn/src/generic/SoftProposalGenerator.cu, SP_InitDistanceMetric(...):
    const uint16 count = N * N;

    should be

    const uint32 count = (uint32)N * (uint32)N;

    Otherwise there's an integer overflow for tensors that have H*W > 1024 (this is pretty restrictive, even 32x32 overflows)

  2. (these of course aren't affecting the normal float code path, but still potentially a bug) Double implementations are currently useless, since the GEMV function consumes only float pointers:

.../SPN.pytorch/spnlib/spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’:
.../SPN.pytorch/spnlib/spn/src/generic/SoftProposalGenerator.cu:107:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer
type [-Wincompatible-pointer-types]
                 transferMatrix_data,
                 ^
  1. (I am building by directly calling python build.py in make.sh instead of python setup.py install). Without these build.py fixes I had various compiler / build_extension "File not found" errors:
...
extra_objects += [os.path.abspath('spn/src/libspn_kernel.cu.o')]
...
#    package=True,
...
include_dirs=[os.path.abspath('spn/src')],
...

Cuda code unnecessary?

Hi, Nice Work. But I think there is actually no need for CUDA code -- they could be implemented vectorized, which is more intuitive. For example:

__global__ void InitDistanceMetricKernel could be implemented as

import torch as t
I = t.range(0, H).view(-1,1,1,1)
J = t.range(0,W).view(1,-1,1,1)
P = t.range(0,H).view(1,1,-1,1)
Q = t.range(0,W).view(1,1,1,-1)

distanceMetric_data = t.exp(   ((I-P)**2 + (J-Q)**2))  / (-2*e) ).view(H*w,-1)

Maybe incorrect, but you know what I mean.

What is the license?

I would like to see a license file uploaded on this repository.
Thanks in advance.

Error in installation

I tried to install by using conda (from the environment.yml file).
On running conda env create -f environment.yml, I get the error:

Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - blas==1.1=openblas
  - numpy==1.13.1=py35_0 -> blas=[build=mkl]
Use "conda info <package>" to see the dependencies for each package.

Any help in solving this issue would be appreciated, thanks!

Questions about the VOC2007 CorLoc results

  1. Do I understand correctly that the model is trained on VOC2012 and COCO2014? (as precised in the Pointing with Prediction, "We upgrade a pre-trained VGG16 model to SPN and respectively fine-tune it on VOC2012 and COCO2014 dataset for 20 epochs. Results are reported in Tab. 3.")

    Or is Table 4 produced with a model trained only on VOC2007?

  2. You aren't using VGG16's pretrained fully-connected layers, right?

  3. Are you applying any bounding box coordinate adjustments due to convolution padding in VGG?

Thanks!

Visualization?

demo is just training? How to visualize weakly supervised localization? Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.