File size: 583 Bytes
fc8f9e3
 
 
 
 
 
 
f27a4ff
fc8f9e3
 
 
 
f27a4ff
fc8f9e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
import torch
from transformers import T5ForConditionalGeneration,AutoTokenizer,pipeline

tokenizer = AutoTokenizer.from_pretrained('SeyedAli/Persian-Text-paraphraser-mT5-V1',model_max_length=100, add_special_tokens = True)
model = T5ForConditionalGeneration.from_pretrained('SeyedAli/Persian-Text-paraphraser-mT5-V1')

def Paraphrase(text):
    pipline = pipeline(task='text2text-generation', model=model, tokenizer=tokenizer)
    output=pipline(text)
    return output

iface = gr.Interface(fn=Paraphrase, inputs="text", outputs="text")
iface.launch(share=False)