if __name__ == '__main__': """A simple demo showing how to run decafnet.""" from decaf.util import smalldata, visualize logging.getLogger().setLevel(logging.INFO) if len(sys.argv) == 1: car = smalldata.car() else: print "Using " + sys.argv[1] car = imread(sys.argv[1]) Decaf = False if Decaf: from kitnet import DecafNet as KitNet kit_net = KitNet() # print car.shape car = car.reshape((40,40,1)) scores = kit_net.classify(car) print 'Is car ? prediction:', kit_net.top_k_prediction(scores, 1) car_conv3 = kit_net.feature("conv3_neuron_cudanet_out") #conv3_cudanet_out mid_convs = car_conv3.reshape((car_conv3.shape[0],-1)) else: os.chdir("E:/2013/cuda-convnet/trunk") # sys.path.append("E:/2013/cuda-convnet/trunk") from show_pred import model as car_model scores = car_model.show_predictions(car) print 'Is car ? prediction:', scores[-1]
img = r.ReadAsArray(cx ,cy , w, h) img = img.swapaxes(0,2).swapaxes(0,1) img = rgb2gray(img) img = resize(img, (in_size, in_size), mode='wrap') return img_as_ubyte(img.reshape((in_size, in_size,1))), (cx,cy,w,h), max_len, env_area #io.imsave("segementation/%s_%s_%s_%s.png" % \ # (lu_offset_x, lu_offset_y, w, h), img) #tmp = cv2.imread("segementation/%s_%s_%s_%s.png" % \ # (lu_offset_x, lu_offset_y, w, h)) #return cv2.resize(tmp, (256,256), interpolation=cv2.INTER_LINEAR) #return resize(img, (256,256)) # 加载 decaf 和 classifier from kitnet import DecafNet as KitNet #from kit_angle_net import DecafNet as AngleNet net = KitNet() #angle = AngleNet() # 读取栅格图像 gdal.AllRegister() if len(sys.argv) != 3: print "Usage: segement_detection.py path_image_folder path_shp_folder" sys.exit() else: image_folder = sys.argv[1] shp_folder = sys.argv[2] #start = int(sys.argv[3]) #end = int(sys.argv[4]) shp_list = []
def load_net(net_file=None, meta_file=None): global NET, IMG, GRAY logging.info("Loading DecafNet...") NET = DecafNet(net_file,meta_file) logging.info("Loading default image...")