Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- DockerFile +18 -0
- app.py +18 -0
- requirements.txt +6 -0
DockerFile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12.0
|
| 2 |
+
|
| 3 |
+
# define the dictionary path
|
| 4 |
+
WORKDIR /code
|
| 5 |
+
|
| 6 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 7 |
+
|
| 8 |
+
# install the requirements package
|
| 9 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 10 |
+
|
| 11 |
+
ENV HOME=/home/user \
|
| 12 |
+
PATH=/home/user/.local/bin:$path
|
| 13 |
+
|
| 14 |
+
WORKDIR $HOME/app
|
| 15 |
+
|
| 16 |
+
COPY --chown=user . $HOME/app
|
| 17 |
+
|
| 18 |
+
CMD ["uvicorn", "app:app","--host","0.0.0.0","--port","7860"]
|
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
app = FastAPI() # app instance
|
| 5 |
+
|
| 6 |
+
@app.get("/")
|
| 7 |
+
def root():
|
| 8 |
+
return {"message": "Hello World"}
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
| 12 |
+
|
| 13 |
+
@app.get("/generate")
|
| 14 |
+
def generate(prompt: str):
|
| 15 |
+
response = pipe(prompt)
|
| 16 |
+
|
| 17 |
+
return {"response": response[0]['generated_text']}
|
| 18 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
fastapi
|
| 3 |
+
uvicorn
|
| 4 |
+
requests
|
| 5 |
+
transformers
|
| 6 |
+
sentencepiece
|