diff --git a/python/paddle/utils/plot.py b/python/paddle/utils/plot.py index 08889c0313fc24151cde6ca7b662d81eb53c9d7b..ee651f2f0cd6f2e594a4e74c896baa924f70bbf5 100644 --- a/python/paddle/utils/plot.py +++ b/python/paddle/utils/plot.py @@ -13,6 +13,7 @@ # limitations under the License. import os +import six class PlotData(object): @@ -60,9 +61,9 @@ class Ploter(object): def append(self, title, step, value): """ - Feed data - - Args: + Feed data + + Args: title: assign the group data to this subtitle. step: the x_axis of data. value: the y_axis of data. @@ -71,9 +72,9 @@ class Ploter(object): .. code-block:: python plot_curve = Ploter("Curve 1","Curve 2") plot_curve.append(title="Curve 1",step=1,value=1) - """ - assert isinstance(title, basestring) - assert self.__plot_data__.has_key(title) + """ + assert isinstance(title, six.string_types) + assert title in self.__plot_data__ data = self.__plot_data__[title] assert isinstance(data, PlotData) data.append(step, value) @@ -89,7 +90,7 @@ class Ploter(object): .. code-block:: python plot_curve = Ploter() plot_cure.plot() - """ + """ if self.__plot_is_disabled__(): return diff --git a/python/paddle/utils/preprocess_img.py b/python/paddle/utils/preprocess_img.py index a322f7b769a2a32df516a4b8ea04289a7f882ff2..fc67949dfe0ef21487de29678781aa2bfd93f354 100644 --- a/python/paddle/utils/preprocess_img.py +++ b/python/paddle/utils/preprocess_img.py @@ -122,7 +122,7 @@ class ImageClassificationDatasetCreater(preprocess_util.DatasetCreater): def create_dataset_from_list(self, path): data = [] label_set = [] - for line in open(file_list): + for line in open(path): items = line.rstrip.split() image_path = items[0] label_name = items[1] @@ -141,7 +141,7 @@ class ImageClassificationDatasetCreater(preprocess_util.DatasetCreater): path: the path of the image dataset. """ if self.from_list: - return create_dataset_from_list(path) + return self.create_dataset_from_list(path) label_set = preprocess_util.get_label_set_from_dir(path) data = [] for l_name in list(label_set.keys()):