Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
pip = pipeline("text2text-generation", model="google/flan-t5-small")
|
| 7 |
+
|
| 8 |
+
@app.get("/generate")
|
| 9 |
+
def generate(text: str):
|
| 10 |
+
output = pipe(text)
|
| 11 |
+
|
| 12 |
+
return {"output": output[0]["generated_text"]}
|