File size: 1,615 Bytes
c821dda df7d62c c821dda df7d62c c821dda 333f094 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import os
import gradio as gr
def greet(content,style):
return os.path.join(os.path.dirname(__file__), "wedding_matisse.jpg")
def clean():
return None
content_examples = [
os.path.join(os.path.dirname(__file__), "bill-Groj66tpxi4-unsplash.jpg"),
os.path.join(os.path.dirname(__file__), "eugenivy_now-1Bs2sZ9fD2Q-unsplash.jpg")
]
content_image = gr.Image(label='Votre photo')
style_image = gr.Image(label='Votre style')
with gr.Blocks() as demo:
gr.Markdown(
"""
# Bienvenu sur la page de test de l'API de Phresque!
Vous pouvez directement importer vos images de test, ou bien cliquer sur les
exemples en bas de page
""")
with gr.Row():
with gr.Column():
content_image = gr.Image(label='Votre photo')
with gr.Column():
style_image = gr.Image(label='Votre style')
with gr.Column():
output = gr.Image(label='Résultat',interactive=False)
with gr.Row():
clean_content_btn = gr.Button(value="Effacer photo", variant="secondary")
clean_style_btn = gr.Button(value="Effacer style", variant="secondary")
submit_btn = gr.Button(value="Transformer", variant="primary")
examples = gr.Examples(
examples=[content_examples],
inputs=[content_image,style_image])
clean_content_btn.click(clean,inputs=[],outputs=[content_image])
clean_style_btn.click(clean,inputs=[],outputs=[style_image])
submit_btn.click(greet, inputs=[content_image, style_image], outputs=[output])
if __name__ == "__main__":
demo.launch(share=True) |