Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- Dockerfile +7 -0
- app.py +34 -0
- requirements.txt +5 -0
Dockerfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The Dockerfile is nearly identical to the ASR service [cite: 235]
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 5 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 6 |
+
COPY ./app.py /code/app.py
|
| 7 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Adapted from source [cite: 214-232]
|
| 2 |
+
from fastapi import FastAPI, HTTPException
|
| 3 |
+
from pydantic import BaseModel
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
import torch
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
class TranscriptionPayload(BaseModel):
|
| 10 |
+
text: str
|
| 11 |
+
|
| 12 |
+
# Load the summarization pipeline on startup
|
| 13 |
+
try:
|
| 14 |
+
summarizer = pipeline(
|
| 15 |
+
"summarization",
|
| 16 |
+
model="knkarthick/MEETING_SUMMARY",
|
| 17 |
+
torch_dtype=torch.float32,
|
| 18 |
+
device="cpu",
|
| 19 |
+
)
|
| 20 |
+
except Exception as e:
|
| 21 |
+
summarizer = None
|
| 22 |
+
print(f"Error loading summarization model: {e}")
|
| 23 |
+
|
| 24 |
+
@app.post("/summarize")
|
| 25 |
+
async def summarize_text(payload: TranscriptionPayload):
|
| 26 |
+
if not summarizer:
|
| 27 |
+
raise HTTPException(status_code=503, detail="Summarizer model is not available.")
|
| 28 |
+
|
| 29 |
+
full_text = payload.text
|
| 30 |
+
|
| 31 |
+
# Generate the summary
|
| 32 |
+
summary = summarizer(full_text, min_length=30, max_length=250, do_sample=False)
|
| 33 |
+
|
| 34 |
+
return {"summary": summary[0]['summary_text']}
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
torch
|
| 4 |
+
transformers
|
| 5 |
+
pydantic
|