NotFoundError (see above for traceback): Unsucessful TensorSliceReader constructor: Failed to find any matching files for xxx://xxx
In ModelArts, user's data is stored in OBS buckets, but training jobs are running in containers. Therefore, users cannot access files in OBS buckets by accessing local paths.
If an error occurs when you read a file, you can use MoXing to copy data to a container and then access the data in the container. For details, see 1.
You can also read files based on the file type. For details, see Reading .json files, Reading .npy files, and Using the cv2 library to read files, and Using the torch package in the MXNet environment.
import moxing as mox mox.file.make_dirs('/cache/data_url') mox.file.copy_parallel('obs://bucket-name/data_url', '/cache/data_url')
json.loads(mox.file.read(json_path, binary=True))
np.load(mox.file.read(_SAMPLE_PATHS['rgb'], binary=True))
with mox.file.File(_SAMPLE_PATHS['rgb'], 'rb') as f: np.load(f)
cv2.imdecode(np.fromstring(mox.file.read(img_path), np.uint8), 1)
import os os.sysytem('pip install torch') import torch