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

minor fixes #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ You can create an anaconda environment called `conv_onet` using
conda env create -f environment.yaml
conda activate conv_onet
```
**Note**: you might need to install **torch-scatter** mannually following [the official instruction](https://github.com/rusty1s/pytorch_scatter#pytorch-140):
**Note**: you might need to (re-)install **torch-scatter** mannually following [the official instruction](https://github.com/rusty1s/pytorch_scatter#pytorch-140):
```
pip install torch-scatter==2.0.4 -f https://pytorch-geometric.com/whl/torch-1.4.0+cu101.html
pip install torch-scatter==2.0.4 --force-reinstall -f https://pytorch-geometric.com/whl/torch-1.4.0+cu101.html
```

Next, compile the extension modules.
Expand Down
2 changes: 1 addition & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# Model
model = config.get_model(cfg, device=device, dataset=dataset)

checkpoint_io = CheckpointIO(out_dir, model=model)
checkpoint_io = CheckpointIO(out_dir, model=model, is_cuda=is_cuda)
checkpoint_io.load(cfg['test']['model_file'])

# Generator
Expand Down
8 changes: 6 additions & 2 deletions src/checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class CheckpointIO(object):
Args:
checkpoint_dir (str): path where checkpoints are saved
'''
def __init__(self, checkpoint_dir='./chkpts', **kwargs):
def __init__(self, checkpoint_dir='./chkpts', is_cuda=True, **kwargs):
self.module_dict = kwargs
self.is_cuda = is_cuda
self.checkpoint_dir = checkpoint_dir
if not os.path.exists(checkpoint_dir):
os.makedirs(checkpoint_dir)
Expand Down Expand Up @@ -75,7 +76,10 @@ def load_url(self, url):
'''
print(url)
print('=> Loading checkpoint from url...')
state_dict = model_zoo.load_url(url, progress=True)
if self.is_cuda:
state_dict = model_zoo.load_url(url, progress=True)
else:
state_dict = model_zoo.load_url(url, progress=True, map_location=torch.device('cpu'))
scalars = self.parse_state_dict(state_dict)
return scalars

Expand Down