IR_expeiment / PART2 /PromptIR /make_rain.py
hugaagg's picture
Upload folder using huggingface_hub
2ecc7ab verified
import cv2
import numpy as np
import os
# 1. 造背景 (灰色)
img = np.full((512, 512, 3), 200, dtype=np.uint8)
# 2. 画点东西 (防止太单调被当成纯色处理)
cv2.rectangle(img, (100, 200), (400, 400), (100, 100, 100), -1) # 房子
cv2.putText(img, "PromptIR Test", (120, 300), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
# 3. 人工降雨 (画白色斜线)
for i in range(300):
x = np.random.randint(0, 512)
y = np.random.randint(0, 512)
length = np.random.randint(10, 30)
cv2.line(img, (x, y), (x+5, y+length), (180, 180, 180), 1)
# 4. 保存
os.makedirs("test/demo", exist_ok=True)
input_path = "test/demo/rainy.png"
cv2.imwrite(input_path, img)
print(f"✅ 下雨图已生成: {input_path}")