From 81c0f909c2ca84e5c1b481ef84ec4b50a88d1cd2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Oct 2021 15:52:51 +0200 Subject: [PATCH 1/6] Fixing float index error. --- pycocotools/cocoeval.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pycocotools/cocoeval.py b/pycocotools/cocoeval.py index da2756b..96a3e93 100644 --- a/pycocotools/cocoeval.py +++ b/pycocotools/cocoeval.py @@ -605,8 +605,8 @@ def setDetParams(self): self.imgIds = [] self.catIds = [] # np.arange causes trouble. the data point on arange is slightly larger than the true value - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) - self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) + self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05) + 1), endpoint=True) + self.recThrs = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01) + 1), endpoint=True) self.maxDets = [1, 10, 100] self.areaRng = [[0 ** 2, 1e5 ** 2], [0 ** 2, 32 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] self.areaRngLbl = ['all', 'small', 'medium', 'large'] @@ -616,8 +616,8 @@ def setKpParams(self): self.imgIds = [] self.catIds = [] # np.arange causes trouble. the data point on arange is slightly larger than the true value - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) - self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) + self.iouThrs = np.linspace(.5, 0.95, int(np.round((0.95 - .5) / .05) + 1), endpoint=True) + self.recThrs = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01) + 1), endpoint=True) self.maxDets = [20] self.areaRng = [[0 ** 2, 1e5 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] self.areaRngLbl = ['all', 'medium', 'large'] From 398af7707410c415979bee8f47cabf6b88629b2d Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Oct 2021 15:57:13 +0200 Subject: [PATCH 2/6] Replace scipy.imresize with cv2.resize because imresize was removed. --- analysisAPI/backgroundFalseNegErrors.py | 4 ++-- analysisAPI/backgroundFalsePosErrors.py | 1 - analysisAPI/utilities.py | 1 - requirements.txt | 3 ++- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/analysisAPI/backgroundFalseNegErrors.py b/analysisAPI/backgroundFalseNegErrors.py index 814624f..48b5945 100644 --- a/analysisAPI/backgroundFalseNegErrors.py +++ b/analysisAPI/backgroundFalseNegErrors.py @@ -1,9 +1,9 @@ ## imports import os, time +import cv2 import numpy as np import matplotlib.pyplot as plt import matplotlib.path as mplPath -from scipy.misc import imresize import skimage.io as io # package imports @@ -146,7 +146,7 @@ def backgroundFalseNegErrors( coco_analyze, imgs_info, saveDir ): grid = grid.reshape((ny,nx)) the_mask += np.array(grid, dtype=int) - segm_heatmap += imresize(the_mask,(128,128)) + segm_heatmap += cv2.resize(the_mask,(128,128)) fig = plt.figure(figsize=(10,10)) ax = plt.subplot(111) diff --git a/analysisAPI/backgroundFalsePosErrors.py b/analysisAPI/backgroundFalsePosErrors.py index 9744b5a..7028a3f 100644 --- a/analysisAPI/backgroundFalsePosErrors.py +++ b/analysisAPI/backgroundFalsePosErrors.py @@ -3,7 +3,6 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib.path as mplPath -from scipy.misc import imresize import skimage.io as io # package imports diff --git a/analysisAPI/utilities.py b/analysisAPI/utilities.py index 5c8ede1..4d7573f 100644 --- a/analysisAPI/utilities.py +++ b/analysisAPI/utilities.py @@ -6,7 +6,6 @@ import matplotlib.path as mplPath from matplotlib.collections import PatchCollection from matplotlib.patches import Polygon -from scipy.misc import imresize import skimage.io as io """ diff --git a/requirements.txt b/requirements.txt index dce60de..08d34cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ colour numpy -matplotlib \ No newline at end of file +matplotlib +opencv-python From 3dc44c5dc1b160589a183580237aad7013e0b2e5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Oct 2021 16:15:31 +0200 Subject: [PATCH 3/6] Save report.tex in the output directory too. --- run_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_analysis.py b/run_analysis.py index ae9e710..f50f0d6 100644 --- a/run_analysis.py +++ b/run_analysis.py @@ -119,7 +119,7 @@ def main(): paths = sizeSensitivity( coco_analyze, .75, saveDir ) template_vars.update(paths) - output_report = open('./%s_performance_report.tex'%teamName, 'w') + output_report = open("{}/{}_performance_report.tex".format(saveDir, teamName), 'w') output_report.write( template.render(template_vars) ) output_report.close() From cc0c255d7b6e4d050787c1855f2ec504df3a936b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Oct 2021 16:18:36 +0200 Subject: [PATCH 4/6] Fix AP discrepancy, see https://github.com/matteorr/coco-analyze/issues/17. --- run_analysis.py | 1 + 1 file changed, 1 insertion(+) diff --git a/run_analysis.py b/run_analysis.py index f50f0d6..e3f91e9 100644 --- a/run_analysis.py +++ b/run_analysis.py @@ -78,6 +78,7 @@ def main(): ## initialize COCO analyze api coco_analyze = COCOanalyze(coco_gt, coco_dt, 'keypoints') + coco_analyze.params.areaRng = [[0 ** 2, 1e5 ** 2], [32 ** 2, 96 ** 2], [96 ** 2, 1e5 ** 2]] if teamName == 'fakekeypoints100': imgIds = sorted(coco_gt.getImgIds())[0:100] coco_analyze.cocoEval.params.imgIds = imgIds From 7aff7d2c66a70f4d8294862550e66d7e1728ef49 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Oct 2021 16:27:33 +0200 Subject: [PATCH 5/6] Search latex template relative from script. --- run_analysis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_analysis.py b/run_analysis.py index e3f91e9..015fc4c 100644 --- a/run_analysis.py +++ b/run_analysis.py @@ -19,6 +19,7 @@ def main(): if len(sys.argv) != 6: raise ValueError("Please specify args: $> python run_analysis.py [annotations_path] [detections_path] [save_dir] [team_name] [version_name]") + filepath = os.path.dirname(os.path.realpath(__file__)) + "/" latex_jinja_env = jinja2.Environment( block_start_string = '\BLOCK{', block_end_string = '}', @@ -30,7 +31,7 @@ def main(): line_comment_prefix = '%#', trim_blocks = True, autoescape = False, - loader = jinja2.FileSystemLoader(os.path.abspath('./latex/')) + loader = jinja2.FileSystemLoader(filepath + 'latex/') ) template = latex_jinja_env.get_template('report_template.tex') template_vars = {} From a17c854d181735ccd9e6f3b1a91159eaebc4bc8a Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Oct 2021 16:53:22 +0200 Subject: [PATCH 6/6] Fix new latex save dir. --- analysisAPI/localizationErrors.py | 3 ++- latex/report_template.tex | 2 +- run_analysis.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/analysisAPI/localizationErrors.py b/analysisAPI/localizationErrors.py index 8422113..da53cc8 100644 --- a/analysisAPI/localizationErrors.py +++ b/analysisAPI/localizationErrors.py @@ -81,7 +81,8 @@ def localizationErrors( coco_analyze, imgs_info, saveDir ): plt.close() fig = plt.figure(figsize=(15,15)); plt.axis('off') - I = io.imread('./latex/manikin.jpg') + filepath = os.path.dirname(os.path.realpath(__file__)) + "/" + I = io.imread(filepath + '../latex/manikin.jpg') plt.imshow(I); ax = plt.gca(); ax.set_autoscale_on(False) rects_d = {} diff --git a/latex/report_template.tex b/latex/report_template.tex index d225032..5c87c3d 100644 --- a/latex/report_template.tex +++ b/latex/report_template.tex @@ -42,7 +42,7 @@ % HUMAN SKELETON COLOR CODING \section{Human Pose and Skeleton Color Coding} \begin{wrapfigure}{l}{0.5\textwidth} -\includegraphics[width=\linewidth]{./latex/color_coding.pdf} +\includegraphics[width=\linewidth]{color_coding.pdf} \caption{ {\small \textbf{Detection's Skeleton Color Coding.}}} \end{wrapfigure} We adopt the following color coding when visualizing an algorithm's keypoint detections: diff --git a/run_analysis.py b/run_analysis.py index 015fc4c..410c6b6 100644 --- a/run_analysis.py +++ b/run_analysis.py @@ -1,5 +1,5 @@ ## general imports -import os, sys, json, datetime, jinja2 +import os, shutil, sys, json, datetime, jinja2 from jinja2 import Template ## COCO imports @@ -124,6 +124,7 @@ def main(): output_report = open("{}/{}_performance_report.tex".format(saveDir, teamName), 'w') output_report.write( template.render(template_vars) ) output_report.close() + shutil.copyfile(filepath + 'latex/color_coding.pdf', os.path.join(saveDir, 'color_coding.pdf')) if __name__ == '__main__': main()