JohnDoee commited on
Commit
2ee1f34
·
1 Parent(s): 197a491

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  from fastapi import FastAPI
3
  from pydantic import BaseModel
4
- from transformers import pipeline, AutoTokenizer
5
  from langdetect import detect, DetectorFactory
6
 
7
  # Ensure consistent language detection results
@@ -16,14 +16,14 @@ app = FastAPI()
16
  # Load the original tokenizer from the base model
17
  original_tokenizer = AutoTokenizer.from_pretrained("tabularisai/multilingual-sentiment-analysis")
18
 
19
- # Load the fine-tuned model and pass the tokenizer explicitly
20
  multilingual_model = pipeline(
21
  "sentiment-analysis",
22
- model="./model",
23
  tokenizer=original_tokenizer
24
  )
25
 
26
- # English model remains unchanged
27
  english_model = pipeline("sentiment-analysis", model="siebert/sentiment-roberta-large-english")
28
 
29
  class SentimentRequest(BaseModel):
 
1
  import os
2
  from fastapi import FastAPI
3
  from pydantic import BaseModel
4
+ from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
5
  from langdetect import detect, DetectorFactory
6
 
7
  # Ensure consistent language detection results
 
16
  # Load the original tokenizer from the base model
17
  original_tokenizer = AutoTokenizer.from_pretrained("tabularisai/multilingual-sentiment-analysis")
18
 
19
+ # Load the fine-tuned model (johndoee/sentiment) and pass the tokenizer explicitly
20
  multilingual_model = pipeline(
21
  "sentiment-analysis",
22
+ model="johndoee/sentiment",
23
  tokenizer=original_tokenizer
24
  )
25
 
26
+ # Load the English sentiment model
27
  english_model = pipeline("sentiment-analysis", model="siebert/sentiment-roberta-large-english")
28
 
29
  class SentimentRequest(BaseModel):