Home>

The file cannot be read because the file path cannot be set properly.

The code is below.

from os.path import join, realpath, dirname, exists, isdir
from os import listdir
import logging
import glob
import numpy as np
import json
import os
from collections import OrderedDict
list_path = join ("/ home/user/abc/ImageSets",'all.txt')
The contents of # all.txt are described below
videos = open (list_path,'r'). readlines ()
for video in videos:
    video_path = os.path.join ("/ home/user/abc/GroundTruth", video)
    gt_path = os.path.join (video_path,'groundtruth.txt')
    gt = np.loadtxt (gt_path, delimiter =','). astype (np.float64)

The error code is as follows.

OSError:/home/user/abc/GroundTruth/bird
/groundtruth.txt not found.

With this code, gt_path is broken and
/ home/user/SiamMask/abc/GroundTruth/bird
/groundtruth.txt
It looks like.
If a line break occurs, is it not read as a file path?
At the last line of code (gt = np.loadtxt (gt_path, delimiter =','). Astype (np.float64) #m)
The error will be spit out.

To avoid this error
gt_path is
/home/user/SiamMask/abc/GroundTruth/bird/groundtruth.txt
Where should I change to get this output?

The contents of all.txt are as follows

bird
tomato
panda
rabbit
car


This is a text file in which nouns such as are listed with line breaks.

If anyone knows anything, please let me know.