bhaavvya commited on
Commit
5da0a9d
1 Parent(s): a3cf5dd

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +23 -0
  2. app.py +15 -0
  3. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##use official python 3.9
2
+
3
+ FROM python:3.9
4
+
5
+ ## set the working directory /code
6
+ WORKDIR /code
7
+
8
+ ## copy the current directory contents into the container /code
9
+ COPY ./requirements.txt /code/requirements.txt
10
+
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
+
13
+ RUN useradd user
14
+ USER user
15
+
16
+ ENV HOME=/home/user \
17
+ PATH=/home/user/.local/bin:$PATH
18
+
19
+ WORKDIR $HOME/app
20
+
21
+ COPY --chown=user . $HOME/app
22
+
23
+ CMD ["uvicorn","app:app","--host","0.0.0.0","--port","1810"]
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ app = FastAPI()
5
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
6
+
7
+ @app.get("/")
8
+ def home():
9
+ return {"message" : "hello world!!"}
10
+
11
+ @app.get("/generate")
12
+ def generate(text:str):
13
+ output = pipe(text)
14
+
15
+ return {"output": output[0]['generated_text']}
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi==0.74.*
2
+ requests==2.27.*
3
+ uvicorn[standard]==0.17.*
4
+ sentencepiece==0.1.*
5
+ torch==1.11.*
6
+ transformers==4.*