|
import gradio as gr |
|
from transformers import ( |
|
AutoTokenizer, |
|
AutoModelForSeq2SeqLM, |
|
pipeline |
|
) |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained( |
|
"prithivida/parrot_paraphraser_on_T5", |
|
use_fast=False |
|
) |
|
model = AutoModelForSeq2SeqLM.from_pretrained( |
|
"prithivida/parrot_paraphraser_on_T5" |
|
) |
|
|
|
|
|
paraphrase = pipeline( |
|
"text2text-generation", |
|
model=model, |
|
tokenizer=tokenizer, |
|
device=0 |
|
) |
|
|
|
def humanize(text): |
|
outputs = paraphrase( |
|
text, |
|
max_length=256, |
|
num_return_sequences=1 |
|
) |
|
return outputs[0]["generated_text"] |
|
|
|
demo = gr.Interface( |
|
fn=humanize, |
|
inputs=gr.Textbox(lines=5, placeholder="Paste your text here…"), |
|
outputs="text", |
|
title="Humanizo: Humanize AI Text", |
|
description="Enter text and get a more natural, human‑like version." |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|