Spaces:
Sleeping
Sleeping
File size: 463 Bytes
f07b276 f597a9f f07b276 0c482c6 7984726 f07b276 3b4bf88 afcb910 f07b276 3b4bf88 f07b276 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from transformers import pipeline
from fastapi import FastAPI
import os
os.environ['TRANSFORMERS_CACHE'] = '/.cache/huggingface/hub'
app = FastAPI()
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get("/")
async def home():
return pipe("what you know about AI?")[0]['generated_text']
@app.get("/generate")
async def generate(text:str):
res = pipe(text)
return {"output":res[0]['generated_text']}
|