Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- README.md +5 -6
- app.py +29 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: red
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: To Gray Scale Example
|
| 3 |
+
emoji: 🦓
|
| 4 |
colorFrom: red
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
+
python_version: 3.10.12
|
| 8 |
+
sdk_version: 5.0.2
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def to_gray(img):
|
| 4 |
+
filtpxs = []
|
| 5 |
+
for r,g,b in img.getdata():
|
| 6 |
+
l = (r + g + b) // 3
|
| 7 |
+
filtpxs.append((l, l, l))
|
| 8 |
+
img.putdata(filtpxs)
|
| 9 |
+
return img
|
| 10 |
+
|
| 11 |
+
my_inputs = [
|
| 12 |
+
gr.Image(type="pil", show_label=False),
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
my_outputs = [
|
| 16 |
+
gr.Image(type="pil", show_label=False)
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
with gr.Blocks() as demo:
|
| 20 |
+
gr.Interface(
|
| 21 |
+
fn=to_gray,
|
| 22 |
+
inputs=my_inputs,
|
| 23 |
+
outputs=my_outputs,
|
| 24 |
+
allow_flagging="never",
|
| 25 |
+
fill_width=True
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pydantic==2.8.2
|
| 2 |
+
huggingface-hub==0.34.3
|