| | import gradio as gr |
| | import requests |
| |
|
| | |
| | HF_MODEL = "google/flan-t5-small" |
| | HF_API_URL = f"https://api-inference.huggingface.co/models/{HF_MODEL}" |
| | HF_KEY = "" |
| | HEADERS = {"Authorization": f"Bearer {HF_KEY}"} if HF_KEY else None |
| |
|
| | def humanize_text(text): |
| | prompt = f"Rewrite the following text to be human-like, plagiarism-free, and natural:\n{text}" |
| | payload = {"inputs": prompt} |
| | try: |
| | response = requests.post(HF_API_URL, headers=HEADERS, json=payload, timeout=60) |
| | if response.status_code == 200: |
| | result = response.json() |
| | if isinstance(result, list) and "generated_text" in result[0]: |
| | return result[0]["generated_text"] |
| | return str(result[0]) |
| | else: |
| | return f"Error: {response.status_code} - {response.text}" |
| | except Exception as e: |
| | return f"Error: {str(e)}" |
| |
|
| | iface = gr.Interface( |
| | fn=humanize_text, |
| | inputs=gr.Textbox(lines=15, placeholder="Paste your text here..."), |
| | outputs="text", |
| | title="HumanizeAI — Plagiarism Remover", |
| | description="Paste your text and click Submit. The AI will rewrite it to be human-like and plagiarism-free." |
| | ) |
| |
|
| | iface.launch() |
| |
|