You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
630 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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("✅ 测试成功!")