diff --git a/bigml/dataset.py b/bigml/dataset.py index 6b45f5e4..5115f7de 100644 --- a/bigml/dataset.py +++ b/bigml/dataset.py @@ -25,7 +25,8 @@ from bigml.fields import Fields, sorted_headers, get_new_fields from bigml.api import get_api_connection, get_dataset_id, get_status from bigml.basemodel import get_resource_dict -from bigml.util import DEFAULT_LOCALE, use_cache, cast, load, dump, dumps +from bigml.util import DEFAULT_LOCALE, use_cache, cast, load, dump, dumps, \ + sensenet_logging from bigml.constants import FINISHED from bigml.flatline import Flatline from bigml.featurizer import Featurizer @@ -40,11 +41,7 @@ #pylint: disable=locally-disabled,bare-except,ungrouped-imports try: # bigml-sensenet should be installed for image processing - logging.disable(logging.WARNING) - os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' - import tensorflow as tf - tf.autograph.set_verbosity(0) - logging.getLogger("tensorflow").setLevel(logging.ERROR) + sensenet_logging() import sensenet from bigml.images.featurizers import ImageFeaturizer as Featurizer except: diff --git a/bigml/deepnet.py b/bigml/deepnet.py index 087f1653..18c5b404 100644 --- a/bigml/deepnet.py +++ b/bigml/deepnet.py @@ -49,7 +49,7 @@ from bigml.api import FINISHED from bigml.api import get_status, get_api_connection, get_deepnet_id from bigml.util import cast, use_cache, load, get_data_transformations, \ - PRECISION + PRECISION, sensenet_logging from bigml.basemodel import get_resource_dict, extract_objective from bigml.modelfields import ModelFields from bigml.laminar.constants import NUMERIC @@ -62,11 +62,7 @@ import bigml.laminar.preprocess_np as pp try: - logging.disable(logging.WARNING) - os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' - logging.getLogger("tensorflow").setLevel(logging.ERROR) - import tensorflow as tf - tf.autograph.set_verbosity(0) + sensenet_logging() from sensenet.models.wrappers import create_model from bigml.images.utils import to_relative_coordinates from bigml.constants import IOU_REMOTE_SETTINGS diff --git a/bigml/util.py b/bigml/util.py index 25ccadba..c1131a0f 100644 --- a/bigml/util.py +++ b/bigml/util.py @@ -748,6 +748,7 @@ def get_formatted_data(input_data_list, out_format=None): inner_data_list = input_data_list.copy() return inner_data_list + #pylint: disable=locally-disabled,import-outside-toplevel def get_data_transformations(resource_id, parent_id): """Returns the pipeline that contains the tranformations and derived @@ -760,3 +761,13 @@ def get_data_transformations(resource_id, parent_id): "pipeline.") from bigml.pipeline.pipeline import BMLPipeline return BMLPipeline("dt-%s" % resource_id, [parent_id]) + + +def sensenet_logging(): + """Removes warnings unnecessary logging when using sensenet""" + logging.disable(logging.WARNING) + os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' + os.environ["TF_USE_LEGACY_KERAS"] = "1" + import tensorflow as tf + tf.autograph.set_verbosity(0) + logging.getLogger("tensorflow").setLevel(logging.ERROR)