-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from ellisdg/dgx
Various updates and improvements
- Loading branch information
Showing
10 changed files
with
346 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .predict import * | ||
from .volumetric import volumetric_predictions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import numpy as np | ||
|
||
|
||
def pytorch_predict_batch_array(model, batch, n_gpus=1): | ||
import torch | ||
batch_x = torch.tensor(np.moveaxis(np.asarray(batch), -1, 1)).float() | ||
pred_x = pytorch_predict_batch(batch_x, model, n_gpus) | ||
return np.moveaxis(pred_x.numpy(), 1, -1) | ||
|
||
|
||
def get_feature_filename_and_subject_id(dataset, idx, verbose=False): | ||
epoch_filenames = dataset.epoch_filenames[idx] | ||
x_filename = epoch_filenames[dataset.feature_index] | ||
if verbose: | ||
print("Reading:", x_filename) | ||
subject_id = epoch_filenames[-1] | ||
return x_filename, subject_id | ||
|
||
|
||
def pytorch_predict_batch(batch_x, model, n_gpus): | ||
if n_gpus > 0: | ||
batch_x = batch_x.cuda() | ||
if hasattr(model, "test"): | ||
pred_x = model.test(batch_x) | ||
else: | ||
pred_x = model(batch_x) | ||
return pred_x.cpu() |
Oops, something went wrong.