Skip to content

An issue caused by a path separator(一个分隔符导致的问题) #8

@payhuan

Description

@payhuan

In the datatrain.py code, the split("/") method in getitem assumes the path separator is /. However, on Windows systems, the path separator is .

Solution
You can use Python's os.path or pathlib modules to handle path separators, ensuring the code works correctly across different operating systems.

Code Modification
Replace the path splitting in getitem with a cross-platform approach:

def getitem(self, item):
# Load egocentric image
exocentric_image_path = self.image_list[item]

# Use os.path.split() to handle path splitting
names = exocentric_image_path.split(os.sep)  # Change to os.sep

datatrain.py代码中__getitem__的 split("/") 假定路径分隔符是 /,但在 Windows 系统中,路径分隔符是 \。

修复方法
可以使用 Python 的 os.path 或 pathlib 模块来处理路径分隔符,保证代码在不同操作系统下都能正确运行。

修改代码
getitem 中的路径分割替换为跨平台的方式:

def getitem(self, item):
# load egocentric image
exocentric_image_path = self.image_list[item]

# 使用 os.path.split() 处理路径分割
names = exocentric_image_path.split(os.sep)  # 修改为 os.sep

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions