From c4b2aea30645d61bec01b593f477b2752028964b Mon Sep 17 00:00:00 2001 From: Dmytro S Lituiev Date: Tue, 16 Jul 2019 16:02:57 -0700 Subject: [PATCH] dependencies simplified --- image_classifiers/image.py | 24 ++++++++++++++---------- requirements.txt | 3 +-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/image_classifiers/image.py b/image_classifiers/image.py index fe44687..7831282 100644 --- a/image_classifiers/image.py +++ b/image_classifiers/image.py @@ -13,7 +13,7 @@ import scipy.ndimage as ndi from six.moves import range import os import threading -import warnings +from warnings import warn import multiprocessing.pool from functools import partial from collections import Counter @@ -59,7 +59,11 @@ _OPENCV_INTERPOLATION_METHODS = { import json from croppad import crop_pad_center -from pycocotools.mask import encode, decode + +try: + from pycocotools.mask import encode, decode +except: + warn('no pycocotools found') def random_rotation(x, rg, row_axis=1, col_axis=2, channel_axis=0, @@ -426,7 +430,7 @@ def load_img_opencv(path, grayscale=False, color_mode='rgb', target_size=None, ValueError: if interpolation method is not supported. """ if grayscale is True: - warnings.warn('grayscale is deprecated. Please use ' + warn('grayscale is deprecated. Please use ' 'color_mode = "grayscale"') color_mode = 'grayscale' @@ -497,7 +501,7 @@ def load_img_pil(path, grayscale=False, color_mode='rgb', target_size=None, ValueError: if interpolation method is not supported. """ if grayscale is True: - warnings.warn('grayscale is deprecated. Please use ' + warn('grayscale is deprecated. Please use ' 'color_mode = "grayscale"') color_mode = 'grayscale' if pil_image is None: @@ -892,7 +896,7 @@ class ImageDataGenerator(object): if self.mean is not None: x -= self.mean else: - warnings.warn('This ImageDataGenerator specifies ' + warn('This ImageDataGenerator specifies ' '`featurewise_center`, but it hasn\'t' 'been fit on any training data. Fit it ' 'first by calling `.fit(numpy_data)`.') @@ -900,7 +904,7 @@ class ImageDataGenerator(object): if self.std is not None: x /= (self.std + 1e-7) else: - warnings.warn('This ImageDataGenerator specifies ' + warn('This ImageDataGenerator specifies ' '`featurewise_std_normalization`, but it hasn\'t' 'been fit on any training data. Fit it ' 'first by calling `.fit(numpy_data)`.') @@ -910,7 +914,7 @@ class ImageDataGenerator(object): whitex = np.dot(flatx, self.principal_components) x = np.reshape(whitex, x.shape) else: - warnings.warn('This ImageDataGenerator specifies ' + warn('This ImageDataGenerator specifies ' '`zca_whitening`, but it hasn\'t' 'been fit on any training data. Fit it ' 'first by calling `.fit(numpy_data)`.') @@ -1096,7 +1100,7 @@ class ImageDataGenerator(object): raise ValueError('Input to `.fit()` should have rank 4. ' 'Got array with shape: ' + str(x.shape)) if x.shape[self.channel_axis] not in {1, 3, 4}: - warnings.warn( + warn( 'Expected input to be images (as Numpy array) ' 'following the data format convention "' + self.data_format + '" ' '(channels on axis ' + str(self.channel_axis) + '), i.e. expected ' @@ -1319,12 +1323,12 @@ class NumpyArrayIterator(Iterator): self.x = np.asarray(x, dtype=K.floatx()) if self.x.ndim != 4: - warnings.warn('Input data in `NumpyArrayIterator` ' + warn('Input data in `NumpyArrayIterator` ' 'should have rank 4. You passed an array ' 'with shape\t%s' % str(self.x.shape)) else: if self.x.shape[channels_axis] not in {1, 3, 4}: - warnings.warn('NumpyArrayIterator is set to use the ' + warn('NumpyArrayIterator is set to use the ' 'data format convention "' + data_format + '" ' '(channels on axis ' + str(channels_axis) + '), i.e. expected ' 'either 1, 3 or 4 channels on axis ' + str(channels_axis) + '. ' diff --git a/requirements.txt b/requirements.txt index 5ecf525..8eb0e5f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,9 +11,7 @@ opencv-python==3.3.0.10 pandas==0.20.2 Pillow==4.1.1 pyaml==17.7.2 --e git+https://github.com/cocodataset/cocoapi/@727b546dd9fa4e4bb113213c98a3925829fac0bf#egg=pycocotools&subdirectory=PythonAPI pydicom==0.9.9 -PyYAML==3.12 scikit-image==0.13.0 scikit-learn==0.18.1 scipy==0.19.1 @@ -21,3 +19,4 @@ seaborn==0.7.1 sklearn==0.0 tensorflow-gpu==1.4.1 tensorflow-tensorboard==0.4.0rc3 +# -e git+https://github.com/cocodataset/cocoapi/@727b546dd9fa4e4bb113213c98a3925829fac0bf#egg=pycocotools&subdirectory=PythonAPI