diff --git a/test.py b/test.py index ecb34399..eb902c5f 100644 --- a/test.py +++ b/test.py @@ -89,6 +89,10 @@ def test( stats.append(([], torch.Tensor(), torch.Tensor(), tcls)) continue + # Append to text file + # with open('test.txt', 'a') as file: + # [file.write('%11.5g' * 7 % tuple(x) + '\n') for x in pred] + # Append to pycocotools JSON dictionary if save_json: # [{"image_id": 42, "category_id": 18, "bbox": [258.15, 41.29, 348.26, 243.78], "score": 0.236}, ... diff --git a/utils/utils.py b/utils/utils.py index 1a340f2b..6a4e90e0 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -599,6 +599,25 @@ def plot_images(imgs, targets, fname='images.jpg'): plt.close() +def plot_test_txt(): # from test import *; plot_test() + # Plot test.txt histograms + x = np.loadtxt('test.txt', dtype=np.float32) + box = xyxy2xywh(x[:, :4]) + cx, cy = box[:, 0], box[:, 1] + + fig, ax = plt.subplots(1, 1, figsize=(6, 6)) + ax.hist2d(cx, cy, bins=600, cmax=10, cmin=0) + ax.set_aspect('equal') + fig.tight_layout() + plt.savefig('hist2d.jpg', dpi=300) + + fig, ax = plt.subplots(1, 2, figsize=(12, 6)) + ax[0].hist(cx, bins=600) + ax[1].hist(cy, bins=600) + fig.tight_layout() + plt.savefig('hist1d.jpg', dpi=300) + + def plot_results(start=0, stop=0): # from utils.utils import *; plot_results() # Plot training results files 'results*.txt' # import os; os.system('wget https://storage.googleapis.com/ultralytics/yolov3/results_v3.txt')