def doClassifyFile(self, tpath, fname): rstParms = np.array([]) tpath = "%s/%s" % (tpath, fname) if os.path.exists(tpath): tdata1 = np.load(tpath) timgs32 = tdata1['imgs'] parms = tdata1['parms'] #fs2n = 1.087/props[:,12].astype(np.float) if timgs32.shape[0] > 0: timgs = getImgStamp(timgs32, size=self.imgSize, padding=1, transMethod='none') preY = self.model.predict(timgs, batch_size=128) timgs2 = getImgStamp(timgs32, size=self.imgSize2, padding=1, transMethod='none') preY2 = self.model2.predict(timgs2, batch_size=128) predProbs = preY[:, 1] predProbs2 = preY2[:, 1] predProbsJoin = ~((predProbs > self.pbb_threshold) & (predProbs2 > self.pbb_threshold)) predProbs[predProbsJoin] = 0 predProbs = predProbs.reshape([predProbs.shape[0], 1]) rstParms = np.concatenate((parms, predProbs), axis=1) return rstParms
def doClassifyFile(self, tpath, fname): rstParms = np.array([]) tpath0 = "%s/%s" % (tpath, fname) if len(fname) > 0 and os.path.exists(tpath0): tdata1 = np.load(tpath0) timgs32 = tdata1['imgs'] parms = tdata1['parms'] #fs2n = 1.087/props[:,12].astype(np.float) if timgs32.shape[0] > 0: timgs = getImgStamp(timgs32, size=self.imgSize, padding=1, transMethod='none') preY = self.model.predict(timgs, batch_size=128) predProbs = preY[:, 1] predProbs = predProbs.reshape([predProbs.shape[0], 1]) rstParms = np.concatenate((parms, predProbs), axis=1) self.log.info("total %d subImgs, %d is valid and classified" % (timgs32.shape[0], timgs.shape[0])) return rstParms
def realDataTest(): imgSize = 8 pbb_threshold = 0.5 workPath = "/home/xy/Downloads/myresource/deep_data2/simot/train_20190102" model = load_model("%s/model_128_5_RealFOT_8.h5"%(workPath)) #dataPath = '/home/xy/Downloads/myresource/deep_data2/simot/G181208_C03490' dataPath = '/home/xy/Downloads/myresource/deep_data2/simot/data_190107/subImg' flist = os.listdir(dataPath) flist.sort() for tfilename in flist: #G034_mon_objt_181208T10463819 #G044_mon_objt_181208T10391696 #G024_mon_objt_181206T12154991_otimg if tfilename.find('G044_mon_objt_180416T12263444_totimg')==-1: continue print(tfilename) tpath = "%s/%s"%(dataPath, tfilename) tdata1 = np.load(tpath) #timg32s = tdata1['fot'] timg32s = tdata1['imgs'] props = tdata1['parms'] #fs2n = 1.087/props[:,12].astype(np.float) timgs = getImgStamp(timg32s, size=imgSize, padding = 0, transMethod='none') print(timgs.shape) preY = model.predict(timgs, batch_size=128) trueIdx = preY[:, 1] > pbb_threshold falseIdx = preY[:, 1] <= pbb_threshold trueNum = np.array(trueIdx, dtype = "int").sum() falseNum = np.array(falseIdx, dtype = "int").sum() print("total %d, true %d, false %d"%(timgs.shape[0], trueNum, falseNum)) trueImgs = timg32s[trueIdx] trueProps = props[trueIdx] truePreYs = preY[trueIdx] falseImgs = timg32s[falseIdx] falseProps = props[falseIdx] falsePreYs = preY[falseIdx] print("\n\n***********************") print("%d images classified as False"%(trueNum)) showImage(trueImgs, trueProps, truePreYs, 'OT', showNum=1000) print("\n\n***********************") print("%d images classified as False"%(falseNum)) showImage(falseImgs, falseProps, falsePreYs, 'FOT', showNum=100)
def doClassifyFile(self, tpath, fname): try: #print("start doClassifyFile") rstParms = np.array([]) obsUtc = '' tpath0 = "%s/%s" % (tpath, fname) #print(tpath0) if len(fname) > 0 and os.path.exists(tpath0): #print("start doClassifyFile 1") tdata1 = np.load(tpath0) timgs32 = tdata1['imgs'] parms = tdata1['parms'] obsUtc = tdata1['obsUtc'] #print(timgs32.shape) #fs2n = 1.087/props[:,12].astype(np.float) if timgs32.shape[0] > 0: timgs = getImgStamp(timgs32, size=self.imgSize, padding=1, transMethod='none') #print(timgs.shape) preY = self.model.predict(timgs, batch_size=128) #model = load_model(self.modelPath,custom_objects={'concatenate':keras.layers.concatenate}) #preY = model.predict(timgs, batch_size=128) #print(preY.shape) predProbs = preY[:, 1] predProbs = predProbs.reshape([predProbs.shape[0], 1]) rstParms = np.concatenate((parms, predProbs), axis=1) tstr = "total %d subImgs, %d is valid and classified" % ( timgs32.shape[0], timgs.shape[0]) self.log.info(tstr) print(tstr) #print("end doClassifyFile") except Exception as e: tstr = traceback.format_exc() print("doClassifyFile") print(tstr) self.log.error(tstr) return rstParms, obsUtc