From 77385c1e26ed5e5c13b32c9582de3e9302a45e6e Mon Sep 17 00:00:00 2001 From: junyanz Date: Sun, 14 Jan 2018 17:13:18 -0800 Subject: update README --- util/util.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'util/util.py') diff --git a/util/util.py b/util/util.py index 4de0a74..26b259a 100644 --- a/util/util.py +++ b/util/util.py @@ -2,11 +2,13 @@ from __future__ import print_function import torch import numpy as np from PIL import Image -import inspect, re +import inspect +import re import numpy as np import os import collections + # Converts a Tensor into a Numpy array # |imtype|: the desired type of the converted numpy array def tensor2im(image_tensor, imtype=np.uint8): @@ -34,21 +36,6 @@ def save_image(image_numpy, image_path): image_pil = Image.fromarray(image_numpy) image_pil.save(image_path) -def info(object, spacing=10, collapse=1): - """Print methods and doc strings. - Takes module, class, list, dictionary, or string.""" - methodList = [e for e in dir(object) if isinstance(getattr(object, e), collections.Callable)] - processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s) - print( "\n".join(["%s %s" % - (method.ljust(spacing), - processFunc(str(getattr(object, method).__doc__))) - for method in methodList]) ) - -def varname(p): - for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]: - m = re.search(r'\bvarname\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*\)', line) - if m: - return m.group(1) def print_numpy(x, val=True, shp=False): x = x.astype(np.float64) -- cgit v1.2.3-70-g09d2