Abineshkumar77 commited on
Commit
4a4f343
·
1 Parent(s): abe3d88

Add application file

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -4,7 +4,7 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
  from scipy.special import softmax
5
  from typing import Dict
6
 
7
- # Set TRANSFORMERS_CACHE to a writable directory
8
  os.environ["TRANSFORMERS_CACHE"] = "/tmp/.cache"
9
 
10
  app = FastAPI()
@@ -38,3 +38,7 @@ def analyze_sentiment(tweet: str) -> Dict[str, float]:
38
  async def analyze_sentiment_endpoint(tweet: str = Query(..., description="The tweet to analyze")):
39
  sentiment_scores = analyze_sentiment(tweet)
40
  return {"sentiment": sentiment_scores}
 
 
 
 
 
4
  from scipy.special import softmax
5
  from typing import Dict
6
 
7
+ # Set the TRANSFORMERS_CACHE environment variable to a writable directory
8
  os.environ["TRANSFORMERS_CACHE"] = "/tmp/.cache"
9
 
10
  app = FastAPI()
 
38
  async def analyze_sentiment_endpoint(tweet: str = Query(..., description="The tweet to analyze")):
39
  sentiment_scores = analyze_sentiment(tweet)
40
  return {"sentiment": sentiment_scores}
41
+
42
+ # To run the application:
43
+ # 1. Save this code as `main.py`.
44
+ # 2. Run the command `uvicorn main:app --reload`.