Spaces:
Sleeping
Sleeping
| 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 | |
| def home(): | |
| return ({"message":"Hello world"}) | |
| 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"]} | |