UniClean commited on
Commit
9a4b862
·
verified ·
1 Parent(s): d8965a8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Replace with free HF model that doesn’t require billing
5
+ HF_MODEL = "google/flan-t5-small" # Small free model
6
+ HF_API_URL = f"https://api-inference.huggingface.co/models/{HF_MODEL}"
7
+ HF_KEY = "" # Empty if using public free endpoint
8
+ HEADERS = {"Authorization": f"Bearer {HF_KEY}"} if HF_KEY else None
9
+
10
+ def humanize_text(text):
11
+ prompt = f"Rewrite the following text to be human-like, plagiarism-free, and natural:\n{text}"
12
+ payload = {"inputs": prompt}
13
+ try:
14
+ response = requests.post(HF_API_URL, headers=HEADERS, json=payload, timeout=60)
15
+ if response.status_code == 200:
16
+ result = response.json()
17
+ if isinstance(result, list) and "generated_text" in result[0]:
18
+ return result[0]["generated_text"]
19
+ return str(result[0])
20
+ else:
21
+ return f"Error: {response.status_code} - {response.text}"
22
+ except Exception as e:
23
+ return f"Error: {str(e)}"
24
+
25
+ iface = gr.Interface(
26
+ fn=humanize_text,
27
+ inputs=gr.Textbox(lines=15, placeholder="Paste your text here..."),
28
+ outputs="text",
29
+ title="HumanizeAI — Plagiarism Remover",
30
+ description="Paste your text and click Submit. The AI will rewrite it to be human-like and plagiarism-free."
31
+ )
32
+
33
+ iface.launch()