ayushsinha commited on
Commit
4105753
·
verified ·
1 Parent(s): 73914be

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +44 -0
  2. requirements.txt +8 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the paraphrase model
5
+ model_name = "AventIQ-AI/t5-paraphrase-generation"
6
+ paraphrase_pipeline = pipeline("text2text-generation", model=model_name)
7
+
8
+ def generate_paraphrase(text, max_length, temperature):
9
+ """Generate a paraphrased version of the input text."""
10
+ if not text.strip():
11
+ return "⚠️ Please enter some text to paraphrase."
12
+
13
+ result = paraphrase_pipeline(
14
+ text,
15
+ max_length=max_length,
16
+ temperature=temperature, # Adds randomness to prevent repetition
17
+ top_k=50, # Consider top-k tokens for variation
18
+ do_sample=True # Enable sampling
19
+ )
20
+ return result[0]["generated_text"]
21
+
22
+ # Define Gradio Interface
23
+ description = """
24
+ ## ✨ AI Paraphrasing Tool
25
+ Enter a sentence and let AI generate a paraphrased version!
26
+ - Adjust **max length** for longer outputs.
27
+ - Tune **temperature** for more creative results.
28
+ """
29
+
30
+ demo = gr.Interface(
31
+ fn=generate_paraphrase,
32
+ inputs=[
33
+ gr.Textbox(label="Enter text", placeholder="Type a sentence to paraphrase..."),
34
+ gr.Slider(20, 100, value=50, step=5, label="Max Output Length"),
35
+ gr.Slider(0.5, 1.5, value=1.0, step=0.1, label="Creativity (Temperature)"),
36
+ ],
37
+ outputs=gr.Textbox(label="Paraphrased Text"),
38
+ title="📝 AI Paraphraser",
39
+ description=description,
40
+ theme="huggingface",
41
+ live=True,
42
+ )
43
+
44
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ gradio
4
+ sentencepiece
5
+ torchvision
6
+ huggingface_hub
7
+ pillow
8
+ numpy