gradio/demo/image_mod/run.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
783 B
Python
Raw Normal View History

2020-08-20 05:27:22 +08:00
import gradio as gr
import os
2020-08-20 05:27:22 +08:00
def image_mod(image):
2020-08-22 05:20:05 +08:00
return image.rotate(45)
2020-08-20 05:27:22 +08:00
new_samples = [
[os.path.join(os.path.dirname(__file__), "images/logo.png")],
[os.path.join(os.path.dirname(__file__), "images/tower.jpg")],
]
with gr.Blocks() as demo:
interface = gr.Interface(
image_mod,
gr.Image(type="pil"),
"image",
flagging_options=["blurry", "incorrect", "other"],
examples=[
os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
],
)
btn = gr.Button("Update Examples")
btn.click(lambda : gr.Dataset(samples=new_samples), None, interface.examples_handler.dataset)
2022-03-29 05:22:49 +08:00
if __name__ == "__main__":
2022-03-29 05:22:49 +08:00
demo.launch()