File size: 1,001 Bytes
31875de ed79474 31875de ed79474 31875de ed79474 31875de ed79474 31875de ed79474 31875de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import gradio as gr
from transformers import (
AutoTokenizer,
AutoModelForSeq2SeqLM,
pipeline
)
# Load slow (SentencePiece) tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(
"prithivida/parrot_paraphraser_on_T5",
use_fast=False
)
model = AutoModelForSeq2SeqLM.from_pretrained(
"prithivida/parrot_paraphraser_on_T5"
)
# Build your paraphrasing pipeline
paraphrase = pipeline(
"text2text-generation",
model=model,
tokenizer=tokenizer,
device=0 # if you have a GPU; otherwise omit this line
)
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()
|