MyDocker / main.py
Nocare3's picture
Update main.py
bfa9d6f verified
raw
history blame
471 Bytes
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI()
app.mount("/", StaticFiles(directory="static", html=True), name="static")
@app.get("/")
def index() -> FileResponse:
return FileResponse(path="/app/static/index.html", media_type="text/html")
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get("infer_t5")
def t5(input):
output = pipe_flan(input)
return {"output": output[0]["generated_text"]}