Spaces:
Sleeping
Sleeping
Kousik Kumar Siddavaram
commited on
Commit
·
b4a4baf
1
Parent(s):
58e24be
Update FastAPI app and templates for Hugging Face Space
Browse files- app/main.py +67 -91
- app/main_bkp.py +148 -0
- app/templates/expr_recognition.html +7 -12
- app/templates/expr_recognition_bkp.html +32 -0
- app/templates/face_recognition.html +7 -12
- app/templates/face_recognition_bkp.html +32 -0
- app/templates/index.html +15 -13
- app/templates/index_bkp.html +29 -0
- app/templates/predict_expr_recognition.html +19 -18
- app/templates/predict_expr_recognition_bkp.html +37 -0
- app/templates/predict_face_recognition.html +19 -18
- app/templates/predict_face_recognition_bkp.html +37 -0
- app/templates/predict_similarity.html +20 -19
- app/templates/predict_similarity_bkp.html +38 -0
- app/templates/similarity_bkp.html +35 -0
app/main.py
CHANGED
|
@@ -1,137 +1,114 @@
|
|
| 1 |
import sys
|
| 2 |
from pathlib import Path
|
| 3 |
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
| 4 |
-
#print(sys.path)
|
| 5 |
-
from typing import Any
|
| 6 |
|
| 7 |
-
from fastapi import FastAPI, Request,
|
| 8 |
from fastapi.staticfiles import StaticFiles
|
| 9 |
from fastapi.templating import Jinja2Templates
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
| 11 |
from app.config import settings
|
| 12 |
-
from app import __version__
|
| 13 |
from app.Hackathon_setup import face_recognition, exp_recognition
|
| 14 |
|
| 15 |
import numpy as np
|
| 16 |
from PIL import Image
|
| 17 |
|
| 18 |
-
|
| 19 |
app = FastAPI(
|
| 20 |
title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
| 21 |
)
|
| 22 |
|
| 23 |
-
#
|
| 24 |
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
| 25 |
|
| 26 |
-
#
|
| 27 |
templates = Jinja2Templates(directory="app/templates")
|
| 28 |
|
| 29 |
-
|
| 30 |
-
simi_filename2 = None
|
| 31 |
-
face_rec_filename = None
|
| 32 |
-
expr_rec_filename = None
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
#################################### Home Page endpoints #################################################
|
| 36 |
@app.get("/")
|
| 37 |
async def root(request: Request):
|
| 38 |
-
return templates.TemplateResponse("index.html", {
|
| 39 |
|
| 40 |
-
|
| 41 |
-
#################################### Face Similarity endpoints #################################################
|
| 42 |
@app.get("/similarity/")
|
| 43 |
async def similarity_root(request: Request):
|
| 44 |
-
return templates.TemplateResponse("similarity.html", {
|
| 45 |
-
|
| 46 |
|
| 47 |
@app.post("/predict_similarity/")
|
| 48 |
-
async def
|
| 49 |
-
global simi_filename1
|
| 50 |
-
global simi_filename2
|
| 51 |
-
|
| 52 |
-
if 'image' in file1.content_type:
|
| 53 |
-
contents = await file1.read()
|
| 54 |
-
simi_filename1 = 'app/static/' + file1.filename
|
| 55 |
-
with open(simi_filename1, 'wb') as f:
|
| 56 |
-
f.write(contents)
|
| 57 |
-
|
| 58 |
-
if 'image' in file2.content_type:
|
| 59 |
-
contents = await file2.read()
|
| 60 |
-
simi_filename2 = 'app/static/' + file2.filename
|
| 61 |
-
with open(simi_filename2, 'wb') as f:
|
| 62 |
-
f.write(contents)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
img2 = Image.open(simi_filename2)
|
| 68 |
-
img2 = np.array(img2).reshape(img2.size[1], img2.size[0], 3).astype(np.uint8)
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
result = face_recognition.get_similarity(img1, img2)
|
| 71 |
-
#print(result)
|
| 72 |
|
| 73 |
-
return templates.TemplateResponse("predict_similarity.html", {
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
@app.get("/face_recognition/")
|
| 81 |
async def face_recognition_root(request: Request):
|
| 82 |
-
return templates.TemplateResponse("face_recognition.html", {
|
| 83 |
-
|
| 84 |
|
| 85 |
@app.post("/predict_face_recognition/")
|
| 86 |
-
async def
|
| 87 |
-
global face_rec_filename
|
| 88 |
-
|
| 89 |
-
if 'image' in file3.content_type:
|
| 90 |
-
contents = await file3.read()
|
| 91 |
-
face_rec_filename = 'app/static/' + file3.filename
|
| 92 |
-
with open(face_rec_filename, 'wb') as f:
|
| 93 |
-
f.write(contents)
|
| 94 |
-
|
| 95 |
-
img1 = Image.open(face_rec_filename)
|
| 96 |
-
img1 = np.array(img1).reshape(img1.size[1], img1.size[0], 3).astype(np.uint8)
|
| 97 |
-
|
| 98 |
-
result = face_recognition.get_face_class(img1)
|
| 99 |
-
print(result)
|
| 100 |
-
|
| 101 |
-
return templates.TemplateResponse("predict_face_recognition.html", {"request": request,
|
| 102 |
-
"result": result,
|
| 103 |
-
"face_rec_filename": '../static/'+file3.filename,})
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
@app.get("/expr_recognition/")
|
| 108 |
async def expr_recognition_root(request: Request):
|
| 109 |
-
return templates.TemplateResponse("expr_recognition.html", {
|
| 110 |
-
|
| 111 |
|
| 112 |
@app.post("/predict_expr_recognition/")
|
| 113 |
-
async def
|
| 114 |
-
global expr_rec_filename
|
| 115 |
-
|
| 116 |
-
if 'image' in file4.content_type:
|
| 117 |
-
contents = await file4.read()
|
| 118 |
-
expr_rec_filename = 'app/static/' + file4.filename
|
| 119 |
-
with open(expr_rec_filename, 'wb') as f:
|
| 120 |
-
f.write(contents)
|
| 121 |
-
|
| 122 |
-
img1 = Image.open(expr_rec_filename)
|
| 123 |
-
img1 = np.array(img1).reshape(img1.size[1], img1.size[0], 3).astype(np.uint8)
|
| 124 |
-
|
| 125 |
-
result = exp_recognition.get_expression(img1)
|
| 126 |
-
print(result)
|
| 127 |
-
|
| 128 |
-
return templates.TemplateResponse("predict_expr_recognition.html", {"request": request,
|
| 129 |
-
"result": result,
|
| 130 |
-
"expr_rec_filename": '../static/'+file4.filename,})
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
|
|
|
| 133 |
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
if settings.BACKEND_CORS_ORIGINS:
|
| 136 |
app.add_middleware(
|
| 137 |
CORSMiddleware,
|
|
@@ -141,8 +118,7 @@ if settings.BACKEND_CORS_ORIGINS:
|
|
| 141 |
allow_headers=["*"],
|
| 142 |
)
|
| 143 |
|
| 144 |
-
|
| 145 |
-
# Start app
|
| 146 |
if __name__ == "__main__":
|
| 147 |
import uvicorn
|
| 148 |
uvicorn.run(app, host="0.0.0.0", port=8001)
|
|
|
|
| 1 |
import sys
|
| 2 |
from pathlib import Path
|
| 3 |
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
from fastapi import FastAPI, Request, File, UploadFile
|
| 6 |
from fastapi.staticfiles import StaticFiles
|
| 7 |
from fastapi.templating import Jinja2Templates
|
| 8 |
from fastapi.middleware.cors import CORSMiddleware
|
| 9 |
+
|
| 10 |
from app.config import settings
|
|
|
|
| 11 |
from app.Hackathon_setup import face_recognition, exp_recognition
|
| 12 |
|
| 13 |
import numpy as np
|
| 14 |
from PIL import Image
|
| 15 |
|
|
|
|
| 16 |
app = FastAPI(
|
| 17 |
title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
| 18 |
)
|
| 19 |
|
| 20 |
+
# Mount static folder
|
| 21 |
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
| 22 |
|
| 23 |
+
# Templates folder
|
| 24 |
templates = Jinja2Templates(directory="app/templates")
|
| 25 |
|
| 26 |
+
#################################### Home Page ####################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
@app.get("/")
|
| 28 |
async def root(request: Request):
|
| 29 |
+
return templates.TemplateResponse("index.html", {"request": request})
|
| 30 |
|
| 31 |
+
#################################### Face Similarity ####################################
|
|
|
|
| 32 |
@app.get("/similarity/")
|
| 33 |
async def similarity_root(request: Request):
|
| 34 |
+
return templates.TemplateResponse("similarity.html", {"request": request})
|
|
|
|
| 35 |
|
| 36 |
@app.post("/predict_similarity/")
|
| 37 |
+
async def predict_similarity(request: Request, file1: UploadFile = File(...), file2: UploadFile = File(...)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
# Save uploaded images
|
| 40 |
+
path1 = f'app/static/{file1.filename}'
|
| 41 |
+
path2 = f'app/static/{file2.filename}'
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
contents1 = await file1.read()
|
| 44 |
+
with open(path1, 'wb') as f:
|
| 45 |
+
f.write(contents1)
|
| 46 |
+
|
| 47 |
+
contents2 = await file2.read()
|
| 48 |
+
with open(path2, 'wb') as f:
|
| 49 |
+
f.write(contents2)
|
| 50 |
+
|
| 51 |
+
# Open images as RGB
|
| 52 |
+
img1 = np.array(Image.open(path1).convert("RGB"))
|
| 53 |
+
img2 = np.array(Image.open(path2).convert("RGB"))
|
| 54 |
+
|
| 55 |
+
# Compute similarity
|
| 56 |
result = face_recognition.get_similarity(img1, img2)
|
|
|
|
| 57 |
|
| 58 |
+
return templates.TemplateResponse("predict_similarity.html", {
|
| 59 |
+
"request": request,
|
| 60 |
+
"result": np.round(result, 3),
|
| 61 |
+
"simi_filename1": f"/static/{file1.filename}",
|
| 62 |
+
"simi_filename2": f"/static/{file2.filename}"
|
| 63 |
+
})
|
| 64 |
+
|
| 65 |
+
#################################### Face Recognition ####################################
|
| 66 |
@app.get("/face_recognition/")
|
| 67 |
async def face_recognition_root(request: Request):
|
| 68 |
+
return templates.TemplateResponse("face_recognition.html", {"request": request})
|
|
|
|
| 69 |
|
| 70 |
@app.post("/predict_face_recognition/")
|
| 71 |
+
async def predict_face_recognition(request: Request, file3: UploadFile = File(...)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
path = f'app/static/{file3.filename}'
|
| 74 |
+
contents = await file3.read()
|
| 75 |
+
with open(path, 'wb') as f:
|
| 76 |
+
f.write(contents)
|
| 77 |
|
| 78 |
+
img = np.array(Image.open(path).convert("RGB"))
|
| 79 |
+
|
| 80 |
+
result = face_recognition.get_face_class(img)
|
| 81 |
+
|
| 82 |
+
return templates.TemplateResponse("predict_face_recognition.html", {
|
| 83 |
+
"request": request,
|
| 84 |
+
"result": result,
|
| 85 |
+
"face_rec_filename": f"/static/{file3.filename}"
|
| 86 |
+
})
|
| 87 |
+
|
| 88 |
+
#################################### Expression Recognition ####################################
|
| 89 |
@app.get("/expr_recognition/")
|
| 90 |
async def expr_recognition_root(request: Request):
|
| 91 |
+
return templates.TemplateResponse("expr_recognition.html", {"request": request})
|
|
|
|
| 92 |
|
| 93 |
@app.post("/predict_expr_recognition/")
|
| 94 |
+
async def predict_expr_recognition(request: Request, file4: UploadFile = File(...)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
path = f'app/static/{file4.filename}'
|
| 97 |
+
contents = await file4.read()
|
| 98 |
+
with open(path, 'wb') as f:
|
| 99 |
+
f.write(contents)
|
| 100 |
|
| 101 |
+
img = np.array(Image.open(path).convert("RGB"))
|
| 102 |
|
| 103 |
+
result = exp_recognition.get_expression(img)
|
| 104 |
+
|
| 105 |
+
return templates.TemplateResponse("predict_expr_recognition.html", {
|
| 106 |
+
"request": request,
|
| 107 |
+
"result": result,
|
| 108 |
+
"expr_rec_filename": f"/static/{file4.filename}"
|
| 109 |
+
})
|
| 110 |
+
|
| 111 |
+
#################################### CORS Middleware ####################################
|
| 112 |
if settings.BACKEND_CORS_ORIGINS:
|
| 113 |
app.add_middleware(
|
| 114 |
CORSMiddleware,
|
|
|
|
| 118 |
allow_headers=["*"],
|
| 119 |
)
|
| 120 |
|
| 121 |
+
#################################### Run App ####################################
|
|
|
|
| 122 |
if __name__ == "__main__":
|
| 123 |
import uvicorn
|
| 124 |
uvicorn.run(app, host="0.0.0.0", port=8001)
|
app/main_bkp.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
| 4 |
+
#print(sys.path)
|
| 5 |
+
from typing import Any
|
| 6 |
+
|
| 7 |
+
from fastapi import FastAPI, Request, APIRouter, File, UploadFile
|
| 8 |
+
from fastapi.staticfiles import StaticFiles
|
| 9 |
+
from fastapi.templating import Jinja2Templates
|
| 10 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 11 |
+
from app.config import settings
|
| 12 |
+
from app import __version__
|
| 13 |
+
from app.Hackathon_setup import face_recognition, exp_recognition
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
from PIL import Image
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
app = FastAPI(
|
| 20 |
+
title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# To store files uploaded by users
|
| 24 |
+
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
| 25 |
+
|
| 26 |
+
# To access Templates directory
|
| 27 |
+
templates = Jinja2Templates(directory="app/templates")
|
| 28 |
+
|
| 29 |
+
simi_filename1 = None
|
| 30 |
+
simi_filename2 = None
|
| 31 |
+
face_rec_filename = None
|
| 32 |
+
expr_rec_filename = None
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
#################################### Home Page endpoints #################################################
|
| 36 |
+
@app.get("/")
|
| 37 |
+
async def root(request: Request):
|
| 38 |
+
return templates.TemplateResponse("index.html", {'request': request,})
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
#################################### Face Similarity endpoints #################################################
|
| 42 |
+
@app.get("/similarity/")
|
| 43 |
+
async def similarity_root(request: Request):
|
| 44 |
+
return templates.TemplateResponse("similarity.html", {'request': request,})
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@app.post("/predict_similarity/")
|
| 48 |
+
async def create_upload_files(request: Request, file1: UploadFile = File(...), file2: UploadFile = File(...)):
|
| 49 |
+
global simi_filename1
|
| 50 |
+
global simi_filename2
|
| 51 |
+
|
| 52 |
+
if 'image' in file1.content_type:
|
| 53 |
+
contents = await file1.read()
|
| 54 |
+
simi_filename1 = 'app/static/' + file1.filename
|
| 55 |
+
with open(simi_filename1, 'wb') as f:
|
| 56 |
+
f.write(contents)
|
| 57 |
+
|
| 58 |
+
if 'image' in file2.content_type:
|
| 59 |
+
contents = await file2.read()
|
| 60 |
+
simi_filename2 = 'app/static/' + file2.filename
|
| 61 |
+
with open(simi_filename2, 'wb') as f:
|
| 62 |
+
f.write(contents)
|
| 63 |
+
|
| 64 |
+
img1 = Image.open(simi_filename1)
|
| 65 |
+
img1 = np.array(img1).reshape(img1.size[1], img1.size[0], 3).astype(np.uint8)
|
| 66 |
+
|
| 67 |
+
img2 = Image.open(simi_filename2)
|
| 68 |
+
img2 = np.array(img2).reshape(img2.size[1], img2.size[0], 3).astype(np.uint8)
|
| 69 |
+
|
| 70 |
+
result = face_recognition.get_similarity(img1, img2)
|
| 71 |
+
#print(result)
|
| 72 |
+
|
| 73 |
+
return templates.TemplateResponse("predict_similarity.html", {"request": request,
|
| 74 |
+
"result": np.round(result, 3),
|
| 75 |
+
"simi_filename1": '../static/'+file1.filename,
|
| 76 |
+
"simi_filename2": '../static/'+file2.filename,})
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
#################################### Face Recognition endpoints #################################################
|
| 80 |
+
@app.get("/face_recognition/")
|
| 81 |
+
async def face_recognition_root(request: Request):
|
| 82 |
+
return templates.TemplateResponse("face_recognition.html", {'request': request,})
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
@app.post("/predict_face_recognition/")
|
| 86 |
+
async def create_upload_files(request: Request, file3: UploadFile = File(...)):
|
| 87 |
+
global face_rec_filename
|
| 88 |
+
|
| 89 |
+
if 'image' in file3.content_type:
|
| 90 |
+
contents = await file3.read()
|
| 91 |
+
face_rec_filename = 'app/static/' + file3.filename
|
| 92 |
+
with open(face_rec_filename, 'wb') as f:
|
| 93 |
+
f.write(contents)
|
| 94 |
+
|
| 95 |
+
img1 = Image.open(face_rec_filename)
|
| 96 |
+
img1 = np.array(img1).reshape(img1.size[1], img1.size[0], 3).astype(np.uint8)
|
| 97 |
+
|
| 98 |
+
result = face_recognition.get_face_class(img1)
|
| 99 |
+
print(result)
|
| 100 |
+
|
| 101 |
+
return templates.TemplateResponse("predict_face_recognition.html", {"request": request,
|
| 102 |
+
"result": result,
|
| 103 |
+
"face_rec_filename": '../static/'+file3.filename,})
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
#################################### Expresion Recognition endpoints #################################################
|
| 107 |
+
@app.get("/expr_recognition/")
|
| 108 |
+
async def expr_recognition_root(request: Request):
|
| 109 |
+
return templates.TemplateResponse("expr_recognition.html", {'request': request,})
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
@app.post("/predict_expr_recognition/")
|
| 113 |
+
async def create_upload_files(request: Request, file4: UploadFile = File(...)):
|
| 114 |
+
global expr_rec_filename
|
| 115 |
+
|
| 116 |
+
if 'image' in file4.content_type:
|
| 117 |
+
contents = await file4.read()
|
| 118 |
+
expr_rec_filename = 'app/static/' + file4.filename
|
| 119 |
+
with open(expr_rec_filename, 'wb') as f:
|
| 120 |
+
f.write(contents)
|
| 121 |
+
|
| 122 |
+
img1 = Image.open(expr_rec_filename)
|
| 123 |
+
img1 = np.array(img1).reshape(img1.size[1], img1.size[0], 3).astype(np.uint8)
|
| 124 |
+
|
| 125 |
+
result = exp_recognition.get_expression(img1)
|
| 126 |
+
print(result)
|
| 127 |
+
|
| 128 |
+
return templates.TemplateResponse("predict_expr_recognition.html", {"request": request,
|
| 129 |
+
"result": result,
|
| 130 |
+
"expr_rec_filename": '../static/'+file4.filename,})
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
# Set all CORS enabled origins
|
| 135 |
+
if settings.BACKEND_CORS_ORIGINS:
|
| 136 |
+
app.add_middleware(
|
| 137 |
+
CORSMiddleware,
|
| 138 |
+
allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS],
|
| 139 |
+
allow_credentials=True,
|
| 140 |
+
allow_methods=["*"],
|
| 141 |
+
allow_headers=["*"],
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Start app
|
| 146 |
+
if __name__ == "__main__":
|
| 147 |
+
import uvicorn
|
| 148 |
+
uvicorn.run(app, host="0.0.0.0", port=8001)
|
app/templates/expr_recognition.html
CHANGED
|
@@ -1,31 +1,26 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
<title>
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
-
<h1 style="background-color:LightGray;">
|
| 9 |
-
|
| 10 |
</h1>
|
| 11 |
</div>
|
|
|
|
| 12 |
<div>
|
| 13 |
<fieldset>
|
| 14 |
-
<ul>
|
| 15 |
-
<!li>
|
| 16 |
-
<br>
|
| 17 |
<form action="/predict_expr_recognition/" enctype="multipart/form-data" method="post">
|
| 18 |
-
<
|
| 19 |
-
<input name="file4" type="file"
|
| 20 |
-
<br><br><br>
|
| 21 |
<button type="submit">Recognize Expression</button>
|
| 22 |
</form>
|
| 23 |
-
|
| 24 |
-
<br><br>
|
| 25 |
<form action="/" method="get">
|
| 26 |
<button type="submit">Home</button>
|
| 27 |
</form>
|
| 28 |
-
</ul>
|
| 29 |
</fieldset>
|
| 30 |
</div>
|
| 31 |
</body>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<title>Expression Recognition</title>
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
+
<h1 style="background-color:LightGray; text-align:center;">
|
| 9 |
+
Expression Recognition
|
| 10 |
</h1>
|
| 11 |
</div>
|
| 12 |
+
|
| 13 |
<div>
|
| 14 |
<fieldset>
|
|
|
|
|
|
|
|
|
|
| 15 |
<form action="/predict_expr_recognition/" enctype="multipart/form-data" method="post">
|
| 16 |
+
<label style="font-weight:bold;">Upload Image:</label><br><br>
|
| 17 |
+
<input name="file4" type="file" accept="image/*" required><br><br>
|
|
|
|
| 18 |
<button type="submit">Recognize Expression</button>
|
| 19 |
</form>
|
| 20 |
+
<br>
|
|
|
|
| 21 |
<form action="/" method="get">
|
| 22 |
<button type="submit">Home</button>
|
| 23 |
</form>
|
|
|
|
| 24 |
</fieldset>
|
| 25 |
</div>
|
| 26 |
</body>
|
app/templates/expr_recognition_bkp.html
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Index</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Expression Recognition</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<ul>
|
| 15 |
+
<!li>
|
| 16 |
+
<br>
|
| 17 |
+
<form action="/predict_expr_recognition/" enctype="multipart/form-data" method="post">
|
| 18 |
+
<span style="font-weight:bold;font-family:sans-serif">Upload Image:</span> <br><br>
|
| 19 |
+
<input name="file4" type="file" onchange="readURL(this);" />
|
| 20 |
+
<br><br><br>
|
| 21 |
+
<button type="submit">Recognize Expression</button>
|
| 22 |
+
</form>
|
| 23 |
+
<!/li>
|
| 24 |
+
<br><br>
|
| 25 |
+
<form action="/" method="get">
|
| 26 |
+
<button type="submit">Home</button>
|
| 27 |
+
</form>
|
| 28 |
+
</ul>
|
| 29 |
+
</fieldset>
|
| 30 |
+
</div>
|
| 31 |
+
</body>
|
| 32 |
+
</html>
|
app/templates/face_recognition.html
CHANGED
|
@@ -1,31 +1,26 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
<title>
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
-
<h1 style="background-color:LightGray;">
|
| 9 |
-
|
| 10 |
</h1>
|
| 11 |
</div>
|
|
|
|
| 12 |
<div>
|
| 13 |
<fieldset>
|
| 14 |
-
<ul>
|
| 15 |
-
<!li>
|
| 16 |
-
<br>
|
| 17 |
<form action="/predict_face_recognition/" enctype="multipart/form-data" method="post">
|
| 18 |
-
<
|
| 19 |
-
<input name="file3" type="file"
|
| 20 |
-
<br><br><br>
|
| 21 |
<button type="submit">Recognize Face</button>
|
| 22 |
</form>
|
| 23 |
-
|
| 24 |
-
<br><br>
|
| 25 |
<form action="/" method="get">
|
| 26 |
<button type="submit">Home</button>
|
| 27 |
</form>
|
| 28 |
-
</ul>
|
| 29 |
</fieldset>
|
| 30 |
</div>
|
| 31 |
</body>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<title>Face Recognition</title>
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
+
<h1 style="background-color:LightGray; text-align:center;">
|
| 9 |
+
Face Recognition
|
| 10 |
</h1>
|
| 11 |
</div>
|
| 12 |
+
|
| 13 |
<div>
|
| 14 |
<fieldset>
|
|
|
|
|
|
|
|
|
|
| 15 |
<form action="/predict_face_recognition/" enctype="multipart/form-data" method="post">
|
| 16 |
+
<label style="font-weight:bold;">Upload Image:</label><br><br>
|
| 17 |
+
<input name="file3" type="file" accept="image/*" required><br><br>
|
|
|
|
| 18 |
<button type="submit">Recognize Face</button>
|
| 19 |
</form>
|
| 20 |
+
<br>
|
|
|
|
| 21 |
<form action="/" method="get">
|
| 22 |
<button type="submit">Home</button>
|
| 23 |
</form>
|
|
|
|
| 24 |
</fieldset>
|
| 25 |
</div>
|
| 26 |
</body>
|
app/templates/face_recognition_bkp.html
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Index</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Face Recognition</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<ul>
|
| 15 |
+
<!li>
|
| 16 |
+
<br>
|
| 17 |
+
<form action="/predict_face_recognition/" enctype="multipart/form-data" method="post">
|
| 18 |
+
<span style="font-weight:bold;font-family:sans-serif">Upload Image:</span> <br><br>
|
| 19 |
+
<input name="file3" type="file" onchange="readURL(this);" />
|
| 20 |
+
<br><br><br>
|
| 21 |
+
<button type="submit">Recognize Face</button>
|
| 22 |
+
</form>
|
| 23 |
+
<!/li>
|
| 24 |
+
<br><br>
|
| 25 |
+
<form action="/" method="get">
|
| 26 |
+
<button type="submit">Home</button>
|
| 27 |
+
</form>
|
| 28 |
+
</ul>
|
| 29 |
+
</fieldset>
|
| 30 |
+
</div>
|
| 31 |
+
</body>
|
| 32 |
+
</html>
|
app/templates/index.html
CHANGED
|
@@ -1,28 +1,30 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
<title>
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
-
<h1 style="background-color:LightGray;">
|
| 9 |
-
|
| 10 |
</h1>
|
| 11 |
</div>
|
|
|
|
| 12 |
<div>
|
| 13 |
<fieldset>
|
| 14 |
-
|
| 15 |
-
<li><span style="font-weight:bold;font-family:sans-serif">Select a task:</span>
|
| 16 |
-
<br><br><br>
|
| 17 |
-
<form action="{{ url_for('similarity_root') }}"><button>Face Similarity</button></form>
|
| 18 |
-
<br><br>
|
| 19 |
-
<form action="{{ url_for('face_recognition_root') }}"><button>Face Recognition</button></form>
|
| 20 |
-
<br><br>
|
| 21 |
-
<form action="{{ url_for('expr_recognition_root') }}"><button>Expression Recognition</button></form>
|
| 22 |
<br>
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
<br>
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
</fieldset>
|
| 27 |
</div>
|
| 28 |
</body>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<title>Recognition Application</title>
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
+
<h1 style="background-color:LightGray; text-align:center;">
|
| 9 |
+
Recognition Application
|
| 10 |
</h1>
|
| 11 |
</div>
|
| 12 |
+
|
| 13 |
<div>
|
| 14 |
<fieldset>
|
| 15 |
+
<p style="font-weight:bold;">Select a task:</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
<br>
|
| 17 |
+
<form action="/similarity/">
|
| 18 |
+
<button type="submit">Face Similarity</button>
|
| 19 |
+
</form>
|
| 20 |
<br>
|
| 21 |
+
<form action="/face_recognition/">
|
| 22 |
+
<button type="submit">Face Recognition</button>
|
| 23 |
+
</form>
|
| 24 |
+
<br>
|
| 25 |
+
<form action="/expr_recognition/">
|
| 26 |
+
<button type="submit">Expression Recognition</button>
|
| 27 |
+
</form>
|
| 28 |
</fieldset>
|
| 29 |
</div>
|
| 30 |
</body>
|
app/templates/index_bkp.html
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Index</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Recognition Application</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<ul>
|
| 15 |
+
<li><span style="font-weight:bold;font-family:sans-serif">Select a task:</span>
|
| 16 |
+
<br><br><br>
|
| 17 |
+
<form action="{{ url_for('similarity_root') }}"><button>Face Similarity</button></form>
|
| 18 |
+
<br><br>
|
| 19 |
+
<form action="{{ url_for('face_recognition_root') }}"><button>Face Recognition</button></form>
|
| 20 |
+
<br><br>
|
| 21 |
+
<form action="{{ url_for('expr_recognition_root') }}"><button>Expression Recognition</button></form>
|
| 22 |
+
<br>
|
| 23 |
+
</li>
|
| 24 |
+
<br>
|
| 25 |
+
</ul>
|
| 26 |
+
</fieldset>
|
| 27 |
+
</div>
|
| 28 |
+
</body>
|
| 29 |
+
</html>
|
app/templates/predict_expr_recognition.html
CHANGED
|
@@ -5,33 +5,34 @@
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
-
<h1 style="background-color:LightGray;">
|
| 9 |
-
|
| 10 |
</h1>
|
| 11 |
</div>
|
|
|
|
| 12 |
<div>
|
| 13 |
<fieldset>
|
| 14 |
-
<h2>
|
| 15 |
-
<
|
| 16 |
-
|
| 17 |
-
<span style="font-weight:bold;color:blue"> {{result}}</span>
|
| 18 |
-
</center>
|
| 19 |
</h2>
|
| 20 |
-
|
| 21 |
-
<
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
</p>
|
| 26 |
-
|
| 27 |
-
<form action="/expr_recognition/" method="get">
|
| 28 |
-
<
|
| 29 |
</form>
|
| 30 |
<br>
|
| 31 |
-
<form action="/" method="get">
|
| 32 |
-
<
|
| 33 |
</form>
|
| 34 |
</fieldset>
|
| 35 |
</div>
|
| 36 |
</body>
|
| 37 |
-
</html>
|
|
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
+
<h1 style="background-color:LightGray; text-align:center;">
|
| 9 |
+
Expression Recognition
|
| 10 |
</h1>
|
| 11 |
</div>
|
| 12 |
+
|
| 13 |
<div>
|
| 14 |
<fieldset>
|
| 15 |
+
<h2 style="text-align:center;">
|
| 16 |
+
<span style="font-weight:bold;">Prediction:</span>
|
| 17 |
+
<span style="font-weight:bold;color:blue;">{{ result }}</span>
|
|
|
|
|
|
|
| 18 |
</h2>
|
| 19 |
+
|
| 20 |
+
<h3 style="text-align:center;">
|
| 21 |
+
<span style="font-weight:bold;">Input image:</span>
|
| 22 |
+
</h3>
|
| 23 |
+
|
| 24 |
+
<p style="text-align:center;">
|
| 25 |
+
<img src="{{ expr_rec_filename }}" alt="Input Image" width="150" height="150">
|
| 26 |
</p>
|
| 27 |
+
|
| 28 |
+
<form action="/expr_recognition/" method="get" style="text-align:center;">
|
| 29 |
+
<button type="submit">Check Another Input</button>
|
| 30 |
</form>
|
| 31 |
<br>
|
| 32 |
+
<form action="/" method="get" style="text-align:center;">
|
| 33 |
+
<button type="submit">Home</button>
|
| 34 |
</form>
|
| 35 |
</fieldset>
|
| 36 |
</div>
|
| 37 |
</body>
|
| 38 |
+
</html>
|
app/templates/predict_expr_recognition_bkp.html
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Predict</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Expression Recognition</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<h2>
|
| 15 |
+
<center>
|
| 16 |
+
<span style="font-weight:bold;font-family:sans-serif">Prediction: </span>
|
| 17 |
+
<span style="font-weight:bold;color:blue"> {{result}}</span>
|
| 18 |
+
</center>
|
| 19 |
+
</h2>
|
| 20 |
+
<h3><center><span style="font-weight:bold;font-family:sans-serif">Input image:</span></Input></center></h3>
|
| 21 |
+
<p>
|
| 22 |
+
<center>
|
| 23 |
+
<img src="{{expr_rec_filename}}" alt={{expr_rec_filename1}} width='150' height='150'>
|
| 24 |
+
</center>
|
| 25 |
+
</p>
|
| 26 |
+
<br>
|
| 27 |
+
<form action="/expr_recognition/" method="get">
|
| 28 |
+
<center><button type="submit">Check Another Input</button></center>
|
| 29 |
+
</form>
|
| 30 |
+
<br>
|
| 31 |
+
<form action="/" method="get">
|
| 32 |
+
<center><button type="submit">Home</button></center>
|
| 33 |
+
</form>
|
| 34 |
+
</fieldset>
|
| 35 |
+
</div>
|
| 36 |
+
</body>
|
| 37 |
+
</html>
|
app/templates/predict_face_recognition.html
CHANGED
|
@@ -5,33 +5,34 @@
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
-
<h1 style="background-color:LightGray;">
|
| 9 |
-
|
| 10 |
</h1>
|
| 11 |
</div>
|
|
|
|
| 12 |
<div>
|
| 13 |
<fieldset>
|
| 14 |
-
<h2>
|
| 15 |
-
<
|
| 16 |
-
|
| 17 |
-
<span style="font-weight:bold;color:blue"> {{result}}</span>
|
| 18 |
-
</center>
|
| 19 |
</h2>
|
| 20 |
-
|
| 21 |
-
<
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
</p>
|
| 26 |
-
|
| 27 |
-
<form action="/face_recognition/" method="get">
|
| 28 |
-
<
|
| 29 |
</form>
|
| 30 |
<br>
|
| 31 |
-
<form action="/" method="get">
|
| 32 |
-
<
|
| 33 |
</form>
|
| 34 |
</fieldset>
|
| 35 |
</div>
|
| 36 |
</body>
|
| 37 |
-
</html>
|
|
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
+
<h1 style="background-color:LightGray; text-align:center;">
|
| 9 |
+
Face Recognition
|
| 10 |
</h1>
|
| 11 |
</div>
|
| 12 |
+
|
| 13 |
<div>
|
| 14 |
<fieldset>
|
| 15 |
+
<h2 style="text-align:center;">
|
| 16 |
+
<span style="font-weight:bold;">Prediction:</span>
|
| 17 |
+
<span style="font-weight:bold;color:blue;">{{ result }}</span>
|
|
|
|
|
|
|
| 18 |
</h2>
|
| 19 |
+
|
| 20 |
+
<h3 style="text-align:center;">
|
| 21 |
+
<span style="font-weight:bold;">Input image:</span>
|
| 22 |
+
</h3>
|
| 23 |
+
|
| 24 |
+
<p style="text-align:center;">
|
| 25 |
+
<img src="{{ face_rec_filename }}" alt="Input Image" width="150" height="150">
|
| 26 |
</p>
|
| 27 |
+
|
| 28 |
+
<form action="/face_recognition/" method="get" style="text-align:center;">
|
| 29 |
+
<button type="submit">Check Another Input</button>
|
| 30 |
</form>
|
| 31 |
<br>
|
| 32 |
+
<form action="/" method="get" style="text-align:center;">
|
| 33 |
+
<button type="submit">Home</button>
|
| 34 |
</form>
|
| 35 |
</fieldset>
|
| 36 |
</div>
|
| 37 |
</body>
|
| 38 |
+
</html>
|
app/templates/predict_face_recognition_bkp.html
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Predict</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Face Recognition</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<h2>
|
| 15 |
+
<center>
|
| 16 |
+
<span style="font-weight:bold;font-family:sans-serif">Prediction: </span>
|
| 17 |
+
<span style="font-weight:bold;color:blue"> {{result}}</span>
|
| 18 |
+
</center>
|
| 19 |
+
</h2>
|
| 20 |
+
<h3><center><span style="font-weight:bold;font-family:sans-serif">Input image:</span></Input></center></h3>
|
| 21 |
+
<p>
|
| 22 |
+
<center>
|
| 23 |
+
<img src="{{face_rec_filename}}" alt={{face_rec_filename1}} width='150' height='150'>
|
| 24 |
+
</center>
|
| 25 |
+
</p>
|
| 26 |
+
<br>
|
| 27 |
+
<form action="/face_recognition/" method="get">
|
| 28 |
+
<center><button type="submit">Check Another Input</button></center>
|
| 29 |
+
</form>
|
| 30 |
+
<br>
|
| 31 |
+
<form action="/" method="get">
|
| 32 |
+
<center><button type="submit">Home</button></center>
|
| 33 |
+
</form>
|
| 34 |
+
</fieldset>
|
| 35 |
+
</div>
|
| 36 |
+
</body>
|
| 37 |
+
</html>
|
app/templates/predict_similarity.html
CHANGED
|
@@ -5,34 +5,35 @@
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
-
<h1 style="background-color:LightGray;">
|
| 9 |
-
|
| 10 |
</h1>
|
| 11 |
</div>
|
|
|
|
| 12 |
<div>
|
| 13 |
<fieldset>
|
| 14 |
-
<h2>
|
| 15 |
-
<
|
| 16 |
-
|
| 17 |
-
<span style="font-weight:bold;color:blue"> {{result}}</span>
|
| 18 |
-
</center>
|
| 19 |
</h2>
|
| 20 |
-
|
| 21 |
-
<
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
</p>
|
| 27 |
-
|
| 28 |
-
<form action="/similarity/" method="get">
|
| 29 |
-
<
|
| 30 |
</form>
|
| 31 |
<br>
|
| 32 |
-
<form action="/" method="get">
|
| 33 |
-
<
|
| 34 |
</form>
|
| 35 |
</fieldset>
|
| 36 |
</div>
|
| 37 |
</body>
|
| 38 |
-
</html>
|
|
|
|
| 5 |
</head>
|
| 6 |
<body>
|
| 7 |
<div>
|
| 8 |
+
<h1 style="background-color:LightGray; text-align:center;">
|
| 9 |
+
Face Similarity
|
| 10 |
</h1>
|
| 11 |
</div>
|
| 12 |
+
|
| 13 |
<div>
|
| 14 |
<fieldset>
|
| 15 |
+
<h2 style="text-align:center;">
|
| 16 |
+
<span style="font-weight:bold;">Dissimilarity:</span>
|
| 17 |
+
<span style="font-weight:bold;color:blue;">{{ result }}</span>
|
|
|
|
|
|
|
| 18 |
</h2>
|
| 19 |
+
|
| 20 |
+
<h3 style="text-align:center;">
|
| 21 |
+
<span style="font-weight:bold;">Input images:</span>
|
| 22 |
+
</h3>
|
| 23 |
+
|
| 24 |
+
<p style="text-align:center;">
|
| 25 |
+
<img src="{{ simi_filename1 }}" alt="First Image" width="150" height="150">
|
| 26 |
+
<img src="{{ simi_filename2 }}" alt="Second Image" width="150" height="150">
|
| 27 |
</p>
|
| 28 |
+
|
| 29 |
+
<form action="/similarity/" method="get" style="text-align:center;">
|
| 30 |
+
<button type="submit">Check Another Input</button>
|
| 31 |
</form>
|
| 32 |
<br>
|
| 33 |
+
<form action="/" method="get" style="text-align:center;">
|
| 34 |
+
<button type="submit">Home</button>
|
| 35 |
</form>
|
| 36 |
</fieldset>
|
| 37 |
</div>
|
| 38 |
</body>
|
| 39 |
+
</html>
|
app/templates/predict_similarity_bkp.html
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Predict</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Face Similarity</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<h2>
|
| 15 |
+
<center>
|
| 16 |
+
<span style="font-weight:bold;font-family:sans-serif">Dissimilarity:</span>
|
| 17 |
+
<span style="font-weight:bold;color:blue"> {{result}}</span>
|
| 18 |
+
</center>
|
| 19 |
+
</h2>
|
| 20 |
+
<h3><center><span style="font-weight:bold;font-family:sans-serif">Input images:</span></Input></center></h3>
|
| 21 |
+
<p>
|
| 22 |
+
<center>
|
| 23 |
+
<img src="{{simi_filename1}}" alt={{simi_filename1}} width='150' height='150'>
|
| 24 |
+
<img src="{{simi_filename2}}" alt={{simi_filename2}} width='150' height='150'>
|
| 25 |
+
</center>
|
| 26 |
+
</p>
|
| 27 |
+
<br>
|
| 28 |
+
<form action="/similarity/" method="get">
|
| 29 |
+
<center><button type="submit">Check Another Input</button></center>
|
| 30 |
+
</form>
|
| 31 |
+
<br>
|
| 32 |
+
<form action="/" method="get">
|
| 33 |
+
<center><button type="submit">Home</button></center>
|
| 34 |
+
</form>
|
| 35 |
+
</fieldset>
|
| 36 |
+
</div>
|
| 37 |
+
</body>
|
| 38 |
+
</html>
|
app/templates/similarity_bkp.html
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<title>Index</title>
|
| 5 |
+
</head>
|
| 6 |
+
<body>
|
| 7 |
+
<div>
|
| 8 |
+
<h1 style="background-color:LightGray;">
|
| 9 |
+
<center>Face Similarity</center>
|
| 10 |
+
</h1>
|
| 11 |
+
</div>
|
| 12 |
+
<div>
|
| 13 |
+
<fieldset>
|
| 14 |
+
<ul>
|
| 15 |
+
<!li>
|
| 16 |
+
<br>
|
| 17 |
+
<form action="/predict_similarity/" enctype="multipart/form-data" method="post">
|
| 18 |
+
<span style="font-weight:bold;font-family:sans-serif">Upload First Image:</span> <br><br>
|
| 19 |
+
<input name="file1" type="file" onchange="readURL(this);" />
|
| 20 |
+
<br><br><br>
|
| 21 |
+
<span style="font-weight:bold;font-family:sans-serif">Upload Second Image:</span> <br><br>
|
| 22 |
+
<input name="file2" type="file" onchange="readURL(this);" />
|
| 23 |
+
<br><br><br><br>
|
| 24 |
+
<button type="submit">Check Similarity</button>
|
| 25 |
+
</form>
|
| 26 |
+
<!/li>
|
| 27 |
+
<br><br>
|
| 28 |
+
<form action="/" method="get">
|
| 29 |
+
<button type="submit">Home</button>
|
| 30 |
+
</form>
|
| 31 |
+
</ul>
|
| 32 |
+
</fieldset>
|
| 33 |
+
</div>
|
| 34 |
+
</body>
|
| 35 |
+
</html>
|