diff --git a/ppdet/data/source/voc.py b/ppdet/data/source/voc.py index 562366ae87279c05513dc9739c7c63e6e9c84a9a..56b746c14cc23a60e148a4c84149a3553b48c927 100644 --- a/ppdet/data/source/voc.py +++ b/ppdet/data/source/voc.py @@ -117,7 +117,12 @@ class VOCDataSet(DetDataset): difficult = [] for i, obj in enumerate(objs): cname = obj.find('name').text - _difficult = int(obj.find('difficult').text) + + # user dataset may not contain difficult field + _difficult = obj.find('difficult') + _difficult = int( + _difficult.text) if _difficult is not None else 0 + x1 = float(obj.find('bndbox').find('xmin').text) y1 = float(obj.find('bndbox').find('ymin').text) x2 = float(obj.find('bndbox').find('xmax').text) diff --git a/ppdet/engine/callbacks.py b/ppdet/engine/callbacks.py index 410de77447f990a84a42e4a4660056017ba5d4be..9d418119fe8706f3710f2f0c3bc55bef0e446189 100644 --- a/ppdet/engine/callbacks.py +++ b/ppdet/engine/callbacks.py @@ -179,6 +179,11 @@ class Checkpointer(Callback): for metric in self.model._metrics: map_res = metric.get_results() key = 'bbox' if 'bbox' in map_res else 'mask' + if key not in map_res: + logger.warn("Evaluation results empty, this may be due to " \ + "training iterations being too few or not " \ + "loading the correct weights.") + return if map_res[key][0] > self.best_ap: self.best_ap = map_res[key][0] save_name = 'best_model'