Ryuzaki007 commited on
Commit
ed9e1a7
1 Parent(s): 7cfad61

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("keras-io/lowlight-enhance-mirnet", compile=False)
9
+
10
+
11
+ def infer(original_image):
12
+ image = keras.utils.img_to_array(original_image)
13
+ image = image.astype("float32") / 255.0
14
+ image = np.expand_dims(image, axis=0)
15
+ output = model.predict(image)
16
+ output_image = output[0] * 255.0
17
+ output_image = output_image.clip(0, 255)
18
+ output_image = output_image.reshape(
19
+ (np.shape(output_image)[0], np.shape(output_image)[1], 3)
20
+ )
21
+ output_image = np.uint32(output_image)
22
+ return output_image
23
+
24
+ iface = gr.Interface(
25
+ fn=infer,
26
+ title="Low Light Image Enhancement",
27
+ description = "",
28
+ inputs=[gr.inputs.Image(label="image", type="pil", shape=(960, 640))],
29
+ outputs="image").launch(enable_queue=True)