witnn/Other/GenPrecisionImage.py

58 lines
1020 B
Python
Executable File

import matplotlib
matplotlib.use('Agg')
import sys
sys.path.append("./coco/PythonAPI/")
import json
import time
import argparse
import pprint
import numpy as np
from pycocotools.coco import COCO
import shutil
import cv2
import torch
import PIL
import torchvision
from torchvision import transforms, utils
import re
import matplotlib.pyplot as plt
testtxt=open('TestPrecision.txt','r')
valtxt=open('ValPrecision.txt','r')
test=[]
for line in testtxt:
line = line.strip('\n')
line = line.rstrip()
#words = line.split()
test.append(float(line))
val=[]
for line in valtxt:
line = line.strip('\n')
line = line.rstrip()
#words = line.split()
val.append(float(line))
y1 = np.array(test)
y2 = np.array(val)
x1=np.arange(len(test))
x2=np.arange(len(val))
plt.figure()
plt.plot(x1, y1, color='red', label='testing')
plt.plot(x2, y2, color='green', label='validation')
plt.title('')
plt.xlabel('epoch')
plt.ylabel('precision')
plt.legend()
plt.savefig('result.png',dpi=600)
#plt.show()