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

Commit

Permalink
Merge pull request #330 from gnes-ai/torch_transform
Browse files Browse the repository at this point in the history
fix(preprocessor): add numpy transform
  • Loading branch information
mergify[bot] authored Oct 15, 2019
2 parents cfee124 + 24e41be commit 5676ab8
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 5676ab8

Please sign in to comment.