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

ISS228: removing gdal from setup.py; fix model download check #230

Merged
merged 1 commit into from
Aug 11, 2019
Merged
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
161 changes: 0 additions & 161 deletions docs/tutorials/notebooks/api_inference_spacenet.ipynb

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def check_output(cmd):
'opencv-python==4.1.0.25',
'numpy>=1.16.4',
'tqdm>=4.32.2',
'GDAL>=2.4.0',
'rtree>=0.8.3',
'networkx>=2.3',
'rasterio>=1.0.18',
Expand Down
25 changes: 23 additions & 2 deletions solaris/nets/model_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,33 @@ def _load_model_weights(model, path, framework):
try:
model.load_weights(path)
except OSError:
raise FileNotFoundError("{} doesn't exist.".format(path))
# first, check to see if the weights are in the default sol dir
default_path = os.path.join(weights_dir, os.path.split(path)[1])
try:
model.load_weights(default_path)
except OSError:
# if they can't be found anywhere, raise the error.
raise FileNotFoundError("{} doesn't exist.".format(path))

elif framework.lower() in ['torch', 'pytorch']:
# pytorch already throws the right error on failed load, so no need
# to fix exception
loaded = torch.load(path)
if torch.cuda.is_available():
try:
loaded = torch.load(path)
except FileNotFoundError:
# first, check to see if the weights are in the default sol dir
default_path = os.path.join(weights_dir,
os.path.split(path)[1])
loaded = torch.load(path)
else:
try:
loaded = torch.load(path, map_location='cpu')
except FileNotFoundError:
default_path = os.path.join(weights_dir,
os.path.split(path)[1])
loaded = torch.load(path, map_location='cpu')

if isinstance(loaded, torch.nn.Module): # if it's a full model already
model.load_state_dict(loaded.state_dict())
else:
Expand Down