Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from transformers import pipeline
|
3 |
|
|
|
|
|
4 |
app = FastAPI(docs_url="/")
|
5 |
|
6 |
-
|
|
|
7 |
|
8 |
@app.get("/generate")
|
9 |
def generate(text: str):
|
|
|
|
|
|
|
|
|
|
|
10 |
output = pipe(text)
|
11 |
-
|
12 |
return {"output": output[0]["generated_text"]}
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
|
5 |
+
|
6 |
app = FastAPI(docs_url="/")
|
7 |
|
8 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
9 |
+
|
10 |
|
11 |
@app.get("/generate")
|
12 |
def generate(text: str):
|
13 |
+
"""
|
14 |
+
Using the text2text-generation pipeline from `transformers`, generate text
|
15 |
+
from the given input text. The model used is `google/flan-t5-small`, which
|
16 |
+
can be found [here](https://huggingface.co/google/flan-t5-small).
|
17 |
+
"""
|
18 |
output = pipe(text)
|
|
|
19 |
return {"output": output[0]["generated_text"]}
|