Spaces:
Runtime error
Runtime error
fix pre-commit and lsf
Browse files- src/api.py +10 -4
- src/model.py +1 -0
src/api.py
CHANGED
@@ -10,6 +10,8 @@ from inference import inferenceAPI
|
|
10 |
# appel de la fonction inference, adaptee pour une entree txt
|
11 |
def summarize(text: str):
|
12 |
return " ".join(inferenceAPI(text))
|
|
|
|
|
13 |
# ----------------------------------------------------------------------------------
|
14 |
|
15 |
|
@@ -20,23 +22,27 @@ app = FastAPI()
|
|
20 |
templates = Jinja2Templates(directory="templates")
|
21 |
app.mount("/templates", StaticFiles(directory="templates"), name="templates")
|
22 |
|
|
|
23 |
@app.get("/")
|
24 |
async def index(request: Request):
|
25 |
return templates.TemplateResponse("index.html.jinja", {"request": request})
|
26 |
|
|
|
27 |
# retourner le texte, les predictions et message d'erreur si formulaire envoye vide
|
28 |
@app.post("/")
|
29 |
async def prediction(request: Request, text: str = Form(None)):
|
30 |
-
if not text
|
31 |
error = "Merci de saisir votre texte."
|
32 |
return templates.TemplateResponse(
|
33 |
-
|
34 |
-
|
35 |
-
else
|
36 |
summary = summarize(text)
|
37 |
return templates.TemplateResponse(
|
38 |
"index.html.jinja", {"request": request, "text": text, "summary": summary}
|
39 |
)
|
|
|
|
|
40 |
# ------------------------------------------------------------------------------------
|
41 |
|
42 |
|
|
|
10 |
# appel de la fonction inference, adaptee pour une entree txt
|
11 |
def summarize(text: str):
|
12 |
return " ".join(inferenceAPI(text))
|
13 |
+
|
14 |
+
|
15 |
# ----------------------------------------------------------------------------------
|
16 |
|
17 |
|
|
|
22 |
templates = Jinja2Templates(directory="templates")
|
23 |
app.mount("/templates", StaticFiles(directory="templates"), name="templates")
|
24 |
|
25 |
+
|
26 |
@app.get("/")
|
27 |
async def index(request: Request):
|
28 |
return templates.TemplateResponse("index.html.jinja", {"request": request})
|
29 |
|
30 |
+
|
31 |
# retourner le texte, les predictions et message d'erreur si formulaire envoye vide
|
32 |
@app.post("/")
|
33 |
async def prediction(request: Request, text: str = Form(None)):
|
34 |
+
if not text:
|
35 |
error = "Merci de saisir votre texte."
|
36 |
return templates.TemplateResponse(
|
37 |
+
"index.html.jinja", {"request": request, "text": error}
|
38 |
+
)
|
39 |
+
else:
|
40 |
summary = summarize(text)
|
41 |
return templates.TemplateResponse(
|
42 |
"index.html.jinja", {"request": request, "text": text, "summary": summary}
|
43 |
)
|
44 |
+
|
45 |
+
|
46 |
# ------------------------------------------------------------------------------------
|
47 |
|
48 |
|
src/model.py
CHANGED
@@ -8,6 +8,7 @@ import torch
|
|
8 |
|
9 |
logging.basicConfig(level=logging.DEBUG)
|
10 |
|
|
|
11 |
class Encoder(torch.nn.Module):
|
12 |
def __init__(
|
13 |
self,
|
|
|
8 |
|
9 |
logging.basicConfig(level=logging.DEBUG)
|
10 |
|
11 |
+
|
12 |
class Encoder(torch.nn.Module):
|
13 |
def __init__(
|
14 |
self,
|