Commit 53068495 authored by E144069X's avatar E144069X

Added functions to plot histogram of video number containing each phase

parent 981ab247
......@@ -367,7 +367,7 @@ def plotData(nbClass,dataset):
nbImages += len(load_data.getGT(os.path.splitext(os.path.basename(videoPath))[0],dataset))
plt.figure()
plt.bar(np.arange(nbClass),priors*nbImages,width=1)
plt.bar(np.arange(nbClass),priors*nbImages,width=1,color='#8ebad9',edgecolor="black")
plt.xticks(np.arange(nbClass),labels,rotation=45)
plt.xlabel("Developpement phases")
plt.ylabel("Number of images")
......@@ -669,7 +669,7 @@ def plotMultiAttentionMaps(dataset,exp_id,model_id,epochToProcess):
writer.append_data(dest.astype("uint8"))
i+=1
def phaseNbHist(datasets,density):
def phaseNbHist(density):
def countRows(x):
x = np.genfromtxt(x,delimiter=",")
......@@ -686,11 +686,33 @@ def phaseNbHist(datasets,density):
plt.figure(1)
plt.hist(phases_nb_list,alpha=0.5,density=density,bins=16,range=(0,16),edgecolor='black')
phaseDict = {}
vidNb = 0
for path in paths:
annotation = np.genfromtxt(path,dtype=str,delimiter=",")
if len(annotation.shape) == 2:
vidNb += 1
phaseList = annotation[:,0]
for phase in phaseList:
if phase in phaseDict:
phaseDict[phase] += 1
else:
phaseDict[phase] = 1
print("Total number of video",vidNb)
phaseNames = formatData.getLabels()
phaseNb = list(map(lambda x:phaseDict[x],phaseNames))
plt.figure(2)
plt.bar(np.arange(len(phaseNb)),phaseNb,width=1,color='#8ebad9',edgecolor="black")
paths = glob.glob("../data/small/annotations/*timeElapsed.csv")
paths += glob.glob("../data/big/annotations/*timeElapsed.csv")
videoLengths = list(map(computeLength,paths))
plt.figure(2)
plt.figure(3)
plt.hist(videoLengths,alpha=0.5,bins=20,range=(0,180),density=density,edgecolor='black')
plt.figure(1)
......@@ -701,6 +723,14 @@ def phaseNbHist(datasets,density):
plt.close()
plt.figure(2)
plt.xticks(np.arange(16),phaseNames,rotation=30)
plt.xlabel("Phases")
plt.ylabel("Number of videos")
plt.tight_layout()
plt.savefig("../vis/priorsVid.png")
plt.close()
plt.figure(3)
plt.savefig("../vis/phasesLengths_density{}.png".format(density))
plt.close()
......@@ -926,7 +956,7 @@ def main(argv=None):
####################### Plot phase number histogram #####################
argreader.parser.add_argument('--phase_nb_hist',type=str,nargs="*",metavar="DATASET",help='To plot the histogram of phase number of all video in several datasets, \
argreader.parser.add_argument('--phase_nb_hist',action="store_true",help='To plot the histogram of phase number of all video in several datasets, \
along with histograms showing the video length distribution. The value of this argument is the names of the datasets.')
argreader.parser.add_argument('--density',type=str2bool,metavar="BOOL",help='To plot the histogram on a density scale.')
......@@ -992,7 +1022,7 @@ def main(argv=None):
if args.plot_multi_attention_maps:
plotMultiAttentionMaps(args.dataset_test,args.exp_id,args.model_id,args.epoch_to_process)
if args.phase_nb_hist:
phaseNbHist(args.phase_nb_hist,args.density)
phaseNbHist(args.density)
if args.plot_confusion_matrix:
plotConfusionMatrix(args.exp_id,args.model_id,args.epoch_to_process,args.dataset_test,args.test_part_beg,args.test_part_end)
if args.plot_points:
......
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