mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-01 11:45:36 +08:00
updated sepia filter
This commit is contained in:
parent
5d84384924
commit
4bbc7deedb
@ -1,14 +1,27 @@
|
|||||||
import gradio as gr
|
import gradio as gr
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def sepia(img):
|
def sepia(input_img):
|
||||||
sepia_filter = np.array([[.393, .769, .189],
|
sepia_filter = np.array([[.393, .769, .189],
|
||||||
[.349, .686, .168],
|
[.349, .686, .168],
|
||||||
[.272, .534, .131]])
|
[.272, .534, .131]])
|
||||||
sepia_img = img.dot(sepia_filter.T)
|
sepia_img = input_img.dot(sepia_filter.T)
|
||||||
sepia_img /= sepia_img.max()
|
sepia_img /= sepia_img.max()
|
||||||
return sepia_img
|
return sepia_img
|
||||||
|
|
||||||
iface = gr.Interface(sepia, gr.inputs.Image(shape=(200, 200)), "image")
|
iface = gr.Interface(sepia, gr.inputs.Image(shape=(200, 200)), "image",
|
||||||
|
article=
|
||||||
|
"""
|
||||||
|
This simple image demo returns applies a sepia filter to the input image, as described below:
|
||||||
|
```python
|
||||||
|
sepia_filter = np.array([[.393, .769, .189],
|
||||||
|
[.349, .686, .168],
|
||||||
|
[.272, .534, .131]])
|
||||||
|
sepia_img = input_img.dot(sepia_filter.T)
|
||||||
|
sepia_img /= sepia_img.max()
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
iface.launch()
|
iface.launch()
|
Loading…
Reference in New Issue
Block a user