viveknarayan commited on
Commit
47fccb3
·
1 Parent(s): 7f7f8bf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ model = from_pretrained_keras("keras-io/lowlight-enhance-mirnet", compile=False)
8
+
9
+ def infer(original_image):
10
+ image = keras.utils.img_to_array(original_image)
11
+ image = image.astype("float32") / 255.0
12
+ image = np.expand_dims(image, axis=0)
13
+ output = model.predict(image)
14
+ output_image = output[0] * 255.0
15
+ output_image = output_image.clip(0, 255)
16
+ output_image = output_image.reshape(
17
+ (np.shape(output_image)[0], np.shape(output_image)[1], 3)
18
+ )
19
+ output_image = np.uint32(output_image)
20
+ return output_image
21
+ examples=['1o.png','2o.png','3o.png']
22
+ iface = gr.Interface(
23
+ fn=infer,
24
+ title="Low Light Image Enhancement",
25
+ description = "Keras Implementation of MIRNet model for lighting up a dark image 🌆🎆",
26
+ inputs=[gr.inputs.Image(label="image", type="pil")],
27
+ outputs="image",
28
+ examples=examples,
29
+ cache_examples=True,
30
+ article = "Authors: <a href=\"https://github.com/Uviveknarayan\">Vivek Narayan</a>, <a href=\"https://github.com/chiranjan-7\">Chiranjan</a>,<a href=\"https://github.com/GangaSrujan\">Srujan</a>,<a href=\"https://github.com/RohanPawar3399\">Rohan Pawar</a>,<a href=\"https://github.com/pavankarthik77\">Pavan Karthik</a>").launch(enable_queue=True)