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
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
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.
Answer # 1
readlines ()Reads including the newline character at the end of the line.
videos = [v.rstrip () for v in videos]You just have to remove the newline character.
Answer # 2
for video in videos:
At that time, there was a line break in the video.
Let's check what's in there.
You can use the strip function to remove whitespace before and after a string
- python - i want to add a line number to the data frame
- python - i want to open a file with an absolute path
- python - i want to read an image and display it
- python - i want to combine two dfs
- python - i want to find the mode of a pixel with a pixel value of 1 or more
- python - i want to pass a list as an argument of glob and repeat it
- python - i want to solve this problem
- python - i want the block to disappear when the ball hits the block
- python - i want to handle webdriverchrome ()
- python - avoid processing when duplicated
- python - i want to move images with pygame
- python - i want to scrape google news, but i can't
- python - i want to add an element to a double list
- python - i want to send a list of yahoo news rankings to line
- html - i want to pack the line break col of bootstrap on top
- python - i want to know how to keep outputting to csv
- python - i want to take 4 edges from the edge image
- java - i want to draw a ruled line with apachi poi
- python - i want to save all the contents in a csv file
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory