Compare commits
2 Commits
12bc6aeee7
...
67016c4e9a
| Author | SHA1 | Date | |
|---|---|---|---|
| 67016c4e9a | |||
| 69c3634731 |
@@ -672,13 +672,18 @@ def create_example_config(config_file: str):
|
|||||||
def read_image_paths(image_list_file: str) -> List[str]:
|
def read_image_paths(image_list_file: str) -> List[str]:
|
||||||
"""从文件读取图片路径列表"""
|
"""从文件读取图片路径列表"""
|
||||||
paths = []
|
paths = []
|
||||||
|
not_images = []
|
||||||
try:
|
try:
|
||||||
with open(image_list_file, "r", encoding="utf-8") as f:
|
with open(image_list_file, "r", encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line and not line.startswith("#"):
|
if line and not line.startswith("#"):
|
||||||
|
if not line.endswith((".png", ".jpeg", ".jpg", ".gif", ".webp")):
|
||||||
|
not_images.append(line)
|
||||||
|
else:
|
||||||
paths.append(line)
|
paths.append(line)
|
||||||
print(f"从文件读取 {len(paths)} 个图片路径")
|
print(f"从文件中读取到 {len(paths)} 个图片路径数据行")
|
||||||
|
print(f"从文件中读取到 {len(not_images)} 个非图片路径数据行")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"读取图片路径文件失败 {image_list_file}: {e}")
|
print(f"读取图片路径文件失败 {image_list_file}: {e}")
|
||||||
return paths
|
return paths
|
||||||
@@ -889,9 +894,14 @@ def main():
|
|||||||
print("请使用 --input 指定文件或直接在命令行提供路径")
|
print("请使用 --input 指定文件或直接在命令行提供路径")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
origin_paths = image_paths
|
||||||
# 去重
|
# 去重
|
||||||
image_paths = list(set(image_paths))
|
image_paths = list(set(image_paths))
|
||||||
|
|
||||||
|
repeats = len(origin_paths) - len(image_paths)
|
||||||
|
if repeats > 0:
|
||||||
|
print(f"从文件中读取到 {repeats} 个重复图片路径数据行")
|
||||||
|
|
||||||
# 创建并运行迁移器
|
# 创建并运行迁移器
|
||||||
migrator = ImageMigrator(
|
migrator = ImageMigrator(
|
||||||
source_config=source_config,
|
source_config=source_config,
|
||||||
|
|||||||
Reference in New Issue
Block a user