Spaces:
Sleeping
Sleeping
fatwalletguy100
commited on
Commit
•
67f53a8
1
Parent(s):
cb96143
uploaded files
Browse files- Dockerfile +20 -0
- app.py +19 -0
- requirements.txt +6 -0
Dockerfile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
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=/home/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,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
# Use a pipeline as a high-level helper
|
7 |
+
from transformers import pipeline
|
8 |
+
|
9 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
+
|
11 |
+
@app.get("/")
|
12 |
+
def home():
|
13 |
+
return {"message" : "helloworld"}
|
14 |
+
|
15 |
+
@app.get("/generate")
|
16 |
+
def generate(text:str):
|
17 |
+
output=pipe(text)
|
18 |
+
|
19 |
+
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
|