aaryangupta22 commited on
Commit
199bcf1
·
verified ·
1 Parent(s): 16c55ff

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +23 -0
  2. app.py +15 -0
  3. requirment.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##python image
2
+
3
+ FROM python:3.9
4
+
5
+ WORKDIR /code
6
+
7
+ COPY ./requirment.txt /code/requirment.txt
8
+
9
+ RUN pip install --no-cache-dir --upgrade -r /code/requirment.txt
10
+
11
+ RUN useradd user
12
+
13
+ USER user
14
+
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
+
18
+ WORKDIR $HOME/app
19
+
20
+ COPY --chown=user . $HOME/app
21
+
22
+ CMD ["uvicorn","app:app","--host","0.0.0.0","--port","7860"]
23
+
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ app=FastAPI()
5
+
6
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
7
+ @app.get("/")
8
+ def home():
9
+ return {"message": "Welcome to the Text Generation API"}
10
+
11
+ @app.get("/generate")
12
+ def generate(text:str):
13
+ output=pipe(text)
14
+
15
+ return{"output":output[0]['genrated_text']}
requirment.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.*