Commit 42acfff4 authored by Gihan Jayatilaka's avatar Gihan Jayatilaka

visualizer-2

parent 218c3d22
#python visualize-2.py results-video.npz
import numpy as np
import matplotlib.pyplot as plt
import sys
import math
import scipy.signal
CELLS_PER_FRAME=0
SQRT_CELLS=0
if __name__ == '__main__':
RESULT_FILE_NAME=sys.argv[1]
CELLS_PER_FRAME=(int(sys.argv[2]))
SQRT_CELLS=math.sqrt(CELLS_PER_FRAME)
data=np.load(RESULT_FILE_NAME)
def countMisses(yTrue,yPred,windowH,windowW):
global SQRT_CELLS
truePred=np.zeros(shape=(windowH*windowW,windowH*windowW),dtype=np.int32)
yTrue=np.reshape(yTrue,(yTrue.shape[0],SQRT_CELLS,SQRT_CELLS))
yPred=np.reshape(yPred,(yPred.shape[0],SQRT_CELLS,SQRT_CELLS))
convKer=np.zeros((windowH,windowW),dtype=np.int32)
convTrue=np.zeros((yTrue.shape[0],SQRT_CELLS-windowH+1,SQRT_CELLS-windowW+1))
convPred=np.zeros((yPred.shape[0],SQRT_CELLS-windowH+1,SQRT_CELLS-windowW+1))
for f in range(yTrue.shape[0]):
convTrue[f]=scipy.signal.convolve2d(yTrue[f],convKer,mode='valid')
for f in range(yPred.shape[0]):
convPred[f]=scipy.signal.convolve2d(yPred[f],convKer,mode='valid')
def drawTrainingHistograms(data):
global SQRT_CELLS
VID='cropped-tvstatic-video'
FIG_NAME='{}-{}x{}-inception'.format(VID,SQRT_CELLS,SQRT_CELLS)
TITLE='{}-{}x{}->inception'.format(VID,SQRT_CELLS,SQRT_CELLS)
CAPTION=" inception v3 network"
FIG_NAME='./fig/'+FIG_NAME+'.png'
trc=data['trainCost']
tra=data['trainAcc']
tec=data['testCost']
tea=data['testAcc']
#print(np.array(tra)-np.array(tea))
EPOCHS=len(trc)
e=range(EPOCHS)
fig, ax = plt.subplots(figsize=(10, 10))
fig.subplots_adjust(bottom=0.5, left=0.2)
ax.plot(e,trc,'r',e,tra,'k',e,tec,'b',e,tea,'y')
ax.set_xlabel('Batch iter\n\n\n----------------------\n'+CAPTION,horizontalalignment='left', x=0)
ax.set_ylabel("Performance")
plt.legend(['Train cost','Train acc','Test cost','Test acc'])
major_ticksY = np.arange(0, 1.05, 0.2)
minor_ticksY = np.arange(0, 1.05, 0.05)
#ax.set_xticks(major_ticksY)
#ax.set_xticks(minor_ticksY, minor=True)
ax.set_yticks(major_ticksY)
ax.set_yticks(minor_ticksY, minor=True)
# And a corresponding grid
ax.grid(which='both')
# Or if you want different settings for the grids:
ax.grid(which='minor', alpha=0.2)
ax.grid(which='major', alpha=0.5)
plt.title(TITLE)
plt.savefig(FIG_NAME,dpi=1000)
plt.show()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment