Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- Dockerfile +0 -0
- app.py +18 -0
- requirements.txt +6 -0
Dockerfile
ADDED
File without changes
|
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
##create new fast api app instance
|
5 |
+
app=FastAPI()
|
6 |
+
|
7 |
+
#initialize the text genration pipeline
|
8 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
9 |
+
|
10 |
+
@app.get("/")
|
11 |
+
def home():
|
12 |
+
return {"message":"Hello World"}
|
13 |
+
|
14 |
+
|
15 |
+
@app.get("/generate")
|
16 |
+
def generate(text:str):
|
17 |
+
output=pipe(text)
|
18 |
+
return{"output":output[0]['generate_text']}
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.74.*
|
2 |
+
requests==2.27.*
|
3 |
+
uvicorn[standard]==0.17.*
|
4 |
+
torch==1.11.*
|
5 |
+
transformers==4.*
|
6 |
+
sentencepiece==0.1.*
|