Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.6
|
| 8 |
-
app_file:
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: blocks_mask_main
|
| 4 |
+
emoji: 🔥
|
| 5 |
+
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 3.6
|
| 9 |
+
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
---
|
|
|
|
|
|
lion.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
https://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
|
run.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio.components import Markdown as md
|
| 3 |
+
|
| 4 |
+
demo = gr.Blocks()
|
| 5 |
+
|
| 6 |
+
io1a = gr.Interface(lambda x: x, gr.Image(), gr.Image())
|
| 7 |
+
io1b = gr.Interface(lambda x: x, gr.Image(source="webcam"), gr.Image())
|
| 8 |
+
|
| 9 |
+
io2a = gr.Interface(lambda x: x, gr.Image(source="canvas"), gr.Image())
|
| 10 |
+
io2b = gr.Interface(lambda x: x, gr.Sketchpad(), gr.Image())
|
| 11 |
+
|
| 12 |
+
io3a = gr.Interface(
|
| 13 |
+
lambda x: [x["mask"], x["image"]],
|
| 14 |
+
gr.Image(source="upload", tool="sketch"),
|
| 15 |
+
[gr.Image(), gr.Image()],
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
io3b = gr.Interface(
|
| 19 |
+
lambda x: [x["mask"], x["image"]],
|
| 20 |
+
gr.ImageMask(),
|
| 21 |
+
[gr.Image(), gr.Image()],
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
io3b2 = gr.Interface(
|
| 25 |
+
lambda x: [x["mask"], x["image"]],
|
| 26 |
+
gr.ImageMask(),
|
| 27 |
+
[gr.Image(), gr.Image()],
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
io3b3 = gr.Interface(
|
| 31 |
+
lambda x: [x["mask"], x["image"]],
|
| 32 |
+
gr.ImageMask(),
|
| 33 |
+
[gr.Image(), gr.Image()],
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
io3c = gr.Interface(
|
| 37 |
+
lambda x: [x["mask"], x["image"]],
|
| 38 |
+
gr.Image(source="webcam", tool="sketch"),
|
| 39 |
+
[gr.Image(), gr.Image()],
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
io4a = gr.Interface(
|
| 43 |
+
lambda x: x, gr.Image(source="canvas", tool="color-sketch"), gr.Image()
|
| 44 |
+
)
|
| 45 |
+
io4b = gr.Interface(lambda x: x, gr.Paint(), gr.Image())
|
| 46 |
+
|
| 47 |
+
io5a = gr.Interface(
|
| 48 |
+
lambda x: x, gr.Image(source="upload", tool="color-sketch"), gr.Image()
|
| 49 |
+
)
|
| 50 |
+
io5b = gr.Interface(lambda x: x, gr.ImagePaint(), gr.Image())
|
| 51 |
+
io5c = gr.Interface(
|
| 52 |
+
lambda x: x, gr.Image(source="webcam", tool="color-sketch"), gr.Image()
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
with demo:
|
| 57 |
+
md("# Different Ways to Use the Image Input Component")
|
| 58 |
+
md(
|
| 59 |
+
"**1a. Standalone Image Upload: `gr.Interface(lambda x: x, gr.Image(), gr.Image())`**"
|
| 60 |
+
)
|
| 61 |
+
io1a.render()
|
| 62 |
+
md(
|
| 63 |
+
"**1b. Standalone Image from Webcam: `gr.Interface(lambda x: x, gr.Image(source='webcam'), gr.Image())`**"
|
| 64 |
+
)
|
| 65 |
+
io1b.render()
|
| 66 |
+
md(
|
| 67 |
+
"**2a. Black and White Sketchpad: `gr.Interface(lambda x: x, gr.Image(source='canvas'), gr.Image())`**"
|
| 68 |
+
)
|
| 69 |
+
io2a.render()
|
| 70 |
+
md(
|
| 71 |
+
"**2b. Black and White Sketchpad: `gr.Interface(lambda x: x, gr.Sketchpad(), gr.Image())`**"
|
| 72 |
+
)
|
| 73 |
+
io2b.render()
|
| 74 |
+
md("**3a. Binary Mask with image upload:**")
|
| 75 |
+
md(
|
| 76 |
+
"""```python
|
| 77 |
+
gr.Interface(
|
| 78 |
+
lambda x: [x['mask'], x['image']],
|
| 79 |
+
gr.Image(source='upload', tool='sketch'),
|
| 80 |
+
[gr.Image(), gr.Image()],
|
| 81 |
+
)
|
| 82 |
+
```
|
| 83 |
+
"""
|
| 84 |
+
)
|
| 85 |
+
io3a.render()
|
| 86 |
+
md("**3b. Binary Mask with image upload:**")
|
| 87 |
+
md(
|
| 88 |
+
"""```python
|
| 89 |
+
gr.Interface(
|
| 90 |
+
lambda x: [x['mask'], x['image']],
|
| 91 |
+
gr.ImageMask(),
|
| 92 |
+
[gr.Image(), gr.Image()],
|
| 93 |
+
)
|
| 94 |
+
```
|
| 95 |
+
"""
|
| 96 |
+
)
|
| 97 |
+
io3b.render()
|
| 98 |
+
md("**3c. Binary Mask with webcam upload:**")
|
| 99 |
+
md(
|
| 100 |
+
"""```python
|
| 101 |
+
gr.Interface(
|
| 102 |
+
lambda x: [x['mask'], x['image']],
|
| 103 |
+
gr.Image(source='webcam', tool='sketch'),
|
| 104 |
+
[gr.Image(), gr.Image()],
|
| 105 |
+
)
|
| 106 |
+
```
|
| 107 |
+
"""
|
| 108 |
+
)
|
| 109 |
+
io3c.render()
|
| 110 |
+
md(
|
| 111 |
+
"**4a. Color Sketchpad: `gr.Interface(lambda x: x, gr.Image(source='canvas', tool='color-sketch'), gr.Image())`**"
|
| 112 |
+
)
|
| 113 |
+
io4a.render()
|
| 114 |
+
md("**4b. Color Sketchpad: `gr.Interface(lambda x: x, gr.Paint(), gr.Image())`**")
|
| 115 |
+
io4b.render()
|
| 116 |
+
md(
|
| 117 |
+
"**5a. Color Sketchpad with image upload: `gr.Interface(lambda x: x, gr.Image(source='upload', tool='color-sketch'), gr.Image())`**"
|
| 118 |
+
)
|
| 119 |
+
io5a.render()
|
| 120 |
+
md(
|
| 121 |
+
"**5b. Color Sketchpad with image upload: `gr.Interface(lambda x: x, gr.ImagePaint(), gr.Image())`**"
|
| 122 |
+
)
|
| 123 |
+
io5b.render()
|
| 124 |
+
md(
|
| 125 |
+
"**5c. Color Sketchpad with webcam upload: `gr.Interface(lambda x: x, gr.Image(source='webcam', tool='color-sketch'), gr.Image())`**"
|
| 126 |
+
)
|
| 127 |
+
io5c.render()
|
| 128 |
+
md("**Tabs**")
|
| 129 |
+
with gr.Tab("One"):
|
| 130 |
+
io3b2.render()
|
| 131 |
+
with gr.Tab("Two"):
|
| 132 |
+
io3b3.render()
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
if __name__ == "__main__":
|
| 136 |
+
demo.launch()
|