Ro8010 commited on
Commit
462f516
1 Parent(s): 47dc236

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +20 -0
  2. app.py +16 -0
  3. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ RUN useradd user
10
+
11
+ USER user
12
+
13
+ ENV HOME=/home/user \
14
+ PATH=/homr/user/.local/bin:$PATH
15
+
16
+ WORKDIR $HOME/app
17
+
18
+ COPY --chown=user . $HOME/app
19
+
20
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
8
+ @app.get("/")
9
+ def home():
10
+ return{"message":"Hello World"}
11
+
12
+ @app.get("generate")
13
+ def generate(text:str):
14
+ output=pipe(text)
15
+
16
+ return {"output":output[0]['generate_text']}
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi
2
+ requests
3
+ uvicorn
4
+ sentencepiece
5
+ torch
6
+ transformers