Sankie005 commited on
Commit
fadc66a
1 Parent(s): 2656846

Upload 4 files

Browse files
Files changed (4) hide show
  1. app/__init__.py +0 -0
  2. app/main.py +20 -0
  3. dockerized.dockerfile +17 -0
  4. requirements.txt +4 -0
app/__init__.py ADDED
File without changes
app/main.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from pydantic import BaseModel
3
+ from typing import List
4
+ app = FastAPI()
5
+
6
+ class TextInput(BaseModel):
7
+ InputText: str # python casing??????
8
+
9
+ def emotion_detection(str1: str) -> str:
10
+ from transformers import pipeline
11
+ pipe = pipeline(model="distilbert-base-uncased-finetuned-sst-2-english")
12
+ expected=(pipe(str1))
13
+ return expected[0].get('label')
14
+
15
+ @app.post("/generate-emotion/")
16
+ async def detect_emotion(input_data: TextInput):
17
+ text1 = input_data.InputText
18
+ emotion= emotion_detection(text1)
19
+ response={"Text Entered":text1,"emotion":emotion}
20
+ return response
dockerized.dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ FROM python:3.11
3
+ ENV PYTHONUNBUFFERED 1
4
+ #
5
+ WORKDIR /Karen_python
6
+
7
+ #
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ #
11
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
12
+
13
+ #
14
+ COPY ./app /code/app
15
+
16
+ #
17
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ transformers[torch]
2
+ fastapi
3
+ uvicorn[standard]
4
+ nltk