Created
March 17, 2023 06:58
-
-
Save agtbaskara/312b4e0253a2aa7b10fde5e3731b3618 to your computer and use it in GitHub Desktop.
Enchance images in a directory using EnlightenGAN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import cv2 | |
from enlighten_inference import EnlightenOnnxModel | |
from tqdm import tqdm | |
# Set input and output path | |
input_path = 'image_rgb' | |
output_path = 'image_enlighten' | |
# Create output folder | |
os.makedirs(output_path, exist_ok=True) | |
# Get file list | |
filelist = os.listdir(input_path) | |
filelist.sort() | |
# Load model | |
model = EnlightenOnnxModel() | |
# Process images | |
for filename in tqdm(filelist): | |
img = cv2.imread(os.path.join(input_path, filename)) | |
processed = model.predict(img) | |
cv2.imwrite(os.path.join(output_path, filename), processed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment