2020-08-22 05:20:05 +08:00
|
|
|
# Demo: (Image) -> (Image)
|
|
|
|
|
2020-08-20 05:27:22 +08:00
|
|
|
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
def image_mod(image):
|
2021-08-31 03:22:12 +08:00
|
|
|
if image is None:
|
|
|
|
return "images/lion.jpg"
|
2020-08-22 05:20:05 +08:00
|
|
|
return image.rotate(45)
|
2020-08-20 05:27:22 +08:00
|
|
|
|
2020-10-23 22:28:30 +08:00
|
|
|
|
2020-11-11 22:15:53 +08:00
|
|
|
iface = gr.Interface(image_mod,
|
2021-08-31 03:22:12 +08:00
|
|
|
gr.inputs.Image(type="pil", optional=True),
|
2020-09-03 00:18:00 +08:00
|
|
|
"image",
|
2020-08-20 05:27:22 +08:00
|
|
|
examples=[
|
|
|
|
["images/cheetah1.jpg"],
|
|
|
|
["images/cheetah2.jpg"],
|
|
|
|
["images/lion.jpg"],
|
2020-11-04 23:38:48 +08:00
|
|
|
])
|
2020-08-28 23:56:03 +08:00
|
|
|
|
2020-11-11 22:15:53 +08:00
|
|
|
iface.test_launch()
|
2020-10-23 22:28:30 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-11-11 22:15:53 +08:00
|
|
|
iface.launch()
|