Spaces:
Sleeping
Sleeping
use hf model
Browse files- Dockerfile +9 -0
- app.py +19 -0
- requirements.txt +6 -0
Dockerfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
From python:3.10-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY ./ /app
|
| 6 |
+
|
| 7 |
+
RUN pip install -r requirements.txt
|
| 8 |
+
|
| 9 |
+
CMD fastapi run --reload --host=0.0.0.0 --port=7860
|
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
# Use a pipeline as a high-level helper
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
@app.get("/")
|
| 10 |
+
def greet_json():
|
| 11 |
+
return {"Hello": "World!"}
|
| 12 |
+
|
| 13 |
+
@app.get("/ask")
|
| 14 |
+
def ask(prompt:str):
|
| 15 |
+
result = pipe(prompt)
|
| 16 |
+
return result
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# docker run --name=fastapi -p 7860:7860 fastapi-hf
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn[standard]
|
| 3 |
+
fastapi[standard]
|
| 4 |
+
transformers
|
| 5 |
+
torch
|
| 6 |
+
torchvision
|