Spaces:
Runtime error
Runtime error
File size: 1,092 Bytes
1f765c5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import os
import cv2
import numpy as np
def get_lol_dataset_samples(base_path="dataset/LOLdataset"):
"""
Crawls the LOL dataset directory for low-light and normal-light image pairs.
LOL dataset usually has 'our485/low' and 'our485/high' subfolders.
"""
low_path = os.path.join(base_path, "low")
high_path = os.path.join(base_path, "high")
if not os.path.exists(low_path):
return []
samples = []
for file_name in os.listdir(low_path):
if file_name.endswith(('.png', '.jpg', '.jpeg')):
samples.append({
"name": file_name,
"low": os.path.join(low_path, file_name),
"high": os.path.join(high_path, file_name)
})
return samples
def load_lol_pair(sample):
"""
Loads a pair of images from the LOL dataset.
"""
low_img = cv2.imread(sample['low'])
high_img = cv2.imread(sample['high'])
low_img = cv2.cvtColor(low_img, cv2.COLOR_BGR2RGB)
high_img = cv2.cvtColor(high_img, cv2.COLOR_BGR2RGB)
return low_img, high_img
|