From b0e26f87787deacc8e48a1c0edd0ef2a23f55e8a Mon Sep 17 00:00:00 2001
From: Mathieu Beligon <mathieu@feedly.com>
Date: Mon, 9 Mar 2020 20:11:28 -0400
Subject: [PATCH] [common] (tf records) fix: add filename in the record as it
 is used by tf for evaluation

---
 common/research_common/dataset/tensorflow_record.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/research_common/dataset/tensorflow_record.py b/common/research_common/dataset/tensorflow_record.py
index 0267a12..76ed247 100644
--- a/common/research_common/dataset/tensorflow_record.py
+++ b/common/research_common/dataset/tensorflow_record.py
@@ -32,6 +32,7 @@ class TensorflowRecordFactory:
         self.from_datasets([dataset], name=dataset.dataset_name)
 
     def example_from_image_annotation(self, image_annotation: ImageAnnotation) -> tf.train.Example:
+        image_name = image_annotation.image_path.name
         encoded_jpg = image_annotation.image_path.read_bytes()
         key = hashlib.sha256(encoded_jpg).hexdigest()
 
@@ -50,6 +51,8 @@ class TensorflowRecordFactory:
         return tf.train.Example(
             features=tf.train.Features(
                 feature={
+                    "image/filename": bytes_feature(image_name.encode("utf8")),
+                    "image/source_id": bytes_feature(image_name.encode("utf8")),
                     "image/height": int64_feature(height),
                     "image/width": int64_feature(width),
                     "image/key/sha256": bytes_feature(key.encode("utf8")),
-- 
GitLab