Last active
April 1, 2022 11:44
-
-
Save osanseviero/36c66bce2b67b1da83ce248c82a18c88 to your computer and use it in GitHub Desktop.
Simple gradio demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%capture | |
!pip install gradio transformers sentencepiece | |
import gradio as gr | |
from transformers import pipeline | |
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es") | |
def predict(text): | |
return pipe(text)[0]["translation_text"] | |
title = "Interactive demo: Helsinki-NLP English to Spanish Translation" | |
iface = gr.Interface( | |
fn=predict, | |
inputs=[gr.inputs.Textbox(label="text", lines=3)], | |
outputs='text', | |
title=title, | |
examples=[["Hello! My name is Omar"], ["I like this workshop"]] | |
) | |
iface.launch(debug=True) | |
iface = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-es", | |
examples=[["Hello! My name is Omar"]] | |
) | |
iface.launch() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment