Example #1
0
def output_results(log_path, batch_id, epoch, input_xyz, skel_xyz, skel_r, A_init=None, A_final=None):
    batch_size = skel_xyz.size()[0]
    batch_id = batch_id.numpy()
    input_xyz_save = input_xyz.detach().cpu().numpy()
    skel_xyz_save = skel_xyz.detach().cpu().numpy()
    skel_r_save = skel_r.detach().cpu().numpy()

    if A_init is not None:
        A_init_save = A_init.detach().cpu().numpy()
    if A_final is not None:
        A_final_save = A_final.detach().cpu().numpy()

    for i in range(batch_size):

        save_name_input = log_path + str(batch_id[i]) + "_input.off"
        save_name_sphere = log_path + str(batch_id[i]) + "_sphere_" + str(epoch) + ".obj"
        save_name_center = log_path + str(batch_id[i]) + "_center_" + str(epoch) + ".off"
        
        save_name_A_init = log_path + str(batch_id[i]) + "_graph_init_" + str(epoch) + ".obj"
        save_name_A_final = log_path + str(batch_id[i]) + "_graph_final_" + str(epoch) + ".obj"
        
        rw.save_off_points(input_xyz_save[i], save_name_input)
        rw.save_spheres(skel_xyz_save[i], skel_r_save[i], save_name_sphere)
        rw.save_off_points(skel_xyz_save[i], save_name_center)

        if A_init is not None:
            rw.save_graph(skel_xyz_save[i], A_init_save[i], save_name_A_init)
        if A_final is not None:
            rw.save_graph(skel_xyz_save[i], A_final_save[i], save_name_A_final)
Example #2
0
def ToJsonData_Q(Q_ID, mode="R"):
    dataPath = "../WebCrawler/Data/Zhihu_GZ_Q.json"
    jsonData = json.loads(FileRW.Rfile(dataPath))
    is_inData = str(Q_ID) in jsonData
    if is_inData:
        print(str(Q_ID) + " 发现重复项")
        return False
    if mode == "W":
        jsonData[str(Q_ID)] = 1
        strJSON = json.dumps(jsonData, ensure_ascii=False)
        if strJSON:
            FileRW.Wfile(dataPath, strJSON)
    return True  #表示通过,没有发现相同项
Example #3
0
def ToJsonData_U(L_U_ID):
    dataPath = "../WebCrawler/Data/Zhihu_GZ_U.json"
    jsonData = json.loads(FileRW.Rfile(dataPath))

    for U_ID in L_U_ID[:]:
        is_inData = str(U_ID) in jsonData
        if is_inData:
            print(str(U_ID) + " 是重复项")
            L_U_ID.remove(U_ID)
            continue

    if not L_U_ID: return L_U_ID
    for U_ID in L_U_ID[:]:  #增加进去
        jsonData[str(U_ID)] = 1
        strJSON = json.dumps(jsonData, ensure_ascii=False)
        if strJSON:
            FileRW.Wfile(dataPath, strJSON)
    return L_U_ID
Example #4
0
def output_results(log_path, batch_id, input_xyz, skel_xyz, skel_r, skel_faces,
                   skel_edges, A_mesh):

    batch_size = skel_xyz.size()[0]
    batch_id = batch_id.numpy()
    input_xyz_save = input_xyz.detach().cpu().numpy()
    skel_xyz_save = skel_xyz.detach().cpu().numpy()
    skel_r_save = skel_r.detach().cpu().numpy()

    for i in range(batch_size):

        save_name_input = log_path + str(batch_id[i]) + "_input.off"
        save_name_sphere = log_path + str(batch_id[i]) + "_sphere" + ".obj"
        save_name_center = log_path + str(batch_id[i]) + "_center" + ".off"
        save_name_f = log_path + str(batch_id[i]) + "_skel_face" + ".obj"
        save_name_e = log_path + str(batch_id[i]) + "_skel_edge" + ".obj"
        save_name_A_mesh = log_path + str(batch_id[i]) + "_mesh_graph" + ".obj"

        rw.save_off_points(input_xyz_save[i], save_name_input)
        rw.save_spheres(skel_xyz_save[i], skel_r_save[i], save_name_sphere)
        rw.save_off_points(skel_xyz_save[i], save_name_center)
        rw.save_skel_mesh(skel_xyz_save[i], skel_faces[i], skel_edges[i],
                          save_name_f, save_name_e)
        rw.save_graph(skel_xyz_save[i], A_mesh[i], save_name_A_mesh)
Example #5
0

