Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
def gray(image):
|
| 5 |
+
grayed_image = np.mean(image, 2)
|
| 6 |
+
image_max = np.max(grayed_image)
|
| 7 |
+
|
| 8 |
+
if image_max > 1:
|
| 9 |
+
grayed_image = grayed_image / image_max
|
| 10 |
+
|
| 11 |
+
return grayed_image
|
| 12 |
+
|
| 13 |
+
app = gr.Interface(
|
| 14 |
+
gray,
|
| 15 |
+
'image',
|
| 16 |
+
gr.Image(format='png'),
|
| 17 |
+
live=True
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
app.launch()
|