From e94c8458f0fc981aa4ee81a870f9b386f963aa29 Mon Sep 17 00:00:00 2001 From: charlesbvll Date: Sun, 25 Apr 2021 10:29:03 +0200 Subject: [PATCH] fix --- monoloco/eval/generate_kitti.py | 3 +-- monoloco/run.py | 2 +- monoloco/utils/kitti.py | 3 +-- monoloco/visuals/pifpaf_show.py | 7 +++---- monoloco/visuals/printer.py | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/monoloco/eval/generate_kitti.py b/monoloco/eval/generate_kitti.py index f65021e..6523aa6 100644 --- a/monoloco/eval/generate_kitti.py +++ b/monoloco/eval/generate_kitti.py @@ -273,5 +273,4 @@ def create_empty_files(dir_out, net): for i in range(7481): name = "0" * (6 - len(str(i))) + str(i) + '.txt' - ff = open(os.path.join(dir_out[net], name), "a+") - ff.close() + with open(os.path.join(dir_out[net], name), "a+"): pass diff --git a/monoloco/run.py b/monoloco/run.py index b22497a..74dc0ed 100644 --- a/monoloco/run.py +++ b/monoloco/run.py @@ -48,7 +48,7 @@ def cli(): visualizer.cli(parser) # Monoloco - predict_parser.add_argument('--activities', nargs='+', + predict_parser.add_argument('--activities', nargs='+', help='Choose activities to show: social_distance, raise_hand') predict_parser.add_argument('--mode', help='keypoints, mono, stereo', default='mono') predict_parser.add_argument('--model', help='path of MonoLoco/MonStereo model to load') diff --git a/monoloco/utils/kitti.py b/monoloco/utils/kitti.py index a306ff1..7ebc7fa 100644 --- a/monoloco/utils/kitti.py +++ b/monoloco/utils/kitti.py @@ -161,8 +161,7 @@ def read_and_rewrite(path_orig, path_new): line_new = temp_1 + ' ' + hwl + ' ' + temp_2 + '\n' ff.write("%s" % line_new) except FileNotFoundError: - ff = open(path_new, "a+") - ff.close() + with open(path_new, "a+"): pass def find_cluster(dd, clusters): diff --git a/monoloco/visuals/pifpaf_show.py b/monoloco/visuals/pifpaf_show.py index 5fef1d2..21bd1ec 100644 --- a/monoloco/visuals/pifpaf_show.py +++ b/monoloco/visuals/pifpaf_show.py @@ -109,11 +109,11 @@ class KeypointPainter: for ci, connection in enumerate(np.array(self.skeleton) - 1): c = color linewidth=self.linewidth - if ((connection[0] == 5 and connection[1] == 7) + if ((connection[0] == 5 and connection[1] == 7) or (connection[0] == 7 and connection[1] == 9)) and raise_hand in ['left','both']: c = 'yellow' linewidth = l_arm_width - if ((connection[0] == 6 and connection[1] == 8) + if ((connection[0] == 6 and connection[1] == 8) or (connection[0] == 8 and connection[1] == 10)) and raise_hand in ['right', 'both']: c = 'yellow' linewidth = r_arm_width @@ -192,7 +192,7 @@ class KeypointPainter: matplotlib.patches.Rectangle( (x - scale, y - scale), 2 * scale, 2 * scale, fill=False, color=color)) - def keypoints(self, ax, keypoint_sets, *, + def keypoints(self, ax, keypoint_sets, *, size=None, scores=None, color=None, colors=None, texts=None, raise_hand='none'): if keypoint_sets is None: return @@ -443,4 +443,3 @@ def social_distance_colors(colors, dic_out): # Prepare color for social distancing colors = ['r' if flag else colors[idx] for idx,flag in enumerate(dic_out['social_distance'])] return colors - diff --git a/monoloco/visuals/printer.py b/monoloco/visuals/printer.py index 34fce8a..b475217 100644 --- a/monoloco/visuals/printer.py +++ b/monoloco/visuals/printer.py @@ -248,7 +248,7 @@ class Printer: if not self.args.activities or 'social_distance' not in self.args.activities: self.mpl_im0.set_data(image) - self._front_loop(iterator, axes, number, colors, annotations, dic_out) + self._front_loop(iterator, axes, number, colors, annotations, dic_out) # Draw the bird figure number['num'] = 97