Spaces:
No application file
No application file
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
from fastapi import FastAPI
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
7 |
+
|
8 |
+
@app.get("/")
|
9 |
+
def home():
|
10 |
+
return "hello world"
|
11 |
+
|
12 |
+
|
13 |
+
@app.get("/generate")
|
14 |
+
def generate(text:str):
|
15 |
+
|
16 |
+
res = pipe(text)
|
17 |
+
|
18 |
+
return {"output":res[0]['generated_text']}
|
19 |
+
|
20 |
+
|
21 |
+
|