from PIL import Image import numpy as np from pathlib import Path # 获取项目根目录 current_file = Path(__file__) # D:\1\1\style_transfer_ai1\tests\test_core.py project_root = current_file.parent.parent # 上两级:tests -> style_transfer_ai1 # 图片路径 img_path = project_root / "data" / "raw" / "content.jpg" print(f"📁 正在加载图片: {img_path}") # 加载图像 img = Image.open(img_path) img_array = np.array(img) # 保存原图(测试是否能写入) output_path = project_root / "data" / "processed" / "test_result.jpg" Image.fromarray(img_array).save(output_path) print("✅ 测试成功!")