Ryan Shrott commited on
Commit ·
a0c89bd
1
Parent(s): 9560ced
commit
Browse files
app.py
CHANGED
|
@@ -1,7 +1,23 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
hf = HfApi()
|
| 6 |
-
repo_url = hf.create_repo("test2", token="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", repo_type="spaces", exist_ok=True)
|
| 7 |
-
iface.launch(debug=True, share=True, huggingface_space=repo_url)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
|
| 3 |
+
|
| 4 |
+
model_name = "t5-base"
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 7 |
+
summarization = pipeline("summarization", model=model, tokenizer=tokenizer)
|
| 8 |
+
|
| 9 |
+
def generate_summary(text):
|
| 10 |
+
summary = summarization(text, max_length=100, min_length=25, do_sample=False)
|
| 11 |
+
return summary[0]["summary_text"]
|
| 12 |
+
|
| 13 |
+
input_text = gr.inputs.Textbox(lines=5, placeholder="Enter your text here...")
|
| 14 |
+
output_text = gr.outputs.Textbox(label="Summary")
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=generate_summary,
|
| 18 |
+
inputs=input_text,
|
| 19 |
+
outputs=output_text,
|
| 20 |
+
title="Text Summarization",
|
| 21 |
+
description="Enter your text and get a summary using the Hugging Face T5 model.",
|
| 22 |
+
)
|
| 23 |
|
|
|
|
|
|
|
|
|