Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(preprocessor): add numpy transform
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Oct 15, 2019
1 parent cfee124 commit 24e41be
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gnes/preprocessor/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,12 @@ def detect_peak_boundary(distances: List[float],


def torch_transform(img):
import torchvision.transforms as transforms
return transforms.Compose([transforms.ToTensor(),
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5))])(img)
try:
import torchvision.transforms as transforms
return transforms.Compose([transforms.ToTensor(),
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5))])(img)
except (ImportError, ModuleNotFoundError):
return np.asarray(img) * 2 / 255. - 1.


def get_all_subarea(img):
Expand Down

0 comments on commit 24e41be

Please sign in to comment.