Spaces:
Sleeping
Sleeping
File size: 610 Bytes
52d75c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from fastapi import FastAPI
from transformers import pipeline
# print("Package Load Successfully")
### create a FastAPI app instance
app = FastAPI()
## Initialize the Text Generation pipeline
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
### Define the Route
@app.get('/')
def home():
return ({"message":"Hello world"})
@app.get('/generate')
def generate(text:str):
## use the pipeline to generate the text generation
output=pipe(text)
## return the output generated text in json format
return {"output":output[0]["generated_text"]}
|