Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1 |
import os
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Set a
|
5 |
-
os.environ["TRANSFORMERS_CACHE"] = "/
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
# Load model (force PyTorch)
|
9 |
-
summarizer = pipeline("summarization", model="t5-base", framework="pt")
|
10 |
|
11 |
from flask import Flask, request, jsonify
|
12 |
|
|
|
1 |
import os
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Set a writable cache directory inside Hugging Face Space
|
5 |
+
os.environ["TRANSFORMERS_CACHE"] = "/tmp/cache"
|
6 |
+
|
7 |
+
# Ensure the cache directory exists
|
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 |
|