Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- Dockerfile +12 -0
- app.py +16 -0
- requirements.txt +7 -0
Dockerfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
COPY . .
|
| 5 |
+
|
| 6 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 7 |
+
|
| 8 |
+
RUN useradd user
|
| 9 |
+
USER user
|
| 10 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 11 |
+
|
| 12 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
|
| 3 |
+
app = FastAPI()
|
| 4 |
+
|
| 5 |
+
@app.get("/")
|
| 6 |
+
async def root():
|
| 7 |
+
return {"message": "Hello World"}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@app.get("/generate")
|
| 11 |
+
def generate(text:str):
|
| 12 |
+
## use the pipeline to generate text from given input text
|
| 13 |
+
output=pipe(text)
|
| 14 |
+
|
| 15 |
+
## return the generate text in Json reposne
|
| 16 |
+
return {"output":output[0]['generated_text']}
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi==0.74.*
|
| 2 |
+
requests==2.27.*
|
| 3 |
+
uvicorn[standard]==0.17.*
|
| 4 |
+
sentencepiece==0.1.*
|
| 5 |
+
torch==1.11.*
|
| 6 |
+
transformers==4.*
|
| 7 |
+
|