vumichien commited on
Commit
47724eb
1 Parent(s): 06e3cf0

upload model

Browse files
Files changed (6) hide show
  1. app.py +27 -0
  2. examples/1.png +0 -0
  3. examples/55.png +0 -0
  4. examples/665.png +0 -0
  5. examples/778.png +0 -0
  6. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ from huggingface_hub import from_pretrained_keras
4
+ import keras
5
+
6
+ model = from_pretrained_keras("keras-io/lowlight-enhance-mirnet", compile=False)
7
+ examples = ['examples/1.png', 'examples/55.png', 'examples/665.png', 'examples/778.png']
8
+
9
+
10
+ def infer(original_image):
11
+ image = keras.preprocessing.image.img_to_array(original_image)
12
+ image = image.astype("float32") / 255.0
13
+ image = np.expand_dims(image, axis=0)
14
+ output = model.predict(image)
15
+ output_image = output[0] * 255.0
16
+ output_image = output_image.clip(0, 255)
17
+ output_image = output_image.reshape(
18
+ (np.shape(output_image)[0], np.shape(output_image)[1], 3)
19
+ )
20
+ output_image = np.uint32(output_image)
21
+ return output_image
22
+
23
+ iface = gr.Interface(
24
+ fn=infer,
25
+ inputs=[gr.inputs.Image(label="image", type="pil")],
26
+ outputs="image",
27
+ examples=examples).launch(debug=True)
examples/1.png ADDED
examples/55.png ADDED
examples/665.png ADDED
examples/778.png ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow
2
+ keras