hbpkillerX commited on
Commit
ee38b9c
Β·
1 Parent(s): 1af7275
Files changed (1) hide show
  1. model.py +32 -0
model.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
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="Low Light Image Enhancement",
28
+ description = "Keras Implementation of MIRNet model for light up the dark image πŸŒ†πŸŽ†",
29
+ inputs=[gr.inputs.Image(label="image", type="pil", shape=(960, 640))],
30
+ outputs="image",
31
+ cache_examples=True,
32
+ )