ShkShahid commited on
Commit
bc4445d
·
1 Parent(s): 575c0de

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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("keras-io/lowlight-enhance-mirnet", compile=False)
9
+ examples = ['examples/179.png', 'examples/493.png', 'examples/780.png']
10
+
11
+
12
+ def infer(original_image):
13
+ image = keras.utils.img_to_array(original_image)
14
+ image = image.astype("float32") / 255.0
15
+ image = np.expand_dims(image, axis=0)
16
+ output = model.predict(image)
17
+ output_image = output[0] * 255.0
18
+ output_image = output_image.clip(0, 255)
19
+ output_image = output_image.reshape(
20
+ (np.shape(output_image)[0], np.shape(output_image)[1], 3)
21
+ )
22
+ output_image = np.uint32(output_image)
23
+ return output_image
24
+
25
+ iface = gr.Interface(
26
+ fn=infer,
27
+ title="Auto-encoder_For_Image_Reconstruction",
28
+ description = "Keras Implementation Reconstructing Low Dynamic Range Images To High Dynamic Range Images 🌆🎆",
29
+ inputs=[gr.inputs.Image(label="image", type="pil", shape=(960, 640))],
30
+ outputs="image",
31
+ examples=examples,
32
+ #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>",
33
+ ).launch(enable_queue=True)