Hugo Rodrigues
commited on
Commit
·
ea61a65
1
Parent(s):
9001e67
rename app.py to main.py
Browse files
main.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
|
3 |
+
# gr.load("models/openai/whisper-large-v3").launch()
|
4 |
+
|
5 |
+
from typing import Union
|
6 |
+
from pydantic import BaseModel
|
7 |
+
from fastapi import FastAPI
|
8 |
+
|
9 |
+
from fastapi.staticfiles import StaticFiles
|
10 |
+
from fastapi.responses import FileResponse
|
11 |
+
|
12 |
+
from transformers import pipeline
|
13 |
+
|
14 |
+
app = FastAPI()
|
15 |
+
|
16 |
+
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
17 |
+
|
18 |
+
|
19 |
+
@app.get("/infer_t5")
|
20 |
+
def t5(input):
|
21 |
+
output = pipe_flan(input)
|
22 |
+
return {"output": output[0]["generated_text"]}
|
23 |
+
|
24 |
+
|
25 |
+
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
26 |
+
|
27 |
+
|
28 |
+
@app.get("/")
|
29 |
+
def index() -> FileResponse:
|
30 |
+
return FileResponse(path="/app/static/index.html", media_type="text/html")
|