GCN-SLAMがpytorchをコンパイルしてTUMデータセットを実行するときに発生する問題

pytorch問題をコンパイルする

githubのプロセスに従ってpytorch(C ++)をコンパイルすると、問題が発生しました。最初は不完全なクローンコードの問題だと思いましたが、後でエラーメッセージを注意深く検索したところ、 pytorchのソースコードとcudaの関数名。競合が発生しました(私の環境cuda10.1は、githubからダウンロードしたpytorch1.0.1のsetup.pyに従って完全にコンパイルされています)。

データセットの問題

1つまたは2つのTUMデータセットをダウンロードした後、GCNでrun.shを実行したところ、起動できないことがわかりました。
最後に、解凍後、ファイル名を保存するためのdepth.txtファイルとrgb.txtファイルが含まれていることがわかります。コードは、ファイル名を介してフォルダーから読み取られた画像です。depth.txtとrgb.txtの内容ファイルは次のとおりです(小さな部分のみを入れてください):

# color images
# file: 'rgbd_dataset_freiburg3_long_office_household.bag'
# timestamp filename
1341847980.722988 rgb/1341847980.722988.png
1341847980.754743 rgb/1341847980.754743.png
1341847980.786856 rgb/1341847980.786856.png
1341847980.822978 rgb/1341847980.822978.png
1341847980.854676 rgb/1341847980.854676.png
1341847980.890728 rgb/1341847980.890728.png
1341847980.922978 rgb/1341847980.922978.png
# depth maps
# file: 'rgbd_dataset_freiburg3_long_office_household.bag'
# timestamp filename
1341847980.723020 depth/1341847980.723020.png
1341847980.754755 depth/1341847980.754755.png
1341847980.786879 depth/1341847980.786879.png
1341847980.822989 depth/1341847980.822989.png
1341847980.854690 depth/1341847980.854690.png
1341847980.890737 depth/1341847980.890737.png
1341847980.922989 depth/1341847980.922989.png

しかし、GCN run.shスタートアップファイルでは、スタートアップパラメータがassociation.txtで渡されます。ORBの着信パラメータのいくつかを調べた後、ここで渡されるassociation.txtは上記のrgb.txtである必要があります。深さ。txtマージの結果は次のとおりです。

1341847980.722988 rgb/1341847980.722988.png 1341847980.723020 depth/1341847980.723020.png
1341847980.754743 rgb/1341847980.754743.png 1341847980.754755 depth/1341847980.754755.png
1341847980.786856 rgb/1341847980.786856.png 1341847980.786879 depth/1341847980.786879.png
1341847980.822978 rgb/1341847980.822978.png 1341847980.822989 depth/1341847980.822989.png
1341847980.854676 rgb/1341847980.854676.png 1341847980.854690 depth/1341847980.854690.png
1341847980.890728 rgb/1341847980.890728.png 1341847980.890737 depth/1341847980.890737.png
1341847980.922978 rgb/1341847980.922978.png 1341847980.922989 depth/1341847980.922989.png
1341847980.954645 rgb/1341847980.954645.png 1341847980.954676 depth/1341847980.954676.png
1341847980.990699 rgb/1341847980.990699.png 1341847980.990724 depth/1341847980.990724.png
1341847981.022715 rgb/1341847981.022715.png 1341847981.022728 depth/1341847981.022728.png

データのフォーマット

オプション1:コードを変更する

必要なrgb.txtとdepth.txtが同時に渡されるため、run.shの最後に着信パラメーターを追加する必要があります。これにより、コードの読み取りイメージ部分に対応するコードも、次のようにする必要があります。変更されます。また、タイムスタンプに従って2つのtxtファイルのファイル名に事前に対応する必要があります(2つのtxtファイルの元のファイル名の数は同じではありません。つまり、2つのフォルダーの画像の数は同じではありません) )。この方法はより面倒であることを考慮して、以下の方法が採用されます。

解決策2:タイムスタンプに従ってrgb.txtとdepth.txtをスプライシングする

コード内のファイル名に従ってファイルを読み取る場合、txtの最初の3行のコメントが考慮されないため、問題が発生することに注意してください。したがって、受信txtファイルの最初の3行のコメントを削除する必要があります。つまり、タイムスタンプに従ってrgb.txtとdepth.txtがスプライスされた後の.txtファイルは、前のコメントを追加しないでください。タイムスタンプによるコードのスプライシングは次のとおりです。コードによって
生成されたassociation.txtを対応するデータセットフォルダーにコピーし、run.shを直接実行します。


def split_line(f_rgbd):
    rgbd_split = f_rgbd.read().split()
    index_to_delete = []
    for i in range(len(rgbd_split)):
        if i%2:
            index_to_delete.append(i)
    count = 0
    for index in index_to_delete:
        index = index - count
        rgbd_split.pop(index)
        count += 1
    return rgbd_split

def near_time_stamp(rgb_time_stamp, depth_time_stamp):
    """
    假设len(rgb_time_stamp)  >  len(depth_time_stamp)
    只需在rgb_time_stamp中取出len(depth_time_stamp)个元素即可
    """
    near_rgb_stamp = []
    for index in depth_time_stamp:
        min_value = 1000000000
        min_jndex = ''
        depth_float = float(index)
        for jndex in rgb_time_stamp:
            rgb_float = float(jndex)
            if abs(depth_float - rgb_float) < min_value:
                min_value = abs(depth_float - rgb_float)
                min_jndex = jndex
        near_rgb_stamp.append(min_jndex)
    return near_rgb_stamp


if __name__ == '__main__':

    f_rgb = open("rgb.txt","r")
    f_depth = open("depth.txt","r")
    f_association = open('association.txt','w',encoding='utf-8')
    data_depth = f_depth.readlines()
    f_depth.seek(0,0)

    # 切分出时间戳
    rgb_time_stamp = split_line(f_rgb)
    depth_time_stamp = split_line(f_depth)

    # 寻找最近时间戳
    rgb_time_stamp = near_time_stamp(rgb_time_stamp, depth_time_stamp)
    
    # 将rgb_time_stamp与depth_time_stamp对应行拼接起来
    for i in range(len(rgb_time_stamp)):
        str_association = rgb_time_stamp[i] + " " \
                            + "rgb/" + rgb_time_stamp[i] + ".png" + " " \
                            + data_depth[i]
        f_association.write(str_association)

    f_rgb.close()
    f_depth.close()
    f_association.close()

おすすめ

転載: blog.csdn.net/qq_38337524/article/details/112648057