Spaces:
Runtime error
Runtime error
upload model
Browse files- app.py +27 -0
- examples/1.png +0 -0
- examples/55.png +0 -0
- examples/665.png +0 -0
- examples/778.png +0 -0
- 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
|