Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -4,16 +4,14 @@ from fastapi import FastAPI
|
|
| 4 |
from pydantic import BaseModel
|
| 5 |
import re
|
| 6 |
import os
|
| 7 |
-
|
| 8 |
|
| 9 |
app = FastAPI()
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-summarize-news")
|
| 16 |
-
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-summarize-news")
|
| 17 |
|
| 18 |
def summarize(text, max_length=150):
|
| 19 |
input_ids = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True)
|
|
|
|
| 4 |
from pydantic import BaseModel
|
| 5 |
import re
|
| 6 |
import os
|
| 7 |
+
from transformers import AutoModelWithLMHead, AutoTokenizer
|
| 8 |
|
| 9 |
app = FastAPI()
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-summarize-news", use_fast=False)
|
| 14 |
+
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-summarize-news", use_fast=False)
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def summarize(text, max_length=150):
|
| 17 |
input_ids = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True)
|