diff --git a/im2txt/im2txt/inference_utils/caption_generator.py b/im2txt/im2txt/inference_utils/caption_generator.py index a6ceecc73ab..4488e6f00d0 100644 --- a/im2txt/im2txt/inference_utils/caption_generator.py +++ b/im2txt/im2txt/inference_utils/caption_generator.py @@ -54,6 +54,16 @@ def __cmp__(self, other): return -1 else: return 1 + + # for version 3 compatibility (__cmp__ is deprecated) + def __lt__(self, other): + assert isinstance(other, Caption) + return self.score < other.score + + # also for version 3 compatibility + def __eq__(self, other): + assert isinstance(other, Caption) + return self.score == other.score class TopN(object):