Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,7 +1,20 @@
|
|
1 |
from fastapi import FastAPI
|
|
|
|
|
|
|
|
|
2 |
|
3 |
app = FastAPI()
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
@app.get("/")
|
6 |
-
def
|
7 |
-
return
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from fastapi.staticfiles import StaticFiles
|
3 |
+
from fastapi.responses import FileResponse
|
4 |
+
|
5 |
+
from transformers import pipeline
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
9 |
+
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
+
|
11 |
+
@app.get("/infer_t5")
|
12 |
+
def t5(input):
|
13 |
+
output = pipe_flan(input)
|
14 |
+
return {"output": output[0]["generated_text"]}
|
15 |
+
|
16 |
+
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
17 |
+
|
18 |
@app.get("/")
|
19 |
+
def index() -> FileResponse:
|
20 |
+
return FileResponse(path="/app/static/index.html", media_type="text/html")
|