Spaces:
Build error
Build error
Commit
·
85a1e8f
1
Parent(s):
8420f0f
added loading bar and did corrections in docs
Browse files- app/static/demo/index/script.js +16 -2
- app/static/docs/data.json +1 -1
- app/static/global.css +3 -0
- app/static/loader.css +37 -0
- app/static/user/dashboard.js +17 -2
- app/templates/base.html +1 -0
- app/templates/demo/index.html +1 -0
- app/templates/docs/index.html +1 -1
- app/templates/loader.html +2 -0
- app/templates/user/dashboard.html +1 -0
app/static/demo/index/script.js
CHANGED
|
@@ -98,7 +98,7 @@ database_input.addEventListener("change", function(e){
|
|
| 98 |
const formdata = new FormData();
|
| 99 |
formdata.append("a",23);
|
| 100 |
formdata.append("image",e.target.files[0]);
|
| 101 |
-
|
| 102 |
fetch("/demo/add_crops/",
|
| 103 |
{
|
| 104 |
method:'POST',
|
|
@@ -114,7 +114,7 @@ database_input.addEventListener("change", function(e){
|
|
| 114 |
console.log(response);
|
| 115 |
if (response['message']=='successful')
|
| 116 |
{
|
| 117 |
-
|
| 118 |
var images_div=document.querySelector("#db_images_bar>#db_images");
|
| 119 |
var img_container_tag=document.createElement("div");
|
| 120 |
var img_remove_tag=document.createElement("p");
|
|
@@ -397,12 +397,14 @@ function face_recognition(elem)
|
|
| 397 |
return ;
|
| 398 |
}
|
| 399 |
// console.log(elem.files[0]);
|
|
|
|
| 400 |
fetch("/demo/face_recognition/",{
|
| 401 |
method:"POST",
|
| 402 |
body:formdata
|
| 403 |
}).then(function(response){
|
| 404 |
return response.json();
|
| 405 |
}).then(function(response){
|
|
|
|
| 406 |
console.log(response);
|
| 407 |
document.querySelector("#face_rec_image").src="data:image/jpeg;base64,"+response['image'].split('\'')[1];
|
| 408 |
})
|
|
@@ -499,4 +501,16 @@ function reset_settings(){
|
|
| 499 |
update_settings_html(res);
|
| 500 |
}
|
| 501 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
}
|
|
|
|
| 98 |
const formdata = new FormData();
|
| 99 |
formdata.append("a",23);
|
| 100 |
formdata.append("image",e.target.files[0]);
|
| 101 |
+
show_loading_bar();
|
| 102 |
fetch("/demo/add_crops/",
|
| 103 |
{
|
| 104 |
method:'POST',
|
|
|
|
| 114 |
console.log(response);
|
| 115 |
if (response['message']=='successful')
|
| 116 |
{
|
| 117 |
+
hide_loading_bar();
|
| 118 |
var images_div=document.querySelector("#db_images_bar>#db_images");
|
| 119 |
var img_container_tag=document.createElement("div");
|
| 120 |
var img_remove_tag=document.createElement("p");
|
|
|
|
| 397 |
return ;
|
| 398 |
}
|
| 399 |
// console.log(elem.files[0]);
|
| 400 |
+
show_loading_bar();
|
| 401 |
fetch("/demo/face_recognition/",{
|
| 402 |
method:"POST",
|
| 403 |
body:formdata
|
| 404 |
}).then(function(response){
|
| 405 |
return response.json();
|
| 406 |
}).then(function(response){
|
| 407 |
+
hide_loading_bar();
|
| 408 |
console.log(response);
|
| 409 |
document.querySelector("#face_rec_image").src="data:image/jpeg;base64,"+response['image'].split('\'')[1];
|
| 410 |
})
|
|
|
|
| 501 |
update_settings_html(res);
|
| 502 |
}
|
| 503 |
);
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
var loader=document.querySelector(".loader");
|
| 509 |
+
|
| 510 |
+
function show_loading_bar(){
|
| 511 |
+
loader.classList.remove("hidden");
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
function hide_loading_bar(){
|
| 515 |
+
loader.classList.add("hidden");
|
| 516 |
}
|
app/static/docs/data.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
| 31 |
{"name":"message","summary":"\"success\" if everything is fine.","type":"Text"},
|
| 32 |
{"name":"pred_image","summary":"image with prediction boxes","type":"base64"},
|
| 33 |
{"name":"person_ids","summary":"list of person_id(\"face\" if face is not found)","type":"list of string"},
|
| 34 |
-
{"name":"crops","summary":"return list of
|
| 35 |
{"name":"objs_found","summary":"dictionary of faces found with coordinates and names .","type":"dictionary"}
|
| 36 |
]
|
| 37 |
}
|
|
|
|
| 31 |
{"name":"message","summary":"\"success\" if everything is fine.","type":"Text"},
|
| 32 |
{"name":"pred_image","summary":"image with prediction boxes","type":"base64"},
|
| 33 |
{"name":"person_ids","summary":"list of person_id(\"face\" if face is not found)","type":"list of string"},
|
| 34 |
+
{"name":"crops","summary":"return list of cropped images.","type":"list of base64 values"},
|
| 35 |
{"name":"objs_found","summary":"dictionary of faces found with coordinates and names .","type":"dictionary"}
|
| 36 |
]
|
| 37 |
}
|
app/static/global.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body{
|
| 2 |
+
position: relative;
|
| 3 |
+
}
|
app/static/loader.css
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
.loader{
|
| 3 |
+
width: 100%;
|
| 4 |
+
height:20px;
|
| 5 |
+
background: white;
|
| 6 |
+
/* -webkit-box-reflect: below 1px linear-gradient(transparent,#0005); */
|
| 7 |
+
position: absolute;
|
| 8 |
+
top: 0;
|
| 9 |
+
border-radius: 50px;
|
| 10 |
+
overflow: hidden;
|
| 11 |
+
z-index: 23;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
.loader::before{
|
| 15 |
+
content:"";
|
| 16 |
+
position:absolute;
|
| 17 |
+
inset:0;
|
| 18 |
+
background: linear-gradient(90deg,#fb0094,#0000ff,#00ff00,#ffff00,#fb0094,#0000ff,#00ff00,#ffff00,#fb0094);
|
| 19 |
+
animation:loader_animate 20s linear infinite;
|
| 20 |
+
background-size:500%;
|
| 21 |
+
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
@keyframes loader_animate {
|
| 25 |
+
0%{
|
| 26 |
+
background-position: 0 0;
|
| 27 |
+
}
|
| 28 |
+
0%{
|
| 29 |
+
background-position: 500% 0;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.loader.hidden{
|
| 35 |
+
display: none;
|
| 36 |
+
|
| 37 |
+
}
|
app/static/user/dashboard.js
CHANGED
|
@@ -191,7 +191,7 @@ function filterFunction() {
|
|
| 191 |
|
| 192 |
const formdata = new FormData();
|
| 193 |
formdata.append("image",e.target.files[0]);
|
| 194 |
-
|
| 195 |
|
| 196 |
fetch("get_crops/",
|
| 197 |
{
|
|
@@ -205,6 +205,7 @@ function filterFunction() {
|
|
| 205 |
).then(
|
| 206 |
function(response)
|
| 207 |
{
|
|
|
|
| 208 |
console.log(response);
|
| 209 |
|
| 210 |
if (response['message']=='successful')
|
|
@@ -277,7 +278,7 @@ function update_db_crops(elem)
|
|
| 277 |
alldata["person_name"]=document.querySelector("#database-form>.field>.person_name").value;
|
| 278 |
alldata["remarks"]=all_remarks;
|
| 279 |
console.log(alldata);
|
| 280 |
-
|
| 281 |
|
| 282 |
|
| 283 |
fetch("set_crops/",{
|
|
@@ -287,6 +288,7 @@ function update_db_crops(elem)
|
|
| 287 |
}).then(function(response){
|
| 288 |
return response.json();
|
| 289 |
}).then(function(response){
|
|
|
|
| 290 |
console.log(response);
|
| 291 |
var person_ids=document.querySelectorAll("#db_people_table>tr>td:first-child");
|
| 292 |
var matching_person_id=null;
|
|
@@ -315,12 +317,14 @@ function face_recoginization(elem){
|
|
| 315 |
if(elem.files[0]){
|
| 316 |
formdata=new FormData();
|
| 317 |
formdata.append("image",elem.files[0]);
|
|
|
|
| 318 |
fetch("face_recognize/",{
|
| 319 |
method:"POST",
|
| 320 |
body:formdata
|
| 321 |
}).then(function(response){
|
| 322 |
return response.json();
|
| 323 |
}).then(function(response){
|
|
|
|
| 324 |
console.log(response);
|
| 325 |
document.querySelector("#face_recognition_image").src="data:image/jpeg;base64,"+response["pred_image"].split('\'')[1];
|
| 326 |
document.querySelector("#face_recognition_image").style.width="unset";
|
|
@@ -483,4 +487,15 @@ function reset_settings(){
|
|
| 483 |
update_settings_html(res);
|
| 484 |
}
|
| 485 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
}
|
|
|
|
| 191 |
|
| 192 |
const formdata = new FormData();
|
| 193 |
formdata.append("image",e.target.files[0]);
|
| 194 |
+
show_loading_bar()
|
| 195 |
|
| 196 |
fetch("get_crops/",
|
| 197 |
{
|
|
|
|
| 205 |
).then(
|
| 206 |
function(response)
|
| 207 |
{
|
| 208 |
+
hide_loading_bar()
|
| 209 |
console.log(response);
|
| 210 |
|
| 211 |
if (response['message']=='successful')
|
|
|
|
| 278 |
alldata["person_name"]=document.querySelector("#database-form>.field>.person_name").value;
|
| 279 |
alldata["remarks"]=all_remarks;
|
| 280 |
console.log(alldata);
|
| 281 |
+
show_loading_bar();
|
| 282 |
|
| 283 |
|
| 284 |
fetch("set_crops/",{
|
|
|
|
| 288 |
}).then(function(response){
|
| 289 |
return response.json();
|
| 290 |
}).then(function(response){
|
| 291 |
+
hide_loading_bar();
|
| 292 |
console.log(response);
|
| 293 |
var person_ids=document.querySelectorAll("#db_people_table>tr>td:first-child");
|
| 294 |
var matching_person_id=null;
|
|
|
|
| 317 |
if(elem.files[0]){
|
| 318 |
formdata=new FormData();
|
| 319 |
formdata.append("image",elem.files[0]);
|
| 320 |
+
show_loading_bar();
|
| 321 |
fetch("face_recognize/",{
|
| 322 |
method:"POST",
|
| 323 |
body:formdata
|
| 324 |
}).then(function(response){
|
| 325 |
return response.json();
|
| 326 |
}).then(function(response){
|
| 327 |
+
hide_loading_bar();
|
| 328 |
console.log(response);
|
| 329 |
document.querySelector("#face_recognition_image").src="data:image/jpeg;base64,"+response["pred_image"].split('\'')[1];
|
| 330 |
document.querySelector("#face_recognition_image").style.width="unset";
|
|
|
|
| 487 |
update_settings_html(res);
|
| 488 |
}
|
| 489 |
);
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
|
| 493 |
+
var loader=document.querySelector(".loader");
|
| 494 |
+
|
| 495 |
+
function show_loading_bar(){
|
| 496 |
+
loader.classList.remove("hidden");
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
function hide_loading_bar(){
|
| 500 |
+
loader.classList.add("hidden");
|
| 501 |
}
|
app/templates/base.html
CHANGED
|
@@ -4,6 +4,7 @@
|
|
| 4 |
<title>{% block title %}Face Recognization{% endblock %}</title>
|
| 5 |
|
| 6 |
<link type="image/*" rel="icon" href="{{ url_for('static',filename='demo/index/icon.jpg' ) }}">
|
|
|
|
| 7 |
|
| 8 |
{% block css %}{% endblock %}
|
| 9 |
</head>
|
|
|
|
| 4 |
<title>{% block title %}Face Recognization{% endblock %}</title>
|
| 5 |
|
| 6 |
<link type="image/*" rel="icon" href="{{ url_for('static',filename='demo/index/icon.jpg' ) }}">
|
| 7 |
+
<link type="text/css" rel="stylesheet" href="{{ url_for('static',filename='global.css' ) }}">
|
| 8 |
|
| 9 |
{% block css %}{% endblock %}
|
| 10 |
</head>
|
app/templates/demo/index.html
CHANGED
|
@@ -6,6 +6,7 @@
|
|
| 6 |
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
|
| 7 |
{% endblock %}
|
| 8 |
{% block body %}
|
|
|
|
| 9 |
<i class="fa-solid fa-gear settings_btn" onclick="show_settings();"></i>
|
| 10 |
<div id="container">
|
| 11 |
<div class="left-section">
|
|
|
|
| 6 |
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
|
| 7 |
{% endblock %}
|
| 8 |
{% block body %}
|
| 9 |
+
{% include 'loader.html' %}
|
| 10 |
<i class="fa-solid fa-gear settings_btn" onclick="show_settings();"></i>
|
| 11 |
<div id="container">
|
| 12 |
<div class="left-section">
|
app/templates/docs/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
|
| 7 |
{% endblock %}
|
| 8 |
{% block body %}
|
| 9 |
-
<h1>API
|
| 10 |
|
| 11 |
<div class="container">
|
| 12 |
|
|
|
|
| 6 |
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
|
| 7 |
{% endblock %}
|
| 8 |
{% block body %}
|
| 9 |
+
<h1>API documentation</h1>
|
| 10 |
|
| 11 |
<div class="container">
|
| 12 |
|
app/templates/loader.html
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<link type="text/css" rel="stylesheet" href="{{ url_for('static',filename='loader.css') }}">
|
| 2 |
+
<div class="loader hidden"></div>
|
app/templates/user/dashboard.html
CHANGED
|
@@ -22,6 +22,7 @@
|
|
| 22 |
{% elif data_dict['access_key']=='rejected' %}
|
| 23 |
<p>sorry you are not given access </p>
|
| 24 |
{% else %}
|
|
|
|
| 25 |
<i class="fa-solid fa-gear settings_btn" onclick="show_settings();"></i>
|
| 26 |
<div id="container">
|
| 27 |
<div id="api-key">
|
|
|
|
| 22 |
{% elif data_dict['access_key']=='rejected' %}
|
| 23 |
<p>sorry you are not given access </p>
|
| 24 |
{% else %}
|
| 25 |
+
{% include 'loader.html' %}
|
| 26 |
<i class="fa-solid fa-gear settings_btn" onclick="show_settings();"></i>
|
| 27 |
<div id="container">
|
| 28 |
<div id="api-key">
|