// If the file is in a totally different tree from the cwd,
// then leave the path as absolute. Otherwise, override with the relative path.
if relPath is not None and len(os.path.commonprefix([cwd, absPath])) > 1:
data_path = relPath
if DatasetInfo.fileHasInternalPaths(data_path):
datasetNames = DatasetInfo.getPossibleInternalPathsFor(absPath)
if len(datasetNames) == 0:
raise RuntimeError(f"{file_extension} file {data_path} has no image datasets")
After Change
try:
data_path = filePath.absolute().relative_to(cwd)
except ValueError:
data_path = filePath.absolute()
if DatasetInfo.fileHasInternalPaths(data_path):
datasetNames = DatasetInfo.getPossibleInternalPathsFor(absPath)
if len(datasetNames) == 0: