Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,7 @@
|
|
1 |
-
import os
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
-
#
|
8 |
-
os.makedirs("/tmp/cache", exist_ok=True)
|
9 |
-
|
10 |
-
# Load model
|
11 |
-
summarizer = pipeline("summarization", model="t5-base", from_tf=True)
|
12 |
print(summarizer("This is a long text that needs summarization.", max_length=50, min_length=10, do_sample=False))
|
13 |
-
|
14 |
-
|
15 |
-
from flask import Flask, request, jsonify
|
16 |
-
|
17 |
-
app = Flask(__name__)
|
18 |
-
|
19 |
-
@app.route("/summarize", methods=["POST"])
|
20 |
-
def summarize():
|
21 |
-
data = request.json
|
22 |
-
text = data.get("text", "")
|
23 |
-
summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
|
24 |
-
return jsonify({"summary": summary[0]["summary_text"]})
|
25 |
-
|
26 |
-
if __name__ == "__main__":
|
27 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
|
3 |
+
# Load the summarization model (ensure from_tf is removed)
|
4 |
+
summarizer = pipeline("summarization", model="t5-base")
|
5 |
|
6 |
+
# Example usage
|
|
|
|
|
|
|
|
|
7 |
print(summarizer("This is a long text that needs summarization.", max_length=50, min_length=10, do_sample=False))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|