Spaces:
Runtime error
Runtime error
import numpy as np | |
import gradio as gr | |
from PIL import Image | |
import keras | |
from huggingface_hub import from_pretrained_keras | |
model = from_pretrained_keras("Harveenchadha/low-light-image-enhancement", compile=False) | |
examples = ['examples/179.png', 'examples/493.png', 'examples/780.png'] | |
def infer(original_image): | |
image = keras.preprocessing.image.img_to_array(original_image) | |
image = image.astype("float32") / 255.0 | |
image = np.expand_dims(image, axis=0) | |
output_image = model.predict(image) | |
output_image = tf.cast((output_image[0, :, :, :] * 255), dtype=np.uint8) | |
output_image = Image.fromarray(output_image.numpy()) | |
return output_image | |
iface = gr.Interface( | |
fn=infer, | |
title="Low Light Image Enhancement", | |
description = "Keras Implementation of MIRNet model for light up the dark image ππ", | |
inputs=[gr.inputs.Image(label="image", type="pil")], | |
outputs="image", | |
examples=examples, | |
article = "Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>. Based on the keras example from <a href=\"https://keras.io/examples/vision/mirnet/\">Soumik Rakshit</a>", | |
).launch(debug=True) |