2020-08-20 05:27:22 +08:00
|
|
|
import gradio as gr
|
2022-07-01 13:27:35 +08:00
|
|
|
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
|
|
|
|
2024-07-16 00:19:52 +08:00
|
|
|
new_samples = [
|
|
|
|
[os.path.join(os.path.dirname(__file__), "images/logo.png")],
|
|
|
|
[os.path.join(os.path.dirname(__file__), "images/tower.jpg")],
|
|
|
|
]
|
2022-01-21 21:44:12 +08:00
|
|
|
|
2024-07-16 00:19:52 +08:00
|
|
|
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
|
|
|
|
2020-10-23 22:28:30 +08:00
|
|
|
if __name__ == "__main__":
|
2022-03-29 05:22:49 +08:00
|
|
|
demo.launch()
|