Harveenchadha commited on
Commit
399a43b
β€’
1 Parent(s): cea4909

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ from PIL import Image
4
+ import keras
5
+ from huggingface_hub import from_pretrained_keras
6
+
7
+
8
+ model = from_pretrained_keras("Harveenchadha/low-light-image-enhancement", compile=False)
9
+ examples = ['examples/179.png', 'examples/493.png', 'examples/780.png']
10
+
11
+
12
+ def infer(original_image):
13
+ image = keras.preprocessing.image.img_to_array(original_image)
14
+ image = image.astype("float32") / 255.0
15
+ image = np.expand_dims(image, axis=0)
16
+ output_image = model.predict(image)
17
+ output_image = tf.cast((output_image[0, :, :, :] * 255), dtype=np.uint8)
18
+ output_image = Image.fromarray(output_image.numpy())
19
+ return output_image
20
+
21
+ iface = gr.Interface(
22
+ fn=infer,
23
+ title="Low Light Image Enhancement",
24
+ description = "Keras Implementation of MIRNet model for light up the dark image πŸŒ†πŸŽ†",
25
+ inputs=[gr.inputs.Image(label="image", type="pil")],
26
+ outputs="image",
27
+ examples=examples,
28
+ 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>",
29
+ ).launch(debug=True)