viveknarayan commited on
Commit
b940c81
·
verified ·
1 Parent(s): 35a1549

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +25 -0
  2. requirements (1).txt +2 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
22
+ iface = gr.Interface(
23
+ fn=infer,
24
+ inputs=[gr.inputs.Image(label="image", type="pil", shape=(960, 640))],
25
+ outputs="image").launch(enable_queue=True)
requirements (1).txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow
2
+ keras==2.15