Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
from fastapi import FastAPI, Header, HTTPException
|
| 3 |
from transformers import pipeline
|
| 4 |
from pydantic import BaseModel
|
|
|
|
| 5 |
|
| 6 |
import os
|
| 7 |
|
|
@@ -11,7 +12,8 @@ API_KEY = os.getenv("API_KEY")
|
|
| 11 |
# Загружаем модель один раз при старте
|
| 12 |
sentiment_model = pipeline(
|
| 13 |
"sentiment-analysis",
|
| 14 |
-
model="cardiffnlp/twitter-roberta-base-sentiment-latest"
|
|
|
|
| 15 |
)
|
| 16 |
|
| 17 |
# FastAPI приложение
|
|
|
|
| 2 |
from fastapi import FastAPI, Header, HTTPException
|
| 3 |
from transformers import pipeline
|
| 4 |
from pydantic import BaseModel
|
| 5 |
+
import torch
|
| 6 |
|
| 7 |
import os
|
| 8 |
|
|
|
|
| 12 |
# Загружаем модель один раз при старте
|
| 13 |
sentiment_model = pipeline(
|
| 14 |
"sentiment-analysis",
|
| 15 |
+
model="cardiffnlp/twitter-roberta-base-sentiment-latest",
|
| 16 |
+
device = 0
|
| 17 |
)
|
| 18 |
|
| 19 |
# FastAPI приложение
|