From 84ae114601d4120b2b885e4d244d11a2db9b87a5 Mon Sep 17 00:00:00 2001 From: Srikanth Anantharam Date: Mon, 27 Mar 2017 11:55:03 +0530 Subject: [PATCH 1/2] open labels file in text mode (not binary) + this makes the `human_string` more humane --- retraining-example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retraining-example.py b/retraining-example.py index 6ca1dd1..e4ba1d5 100644 --- a/retraining-example.py +++ b/retraining-example.py @@ -70,7 +70,7 @@ def run_inference_on_image(): predictions = np.squeeze(predictions) top_k = predictions.argsort()[-5:][::-1] # Getting top 5 predictions - f = open(labelsFullPath, 'rb') + f = open(labelsFullPath, 'r') lines = f.readlines() labels = [str(w).replace("\n", "") for w in lines] for node_id in top_k: From 8cb7c0aba765a18fe89946974d22213d856b9bce Mon Sep 17 00:00:00 2001 From: Srikanth Anantharam Date: Mon, 27 Mar 2017 11:56:56 +0530 Subject: [PATCH 2/2] `w` is already a string --- retraining-example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retraining-example.py b/retraining-example.py index e4ba1d5..9d084ce 100644 --- a/retraining-example.py +++ b/retraining-example.py @@ -72,7 +72,7 @@ def run_inference_on_image(): top_k = predictions.argsort()[-5:][::-1] # Getting top 5 predictions f = open(labelsFullPath, 'r') lines = f.readlines() - labels = [str(w).replace("\n", "") for w in lines] + labels = [w.replace("\n", "") for w in lines] for node_id in top_k: human_string = labels[node_id] score = predictions[node_id]