Explorar el Código

Merge pull request #842 from tae-jun/patch-1

im2txt: make python3 compatible adding lt and eq
Chris Shallue hace 8 años
padre
commit
2cd62f6c6d
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      im2txt/im2txt/inference_utils/caption_generator.py

+ 10 - 0
im2txt/im2txt/inference_utils/caption_generator.py

@@ -54,6 +54,16 @@ class Caption(object):
       return -1
     else:
       return 1
+  
+  # For Python 3 compatibility (__cmp__ is deprecated).
+  def __lt__(self, other):
+    assert isinstance(other, Caption)
+    return self.score < other.score
+  
+  # Also for Python 3 compatibility.
+  def __eq__(self, other):
+    assert isinstance(other, Caption)
+    return self.score == other.score
 
 
 class TopN(object):