if __name__ == "__main__":
    #parse arguments
    args = parse_args()
    pc_list_file = args.pc_list_file
    data_root = args.data_root
    point_num = args.point_num
    skelpoint_num = args.skelpoint_num
    gpu = args.gpu
    load_skelnet_path = args.load_skelnet_path
    load_gae_path = args.load_gae_path
    save_result_path = args.save_result_path

    #create folders
    rw.check_and_create_dirs([save_result_path])

    #load networks
    model_skel = SkelPointNet(num_skel_points=skelpoint_num,
                              input_channels=0,
                              use_xyz=True)
    model_gae = LinkPredNet()

    if torch.cuda.is_available():
        os.environ['CUDA_VISIBLE_DEVICES'] = gpu
        print("GPU Number:", torch.cuda.device_count(), "GPUs!")
        model_skel.cuda()
        model_skel.eval()
        model_gae.cuda()
        model_gae.eval()
    else:
Example #6
0
 def __getitem__(self, index):
     data_pc = rw.load_ply_points(self.data_folder + self.data_id[index] + '.ply', expected_point=self.point_num)
     return index, data_pc
Example #7
0
 def __init__(self):
     #self.browser = webdriver.Firefox(executable_path='C:\Program Files\Mozilla Firefox\geckodriver.exe')
     os.environ['MOZ_HEADLESS'] = '1'
     self.browser = webdriver.Firefox()
     self.base_url = u'http://twitter.com/search?'
     self.fileRW = FileRW.FileRW()
Example #8
0
if __name__ == "__main__":
    #parse arguments
    args = parse_args()
    pc_list_file = args.pc_list_file
    data_root = args.data_root
    point_num = args.point_num
    skelpoint_num = args.skelpoint_num
    gpu = args.gpu
    save_net_path = args.save_net_path
    save_net_iter = args.save_net_iter
    save_log_path = args.save_log_path
    save_result_path = args.save_result_path
    save_result_iter = args.save_result_iter

    #create folders
    rw.check_and_create_dirs([save_net_path, save_log_path, save_result_path])

    #intialize networks
    model_skel = SkelPointNet(num_skel_points=skelpoint_num,
                              input_channels=0,
                              use_xyz=True)
    model_gae = LinkPredNet()
    optimizer_skel = torch.optim.Adam(model_skel.parameters(), lr=conf.LR_SPN)
    optimizer_gae = torch.optim.Adam(model_gae.parameters(), lr=conf.LR_GAE)

    TIMESTAMP = "{0:%Y-%m-%dT%H-%M-%S/}".format(datetime.now())
    tb_writer = SummaryWriter(save_log_path + TIMESTAMP)

    if torch.cuda.is_available():
        os.environ['CUDA_VISIBLE_DEVICES'] = gpu
        print("GPU Number:", torch.cuda.device_count(), "GPUs!")
Example #9
0
def output_results(log_path,
                   batch_id,
                   input_xyz,
                   skel_xyz,
                   skel_r,
                   skel_faces,
                   skel_edges,
                   A_init=None,
                   A_pred=None,
                   A_final=None):
    batch_size = skel_xyz.size()[0]
    batch_id = batch_id.numpy()
    input_xyz_save = input_xyz.detach().cpu().numpy()
    skel_xyz_save = skel_xyz.detach().cpu().numpy()
    skel_r_save = skel_r.detach().cpu().numpy()

    if A_init is not None:
        A_init_save = A_init.detach().cpu().numpy()
    if A_pred is not None:
        A_pred_save = A_pred.detach().cpu().numpy()
    if A_final is not None:
        A_final_save = A_final.detach().cpu().numpy()

    for i in range(batch_size):

        save_name_input = log_path + str(batch_id[i]) + "_input.off"
        save_name_sphere = log_path + str(batch_id[i]) + "_sphere" + ".obj"
        save_name_center = log_path + str(batch_id[i]) + "_center" + ".off"
        save_name_f = log_path + str(batch_id[i]) + "_face" + ".obj"
        save_name_e = log_path + str(batch_id[i]) + "_edge" + ".obj"
        save_name_A_init = log_path + str(batch_id[i]) + "_graph_init" + ".obj"
        save_name_A_pred = log_path + str(batch_id[i]) + "_graph_pred" + ".obj"
        save_name_A_final = log_path + str(
            batch_id[i]) + "_graph_final" + ".obj"

        rw.save_off_points(input_xyz_save[i], save_name_input)
        rw.save_spheres(skel_xyz_save[i], skel_r_save[i], save_name_sphere)
        rw.save_off_points(skel_xyz_save[i], save_name_center)
        rw.save_skel_mesh(skel_xyz_save[i], skel_faces[i], skel_edges[i],
                          save_name_f, save_name_e)

        if A_init is not None:
            rw.save_graph(skel_xyz_save[i], A_init_save[i], save_name_A_init)
        if A_pred is not None:
            rw.save_graph(skel_xyz_save[i], A_pred_save[i], save_name_A_pred)
        if A_final is not None:
            rw.save_graph(skel_xyz_save[i], A_final_save[i], save_name_A_final)