rsaketh02 commited on
Commit
3af6de7
1 Parent(s): 03124db

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +24 -0
  2. app.py +23 -0
  3. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Use the official Python Python 3.12.3 image
2
+ FROM python:3.12.3
3
+
4
+ ## set the working directory to /code
5
+ WORKDIR /code
6
+
7
+ ##copy the current directory contents in the container at /code
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ #3 Install the requirements.txt
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
+
13
+ RUN useradd user
14
+
15
+ USER user
16
+
17
+ ENV HOME=/home/user \
18
+ PATH=/home/user/.local/bin:$PATH
19
+
20
+ WORKDIR $HOME/app
21
+
22
+ COPY --chown=user . $HOME/app
23
+
24
+ CMD [ "uvicorn" ,"app:app", "--host","0.0.0.0","--port","7860"]
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ ## create a new FASTAPI app instance
5
+ app=FastAPI()
6
+
7
+
8
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
9
+
10
+
11
+ @app.get("/")
12
+ def home():
13
+ return {"message":"Hello World"}
14
+
15
+
16
+ @app.get("/generate")
17
+ def generate(text:str):
18
+ ## use pipeline to generate text from given input text
19
+ output=pipe(text)
20
+
21
+
22
+ ## return generated text in json
23
+ return {"output":output[0]['generated_text']}
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi
2
+ requests
3
+ uvicorn[standard]
4
+ sentencepiece
5
+ torch
6
+ transformers