mohsinabbas1984 commited on
Commit
9654824
1 Parent(s): e558606

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -8
main.py CHANGED
@@ -49,17 +49,16 @@ def preprocess_text(text):
49
  @asynccontextmanager
50
  async def lifespan(app: FastAPI):
51
  # Load the model from HuggingFace transformers library
52
- # from transformers import pipeline
53
-
54
- # sentiment_task = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest", tokenizer="cardiffnlp/twitter-roberta-base-sentiment-latest")
55
  # Use a pipeline as a high-level helper
56
- from transformers import pipeline
57
- global sentiment_task
58
- pipe = pipeline("text-classification", model="SamLowe/roberta-base-go_emotions", tokenizer="SamLowe/roberta-base-go_emotions")
59
 
60
- yield
 
61
  # Clean up the model and release the resources
62
- del sentiment_task
63
 
64
  description = """
65
  ## Text Classification API
 
49
  @asynccontextmanager
50
  async def lifespan(app: FastAPI):
51
  # Load the model from HuggingFace transformers library
52
+ from transformers import pipeline
53
+ global sentiment_task
54
+ sentiment_task = pipeline("text-classification", model="lxyuan/distilbert-base-multilingual-cased-sentiments-student", tokenizer= "lxyuan/distilbert-base-multilingual-cased-sentiments-student")
55
  # Use a pipeline as a high-level helper
56
+ # from transformers import pipeline
 
 
57
 
58
+ # pipe = pipeline("text-classification", model="SamLowe/roberta-base-go_emotions", tokenizer="SamLowe/roberta-base-go_emotions")
59
+ yield
60
  # Clean up the model and release the resources
61
+ del sentiment_task
62
 
63
  description = """
64
  ## Text Classification API