CoolFace
Apppublic

Harsh-Gupta/simple-text2text

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py18 linesDownload Raw Back to root
1from fastapi import FastAPI
2from transformers import pipeline
3
4app=FastAPI()
5
6pipe = pipeline("text2text-generation", model="google/flan-t5-small")
7
8@app.get('/')
9def home():
10    return {'message':'Hello World'}
11
12@app.get('/generate')
13def generate(text:str):
14    output=pipe(text)
15
16    #returning the generated text in json
17    return {'output':output[0]['generated_text']}
18