File size: 710 Bytes
1375ad0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import AutoTokenizer, T5ForConditionalGeneration

model_name = "umutbozdag/humanizer_model"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)

def humanize(text):
    inputs = tokenizer(text, return_tensors="pt", max_length=128, truncation=True)
    outputs = model.generate(**inputs, max_length=128)
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

iface = gr.Interface(
    fn=humanize,
    inputs=gr.Textbox(lines=5, label="Formal Text"),
    outputs=gr.Textbox(label="Humanized Text"),
    title="Text Humanizer",
    description="Enter formal text to humanize it."
)

iface.launch()