Commit 0b9e4680 authored by Gihan Jayatilaka's avatar Gihan Jayatilaka

17-04-2019

parent 42acfff4
python inceptionV3.py video/tvstatic-ideal-3x3.npz 1 0.1 8000 250 9 > exp-2019-04-04-incep-3x3.txt
python inceptionV3.py video/tvstatic-ideal-5x5.npz 1 0.1 8000 250 25 > exp-2019-04-04-incep-5x5.txt
python inceptionV3.py video/tvstatic-ideal-10x10.npz 1 0.1 8000 250 100 > exp-2019-04-04-incep-10x10.txt
python inceptionV3.py video/tvstatic-ideal-20x20.npz 1 0.1 8000 250 400 > exp-2019-04-04-incep-20x20.txt
python inceptionV3-shallow.py video/tvstatic-ideal-3x3.npz 1 0.1 8000 250 9 > exp-2019-04-04-shallow-3x3.txt
python inceptionV3-shallow.py video/tvstatic-ideal-5x5.npz 1 0.1 8000 250 25 > exp-2019-04-04-shallow-5x5.txt
python inceptionV3-shallow.py video/tvstatic-ideal-10x10.npz 1 0.1 8000 250 100 > exp-2019-04-04-shallow-10x10.txt
python inceptionV3-shallow.py video/tvstatic-ideal-20x20.npz 1 0.1 8000 250 400 > exp-2019-04-04-shallow-20x20.txt
python inceptionV3-extra-fc.py video/tvstatic-ideal-3x3.npz 1 0.1 8000 250 9 > exp-2019-04-04-fc-3x3.txt
python inceptionV3-extra-fc.py video/tvstatic-ideal-5x5.npz 1 0.1 8000 250 25 > exp-2019-04-04-fc-5x5.txt
python inceptionV3-extra-fc.py video/tvstatic-ideal-10x10.npz 1 0.1 8000 250 100 > exp-2019-04-04-fc-10x10.txt
python inceptionV3-extra-fc.py video/tvstatic-ideal-20x20.npz 1 0.1 8000 250 400 > exp-2019-04-04-fc-20x20.txt
#python inceptionV3.py video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame
python inceptionV3.py video/videos-ideal-3x3-shuffled.npz 0 0.2 10000 100 9 > exp-2019-04-05-incep-3x3.txt
python inceptionV3.py video/videos-ideal-5x5-shuffled.npz 0 0.2 10000 100 25 > exp-2019-04-05-incep-5x5.txt
python inceptionV3.py video/videos-ideal-10x10-shuffled.npz 0 0.2 10000 100 100 > exp-2019-04-05-incep-10x10.txt
python inceptionV3.py video/videos-ideal-10x10-shuffled.npz 0 0.2 10000 100 400 > exp-2019-04-05-incep-20x20.txt
python inceptionV3-shallow.py video/videos-ideal-3x3-shuffled.npz 0 0.2 10000 100 9 > exp-2019-04-05-incep-shallow-3x3.txt
python inceptionV3-shallow.py video/videos-ideal-5x5-shuffled.npz 0 0.2 10000 100 25 > exp-2019-04-05-incep-shallow-5x5.txt
python inceptionV3-shallow.py video/videos-ideal-10x10-shuffled.npz 0 0.2 10000 100 100 > exp-2019-04-05-incep-shallow-10x10.txt
python inceptionV3-shallow.py video/videos-ideal-10x10-shuffled.npz 0 0.2 10000 100 400 > exp-2019-04-05-incep-shallow-20x20.txt
python inceptionV3-extra-fc.py video/videos-ideal-3x3-shuffled.npz 0 0.2 10000 100 9 > exp-2019-04-05-incep-extra-fc-3x3.txt
python inceptionV3-extra-fc.py video/videos-ideal-5x5-shuffled.npz 0 0.2 10000 100 25 > exp-2019-04-05-incep-extra-fc-5x5.txt
python inceptionV3-extra-fc.py video/videos-ideal-10x10-shuffled.npz 0 0.2 10000 100 100 > exp-2019-04-05-incep-extra-fc-10x10.txt
python inceptionV3-extra-fc.py video/videos-ideal-10x10-shuffled.npz 0 0.2 10000 100 400 > exp-2019-04-05-incep-extra-fc-20x20.txt
#python inceptionV3.py video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame
python inceptionV3.py video/videos-ideal-20x20.npz 7 0.2 10000 100 400 > exp-2019-04-08-incep-20x20.txt
python inceptionV3-shallow.py video/videos-ideal-20x20.npz 7 0.2 10000 100 400 > exp-2019-04-08-incep-shallow-20x20.txt
python inceptionV3-extra-fc.py video/videos-ideal-20x20.npz 7 0.2 10000 100 400 > exp-2019-04-08-incep-extra-fc-20x20.txt
python inceptionV3.py video/videos-ideal-10x10.npz 7 0.2 10000 100 100 > exp-2019-04-08-incep-10x10.txt
python inceptionV3-shallow.py video/videos-ideal-10x10.npz 7 0.2 10000 100 100 > exp-2019-04-08-incep-shallow-10x10.txt
python inceptionV3-extra-fc.py video/videos-ideal-10x10.npz 7 0.2 10000 100 100 > exp-2019-04-08-incep-extra-fc-10x10.txt
python inceptionV3.py video/videos-ideal-3x3.npz 7 0.2 10000 100 9 > exp-2019-04-08-incep-3x3.txt
python inceptionV3.py video/videos-ideal-5x5.npz 7 0.2 10000 100 25 > exp-2019-04-08-incep-5x5.txt
python inceptionV3-shallow.py video/videos-ideal-3x3.npz 7 0.2 10000 100 9 > exp-2019-04-08-incep-shallow-3x3.txt
python inceptionV3-shallow.py video/videos-ideal-5x5.npz 7 0.2 10000 100 25 > exp-2019-04-08-incep-shallow-5x5.txt
python inceptionV3-extra-fc.py video/videos-ideal-3x3.npz 7 0.2 10000 100 9 > exp-2019-04-08-incep-extra-fc-3x3.txt
python inceptionV3-extra-fc.py video/videos-ideal-5x5.npz 7 0.2 10000 100 25 > exp-2019-04-08-incep-extra-fc-5x5.txt
CUDA=7
ITERS=1
rm -rf rep-2019-04-2018/
mkdir rep-2019-04-2018/
#python inceptionV3.py video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame
python inceptionV3.py video/multivid-rec-10x10.npz $CUDA 0.2 8000 $ITERS 100 > ./rep-2019-04-2018/multivid-rec-10x10-incep.txt
python inceptionV3-shallow.py video/multivid-rec-10x10.npz $CUDA 0.2 8000 $ITERS 100 > ./rep-2019-04-2018/multivid-rec-10x10-incep-shallow.txt
python inceptionV3-extra-fc.py video/multivid-rec-10x10.npz $CUDA 0.2 8000 $ITERS 100 > ./rep-2019-04-2018/multivid-rec-10x10-incep-extra-fc.txt
python inceptionV3.py video/multivid-rec-20x20.npz $CUDA 0.2 8000 $ITERS 400 > ./rep-2019-04-2018/multivid-rec-20x20-incep.txt
python inceptionV3-shallow.py video/multivid-rec-20x20.npz $CUDA 0.2 8000 $ITERS 400 > ./rep-2019-04-2018/multivid-rec-20x20-incep-shallow.txt
python inceptionV3-extra-fc.py video/multivid-rec-20x20.npz $CUDA 0.2 8000 $ITERS 400 > ./rep-2019-04-2018/multivid-rec-20x20-incep-extra-fc.txt
#python inceptionV3.py video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame
python inceptionV3.py video/tvstatic-rec-10x10.npz $CUDA 0.2 8000 $ITERS 100 > ./rep-2019-04-2018/tvstatic-rec-10x10-incep.txt
python inceptionV3-shallow.py video/tvstatic-rec-10x10.npz $CUDA 0.2 8000 $ITERS 100 > ./rep-2019-04-2018/tvstatic-rec-10x10-incep-shallow.txt
python inceptionV3-extra-fc.py video/tvstatic-rec-10x10.npz $CUDA 0.2 8000 $ITERS 100 > ./rep-2019-04-2018/tvstatic-rec-10x10-incep-extra-fc.txt
python inceptionV3.py video/tvstatic-rec-20x20.npz $CUDA 0.2 8000 $ITERS 400 > ./rep-2019-04-2018/tvstatic-rec-20x20-incep.txt
python inceptionV3-shallow.py video/tvstatic-rec-20x20.npz $CUDA 0.2 8000 $ITERS 400 > ./rep-2019-04-2018/tvstatic-rec-20x20-incep-shallow.txt
python inceptionV3-extra-fc.py video/tvstatic-rec-20x20.npz $CUDA 0.2 8000 $ITERS 400 > ./rep-2019-04-2018/multivid-rec-20x20-incep-extra-fc.txt
\ No newline at end of file
CUDA=6
ITERS=100
FRAMES=8000
TESTFRAC=0.2
rm -rf exp-2019-04-16/
mkdir exp-2019-04-16/
python inception.py none video/cropped/tvstatic-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-tvstatic-cropped-incep-10x10.npz
python inception.py none video/cropped/tvstatic-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-tvstatic-cropped-incep-20x20.npz
python inception.py none video/cropped/multivid-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-multivid-cropped-incep-10x10.npz
python inception.py none video/cropped/multivid-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-multivid-cropped-incep-20x20.npz
python inception.py shallow video/cropped/tvstatic-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-tvstatic-cropped-incep-shallow-10x10.npz
python inception.py shallow video/cropped/tvstatic-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-tvstatic-cropped-incep-shallow-20x20.npz
python inception.py shallow video/cropped/multivid-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-multivid-cropped-incep-shallow-10x10.npz
python inception.py shallow video/cropped/multivid-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-multivid-cropped-incep-shallow-20x20.npz
python inception.py extra-fc video/cropped/tvstatic-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-tvstatic-cropped-incep-extrafc-10x10.npz
python inception.py extra-fc video/cropped/tvstatic-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-tvstatic-cropped-incep-extrafc-20x20.npz
python inception.py extra-fc video/cropped/multivid-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-multivid-cropped-incep-extrafc-10x10.npz
python inception.py extra-fc video/cropped/multivid-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-multivid-cropped-incep-extrafc-20x20.npz
python inception.py very-shallow video/cropped/tvstatic-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-tvstatic-cropped-incep-veryshallow-10x10.npz
python inception.py very-shallow video/cropped/tvstatic-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-tvstatic-cropped-incep-veryshallow-20x20.npz
python inception.py very-shallow video/cropped/multivid-cropped-10x10.npz $CUDA $TESTFRAC $FRAMES $ITERS 100 exp-2019-04-16/results-multivid-cropped-incep-veryshallow-10x10.npz
python inception.py very-shallow video/cropped/multivid-cropped-20x20.npz $CUDA $TESTFRAC $FRAMES $ITERS 400 exp-2019-04-16/results-multivid-cropped-incep-veryshallow-20x20.npz
import os
CUDA=6
ITERS=100
FRAMES=8000
TESTFRAC=0.2
DIR='exp-2019-04-17'
#ALGOS=['none','extra-fc','shallow','very-shallow']
ALGOS=['none','very-shallow']
ANGLES=[0,7,10,60]
CELS_PER_FRAME=100
TEMP=['cropped/multivid-crop','rec/multivid-rec']
commandCount=[0,0]
f=open(DIR+'.sh',"w")
f.write("rm -rf {}\n".format(DIR))
commandCount[0]+=1
f.write('mkdir {}\n'.format(DIR))
commandCount[0]+=1
f.write('CUDA={}\n'.format(CUDA))
commandCount[0]+=1
for t in TEMP:
for algo in ALGOS:
for angle in ANGLES:
f.write('python inception.py {} video/{}-10x10-{:02d}-deg.npz {} {} {} {} {} {}/results-tvstatic-{}-{:02d}-deg-{}.npz'\
.format(algo,t,angle,"$CUDA",TESTFRAC,FRAMES,ITERS,CELS_PER_FRAME,DIR,t.split("-")[1],angle,algo))
f.write("\n")
commandCount[1]+=1
f.close()
print("{} commands including {} NN training commands written to file {}".format(commandCount[0]+commandCount[1],commandCount[1],"{}.sh".format(DIR)))
os.system("chmod 700 {}.sh".format(DIR))
os.system("./{}.sh".format(DIR))
rm -rf exp-2019-04-17
mkdir exp-2019-04-17
CUDA=6
python inception.py none video/cropped/multivid-crop-10x10-00-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-00-deg-none.npz
python inception.py none video/cropped/multivid-crop-10x10-07-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-07-deg-none.npz
python inception.py none video/cropped/multivid-crop-10x10-10-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-10-deg-none.npz
python inception.py none video/cropped/multivid-crop-10x10-60-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-60-deg-none.npz
python inception.py very-shallow video/cropped/multivid-crop-10x10-00-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-00-deg-very-shallow.npz
python inception.py very-shallow video/cropped/multivid-crop-10x10-07-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-07-deg-very-shallow.npz
python inception.py very-shallow video/cropped/multivid-crop-10x10-10-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-10-deg-very-shallow.npz
python inception.py very-shallow video/cropped/multivid-crop-10x10-60-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-crop-60-deg-very-shallow.npz
python inception.py none video/rec/multivid-rec-10x10-00-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-00-deg-none.npz
python inception.py none video/rec/multivid-rec-10x10-07-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-07-deg-none.npz
python inception.py none video/rec/multivid-rec-10x10-10-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-10-deg-none.npz
python inception.py none video/rec/multivid-rec-10x10-60-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-60-deg-none.npz
python inception.py very-shallow video/rec/multivid-rec-10x10-00-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-00-deg-very-shallow.npz
python inception.py very-shallow video/rec/multivid-rec-10x10-07-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-07-deg-very-shallow.npz
python inception.py very-shallow video/rec/multivid-rec-10x10-10-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-10-deg-very-shallow.npz
python inception.py very-shallow video/rec/multivid-rec-10x10-60-deg.npz $CUDA 0.2 8000 100 100 exp-2019-04-17/results-tvstatic-rec-60-deg-very-shallow.npz
......@@ -6,8 +6,8 @@
"metadata": {},
"outputs": [],
"source": [
"# python inception.py None|shallow|extra-fc video/tvstatic-ideal-3x3.npz 1 0.2 1000 1 9\n",
"# python inception.py None|shallow|extra-fc video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame"
"# python inception.py shallow video/tvstatic-ideal-3x3.npz 1 0.2 100 5 9 results.npz\n",
"# python inception.py {None|shallow|extra-fc} video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame results.npz"
]
},
{
......@@ -179,7 +179,7 @@
"metadata": {},
"outputs": [],
"source": [
"def trainAndTestForVideo(model,fileName,noFrames,framesToSkip=0,videoFileFormat='.avi',testSplit=0.1):\n",
"def trainAndTestForVideo(model,fileName,noFrames,framesToSkip=0,videoFileFormat='.avi',testSplit=0.1,resultFile=None):\n",
" print(\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Starting new video file\\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>{}\".format(fileName))\n",
" FILE_NAME=fileName\n",
" FILE_NAME_VIDEO=FILE_NAME+videoFileFormat\n",
......@@ -217,16 +217,23 @@
" xTrain, xTest, yTrain, yTest= train_test_split(dataX, dataY, test_size=testSplit)\n",
" dataX=None\n",
" dataY=None\n",
" print(\"SIZES: xTrain {}, yTrain {}, xTest {}, yTest {}\".format(xTrain.shape,yTrain.shape,xTest.shape,yTest.shape))\n",
" print(\"SIZES: xTrain {}, yTrain {}, xTest {}, yTest {}\".\\\n",
" format(xTrain.shape,yTrain.shape,xTest.shape,yTest.shape))\n",
" \n",
" if INTERACTIVE: iters=int(input(\"How many iters more? : \"))\n",
" else: iters=EPOCHS\n",
" while iters>0:\n",
" hist=oneIter(model,xTrain,yTrain,xTest,yTest,hist)\n",
" print(\"Iter {} of {} complete\".format(len(hist['testAcc']),EPOCHS))\n",
" iters-=1\n",
" if iters==0:\n",
" if INTERACTIVE: iters=int(input(\"How many iters more? : \"))\n",
" \n",
" \n",
" if resultFile!=None:\n",
" np.savez(resultFile,\\\n",
" yPredTest=np.round(model.predict(xTest)).astype(np.uint8),yPredTrain=np.round(model.predict(xTrain)).astype(np.uint8),yTrueTest=yTest,yTrueTrain=yTrain,\\\n",
" trainAcc=hist['trainAcc'],trainCost=hist['trainCost'],testAcc=hist['testAcc'],testCost=hist['testCost'])\n",
" \n",
" print(hist)"
]
},
......@@ -545,41 +552,14 @@
"outputs": [],
"source": [
"def inceptionVeryShallow(imgInput):\n",
" '''\n",
" gihanj (16/04/2019): Vu, please complete this.\n",
" '''\n",
" print(imgInput.shape)\n",
" x=None\n",
"# x=inceptionConeA(imgInput)\n",
"# print(x.shape)\n",
"# x=inceptionBlockA(x,64)\n",
"# print(\"After 3A\",x.shape)\n",
"# x=inceptionConeB(x)\n",
"# print(x.shape)\n",
"# x=inceptionBlockB(x,128)\n",
"# print(\"After 1B\",x.shape)\n",
"# x=inceptionBlockB(x,160)\n",
"# print(\"After 2B\",x.shape)\n",
"# x=inceptionBlockB(x,160)\n",
"# print(\"After 3B\",x.shape)\n",
"# x=inceptionBlockB(x,192)\n",
"# print(\"After 4B\",x.shape)\n",
"# x=inceptionConeC(x)\n",
"# print(x.shape)\n",
"# x=inceptionBlockC(x)\n",
"# print(\"After 1C\",x.shape)\n",
"# x=inceptionBlockC(x)\n",
"# print(\"After 2C\",x.shape)\n",
"\n",
"\n",
"# x = AveragePooling2D(pool_size=(8, 8), strides=(8,8),name='avg_pool')(x)\n",
"# print(x.shape)\n",
"# x = Flatten()(x)\n",
"# print(x.shape)\n",
"# x = Dropout(0.25)(x)\n",
"# print(x.shape)\n",
"# x = Dense(CELLS_PER_FRAME, activation='sigmoid', name='predictions')(x)\n",
"# print(x.shape) \n",
" x=inceptionConeA(imgInput)\n",
" x=inceptionBlockA(x,64)\n",
" x = layers.AveragePooling2D(name='avg_pool')(x)\n",
" x = Flatten()(x)\n",
" x = Dropout(0.25)(x)\n",
" x = Dense(CELLS_PER_FRAME, activation='sigmoid', name='predictions')(x)\n",
" return x"
]
},
......@@ -590,18 +570,19 @@
"outputs": [],
"source": [
"def inceptionNet(variant=None):\n",
"\n",
" if DEBUG: print(\"DEBUG: Model vairant={}.\".format(variant))\n",
" imgInput = Input(shape=(299,299,3))\n",
" x=None\n",
" if variant==None or variant==\"None\" or variant==\"none\":\n",
" x=inceptionV3(imgInput)\n",
" elif variant=='extra-fc'\n",
" elif variant=='extra-fc':\n",
" x=inceptionExtraFc(imgInput)\n",
" elif variant=='shallow':\n",
" x=inceptionShallow(imgInput) \n",
" elif variant=='very-shallow':\n",
" elif variant=='very-shallow' or variant=='veryshallow':\n",
" x=inceptionVeryShallow(imgInput)\n",
" \n",
" else:\n",
" assert False, \"Please enter the correct model variant\"\n",
" \n",
" \n",
" model = Model(imgInput, x, name='inception_v3')\n",
......@@ -641,8 +622,13 @@
"\n",
"if len(sys.argv)>=8:\n",
" CELLS_PER_FRAME=int(sys.argv[7])\n",
" \n",
"trainAndTestForVideo(inceptionNet(sys.argv[2]),DATASET,NO_FRAMES,videoFileFormat=VIDEO_FILE_FORMAT,testSplit=TEST_SPLIT)\n",
"\n",
"if len(sys.argv)>=9:\n",
" trainAndTestForVideo(inceptionNet(sys.argv[1]),DATASET,NO_FRAMES,\\\n",
" videoFileFormat=VIDEO_FILE_FORMAT,testSplit=TEST_SPLIT,resultFile=sys.argv[8])\n",
"else:\n",
" trainAndTestForVideo(inceptionNet(sys.argv[1]),DATASET,NO_FRAMES,\\\n",
" videoFileFormat=VIDEO_FILE_FORMAT,testSplit=TEST_SPLIT)\n",
"\n",
"# python inceptionV3.py video/tvstatic-ideal-3x3.npz 1 0.2 1000 1 9\n",
"# python inceptionV3.py video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame"
......
......@@ -4,8 +4,8 @@
# In[ ]:
# python inception.py None|shallow|extra-fc video/tvstatic-ideal-3x3.npz 1 0.2 1000 1 9
# python inception.py None|shallow|extra-fc video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame
# python inception.py shallow video/tvstatic-ideal-3x3.npz 1 0.2 100 5 9 results.npz
# python inception.py {None|shallow|extra-fc} video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame results.npz
# In[ ]:
......@@ -156,7 +156,7 @@ def oneIter(model,xTrain,yTrain,xTest,yTest,hist):
# In[ ]:
def trainAndTestForVideo(model,fileName,noFrames,framesToSkip=0,videoFileFormat='.avi',testSplit=0.1):
def trainAndTestForVideo(model,fileName,noFrames,framesToSkip=0,videoFileFormat='.avi',testSplit=0.1,resultFile=None):
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Starting new video file\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>{}".format(fileName))
FILE_NAME=fileName
FILE_NAME_VIDEO=FILE_NAME+videoFileFormat
......@@ -194,16 +194,20 @@ def trainAndTestForVideo(model,fileName,noFrames,framesToSkip=0,videoFileFormat=
xTrain, xTest, yTrain, yTest= train_test_split(dataX, dataY, test_size=testSplit)
dataX=None
dataY=None
print("SIZES: xTrain {}, yTrain {}, xTest {}, yTest {}".format(xTrain.shape,yTrain.shape,xTest.shape,yTest.shape))
print("SIZES: xTrain {}, yTrain {}, xTest {}, yTest {}". format(xTrain.shape,yTrain.shape,xTest.shape,yTest.shape))
if INTERACTIVE: iters=int(input("How many iters more? : "))
else: iters=EPOCHS
while iters>0:
hist=oneIter(model,xTrain,yTrain,xTest,yTest,hist)
print("Iter {} of {} complete".format(len(hist['testAcc']),EPOCHS))
iters-=1
if iters==0:
if INTERACTIVE: iters=int(input("How many iters more? : "))
if resultFile!=None:
np.savez(resultFile, yPredTest=np.round(model.predict(xTest)).astype(np.uint8),yPredTrain=np.round(model.predict(xTrain)).astype(np.uint8),yTrueTest=yTest,yTrueTrain=yTrain, trainAcc=hist['trainAcc'],trainCost=hist['trainCost'],testAcc=hist['testAcc'],testCost=hist['testCost'])
print(hist)
......@@ -489,41 +493,14 @@ def inceptionShallow(imgInput):
def inceptionVeryShallow(imgInput):
'''
gihanj (16/04/2019): Vu, please complete this.
'''
print(imgInput.shape)
x=None
# x=inceptionConeA(imgInput)
# print(x.shape)
# x=inceptionBlockA(x,64)
# print("After 3A",x.shape)
# x=inceptionConeB(x)
# print(x.shape)
# x=inceptionBlockB(x,128)
# print("After 1B",x.shape)
# x=inceptionBlockB(x,160)
# print("After 2B",x.shape)
# x=inceptionBlockB(x,160)
# print("After 3B",x.shape)
# x=inceptionBlockB(x,192)
# print("After 4B",x.shape)
# x=inceptionConeC(x)
# print(x.shape)
# x=inceptionBlockC(x)
# print("After 1C",x.shape)
# x=inceptionBlockC(x)
# print("After 2C",x.shape)
# x = AveragePooling2D(pool_size=(8, 8), strides=(8,8),name='avg_pool')(x)
# print(x.shape)
# x = Flatten()(x)
# print(x.shape)
# x = Dropout(0.25)(x)
# print(x.shape)
# x = Dense(CELLS_PER_FRAME, activation='sigmoid', name='predictions')(x)
# print(x.shape)
x=inceptionConeA(imgInput)
x=inceptionBlockA(x,64)
x = layers.AveragePooling2D(name='avg_pool')(x)
x = Flatten()(x)
x = Dropout(0.25)(x)
x = Dense(CELLS_PER_FRAME, activation='sigmoid', name='predictions')(x)
return x
......@@ -531,18 +508,19 @@ def inceptionVeryShallow(imgInput):
def inceptionNet(variant=None):
if DEBUG: print("DEBUG: Model vairant={}.".format(variant))
imgInput = Input(shape=(299,299,3))
x=None
if variant==None or variant=="None" or variant=="none":
x=inceptionV3(imgInput)
elif variant=='extra-fc'
elif variant=='extra-fc':
x=inceptionExtraFc(imgInput)
elif variant=='shallow':
x=inceptionShallow(imgInput)
elif variant=='very-shallow':
x=inceptionVeryShallow(imgInput)
else:
assert False, "Please enter the correct model variant"
model = Model(imgInput, x, name='inception_v3')
......@@ -579,8 +557,11 @@ if len(sys.argv)>=7:
if len(sys.argv)>=8:
CELLS_PER_FRAME=int(sys.argv[7])
trainAndTestForVideo(inceptionNet(sys.argv[2]),DATASET,NO_FRAMES,videoFileFormat=VIDEO_FILE_FORMAT,testSplit=TEST_SPLIT)
if len(sys.argv)>=9:
trainAndTestForVideo(inceptionNet(sys.argv[1]),DATASET,NO_FRAMES, videoFileFormat=VIDEO_FILE_FORMAT,testSplit=TEST_SPLIT,resultFile=sys.argv[8])
else:
trainAndTestForVideo(inceptionNet(sys.argv[1]),DATASET,NO_FRAMES, videoFileFormat=VIDEO_FILE_FORMAT,testSplit=TEST_SPLIT)
# python inceptionV3.py video/tvstatic-ideal-3x3.npz 1 0.2 1000 1 9
# python inceptionV3.py video/tvstatic-ideal-3x3.npz CUDA Test-split Frames Iters cellsPerFrame
......
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