From 003f265719c0e81b7662e6e1763330dd238a2f66 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Mon, 20 Apr 2020 15:11:50 +0800 Subject: [PATCH] fix inference vis.py py2 encoding (#522) --- inference/tools/vis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inference/tools/vis.py b/inference/tools/vis.py index d0f9fc841f..a4f7c6b413 100644 --- a/inference/tools/vis.py +++ b/inference/tools/vis.py @@ -20,6 +20,7 @@ import numpy as np import json from PIL import Image, ImageDraw, ImageFont +import io Flags = gflags.FLAGS gflags.DEFINE_string('img_path', 'abc', 'image path') @@ -80,7 +81,7 @@ def colormap(rgb=False): img = cv2.imread(Flags.img_path) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) class2LabelMap = dict() - with open(Flags.c2l_path, "r", encoding="utf-8") as json_f: + with io.open(Flags.c2l_path, "r", encoding="utf-8") as json_f: class2LabelMap = json.load(json_f) for box in detection_result.detection_boxes: if box.score >= Flags.threshold: