prowriting commited on
Commit
da35fc5
·
verified ·
1 Parent(s): f3738c6

Fix Hugging Face Space configuration and app setup

Browse files

- Added proper YAML frontmatter to README.md for Hugging Face Spaces
- Renamed main.py → app.py for correct entrypoint
- Updated requirements.txt with required dependencies
- Ensured configuration points to the right app file
- Prepared Smooth Paraphraser for stable deployment on Hugging Face

Files changed (3) hide show
  1. README.md +23 -10
  2. app.py +8 -6
  3. requirements.txt +3 -1
README.md CHANGED
@@ -1,14 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
1
  # Smooth Paraphraser
2
 
3
- Smooth Paraphraser is a simple Hugging Face Space app built with **Gradio** and a pretrained **T5 model** for paraphrasing text.
 
4
 
5
  ## Features
6
- - Enter any text and get a smooth paraphrased version.
7
- - Powered by Hugging Face `transformers` library.
8
- - Runs with Gradio for a clean UI.
9
-
10
- ## How to Run Locally
11
- ```bash
12
- pip install -r requirements.txt
13
- python app.py
14
- ```
 
 
1
+ ---
2
+ title: Smooth Paraphraser
3
+ emoji: 📝
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: "4.29.0"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
  # Smooth Paraphraser
13
 
14
+ A lightweight web app that rewrites text smoothly while preserving meaning.
15
+ Built with **Gradio + Transformers**, deployed on **Hugging Face Spaces**.
16
 
17
  ## Features
18
+ - Paraphrase sentences, paragraphs, or articles.
19
+ - Uses state-of-the-art T5 model.
20
+ - Simple and responsive UI.
21
+
22
+ ## Usage
23
+ 1. Enter text in the input box.
24
+ 2. Click **Paraphrase**.
25
+ 3. Copy the rewritten text.
26
+
27
+ ---
app.py CHANGED
@@ -1,21 +1,23 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load paraphrasing pipeline
5
  paraphraser = pipeline("text2text-generation", model="Vamsi/T5_Paraphrase_Paws")
6
 
7
  def paraphrase(text):
8
- result = paraphraser(text, max_length=100, num_return_sequences=1)
 
 
9
  return result[0]['generated_text']
10
 
11
  # Gradio interface
12
- demo = gr.Interface(
13
  fn=paraphrase,
14
- inputs=gr.Textbox(lines=4, placeholder="Enter text to paraphrase..."),
15
  outputs="text",
16
  title="Smooth Paraphraser",
17
- description="A simple app to smoothly paraphrase text using a pretrained T5 transformer model."
18
  )
19
 
20
  if __name__ == "__main__":
21
- demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load model
5
  paraphraser = pipeline("text2text-generation", model="Vamsi/T5_Paraphrase_Paws")
6
 
7
  def paraphrase(text):
8
+ if not text.strip():
9
+ return "Please enter some text."
10
+ result = paraphraser(text, max_length=128, num_return_sequences=1, do_sample=False)
11
  return result[0]['generated_text']
12
 
13
  # Gradio interface
14
+ iface = gr.Interface(
15
  fn=paraphrase,
16
+ inputs=gr.Textbox(lines=4, placeholder="Enter text here..."),
17
  outputs="text",
18
  title="Smooth Paraphraser",
19
+ description="Rewrite sentences smoothly while preserving meaning."
20
  )
21
 
22
  if __name__ == "__main__":
23
+ iface.launch()
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
- transformers==4.42.4
2
  torch
3
  gradio==4.29.0
 
 
 
1
+ transformers==4.39.3
2
  torch
3
  gradio==4.29.0
4
+ sentencepiece
5
+ tiktoken