import gradio as gr from transformers import pipeline import torch generator = pipeline('text-generation', model='Sigurdur/icebreaker') def generate(text): result = generator(text, max_length=30, num_return_sequences=1) return result[0]["generated_text"] examples = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '<Í dag - mbl.is>', '<Íslensk stjórnmál>', '<Íslenskt mál>', '<Íþróttir>', '<Óflokkað>', '<Ólympíuleikar>'] demo = gr.Interface( fn=generate, inputs=gr.Textbox(lines=5, label="Input Text"), outputs=gr.Textbox(label="Generated Text"), examples=examples, title="Generate news articles in Icelandic with Icebreaker", description="Author: Sigurdur Haukur Birgisson", ) demo.launch()