Skip to content

Instantly share code, notes, and snippets.

@agtbaskara
Created March 17, 2023 06:58
Show Gist options
  • Save agtbaskara/312b4e0253a2aa7b10fde5e3731b3618 to your computer and use it in GitHub Desktop.
Save agtbaskara/312b4e0253a2aa7b10fde5e3731b3618 to your computer and use it in GitHub Desktop.
Enchance images in a directory using EnlightenGAN
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