Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-073
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-073
2022-073
Commits
ed2d0796
Commit
ed2d0796
authored
Nov 12, 2022
by
NilanDMeegoda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attention_span_fix
parent
cddc0e2a
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17770 additions
and
77 deletions
+17770
-77
web-app/backend/requirements.txt
web-app/backend/requirements.txt
+0
-0
web-app/backend/server.py
web-app/backend/server.py
+21
-16
web-app/backend/test_vids/Testing_vid
web-app/backend/test_vids/Testing_vid
+0
-0
web-app/frontend/package-lock.json
web-app/frontend/package-lock.json
+17743
-54
web-app/frontend/src/pages/attention_demo/attentionspan.jsx
web-app/frontend/src/pages/attention_demo/attentionspan.jsx
+6
-4
web-app/package-lock.json
web-app/package-lock.json
+0
-3
No files found.
web-app/backend/requirements.txt
View file @
ed2d0796
B
absl-py==1.2.0
...
...
web-app/backend/server.py
View file @
ed2d0796
...
...
@@ -21,45 +21,50 @@ from controler import captureImage
from
keras.models
import
load_model
from
sklearn.preprocessing
import
OneHotEncoder
from
datetime
import
datetime
# Attention classes
attClass
=
{
0
:
'Low Attention'
,
1
:
'Mid Attention'
,
2
:
'High Attention'
}
UPLOAD_FOLDER
=
'C:/SLIIT/Final Research implementation/Backend/new model 2.0/Main Project code/uploads'
ALLOWED_EXTENSIONS
=
set
(
[
'mkv'
,
'webm'
,
'mp4'
,
'txt'
,
'pdf'
,
'png'
,
'jpg'
,
'jpeg'
,
'gif'
])
x
=
datetime
.
datetime
.
now
()
# Initializing flask app
app
=
Flask
(
__name__
)
cors
=
CORS
(
app
)
app
.
config
[
'CORS_HEADERS'
]
=
'Content-Type'
app
.
config
[
'UPLOAD_FOLDER'
]
=
UPLOAD_FOLDER
# for prediction
@
app
.
route
(
'/upload'
,
methods
=
[
'POST'
])
@
cross_origin
()
def
predictAttention
():
print
(
request
)
target
=
os
.
path
.
join
(
UPLOAD_FOLDER
,
'test_vids'
)
if
not
os
.
path
.
isdir
(
target
):
os
.
mkdir
(
target
)
directory
=
os
.
getcwd
()
dataJson
=
[]
file
=
request
.
files
[
'file'
]
testNo
=
request
.
form
.
get
(
'questionIndex'
)
filename
=
secure_filename
(
"Testing_vid"
)
destination
=
"/"
.
join
([
target
,
filename
])
file
.
save
(
destination
)
session
[
'uploadFilePath'
]
=
destination
filename
=
request
.
form
.
get
(
'filename'
)
if
file
is
None
or
filename
==
""
:
return
jsonify
({
'error: no file'
})
file
.
save
(
"./uploads/"
+
filename
)
destination
=
directory
+
r"\uploads\att.mp4"
scoreLst
=
captureImage
(
destination
,
10
)
dataDict
=
{
'low_attention'
:
scoreLst
[
0
],
'mid_attention'
:
scoreLst
[
1
],
'high_attention'
:
scoreLst
[
2
],
}
dataJson
.
append
(
dataDict
)
dt_string
=
datetime
.
now
()
.
strftime
(
"
%
d/
%
m/
%
Y
%
H:
%
M:
%
S"
)
db
.
db
[
'attentionlevelScore'
]
.
insert_one
({
"activityName"
:
"Manual_Attention_Test"
,
"questionIndex"
:
testNo
,
"attentionLevelScore"
:
scoreLst
,
"attentionLevelScore"
:
dataDict
,
"createdAt"
:
dt_string
,
})
print
(
"Prediction"
,
scoreLst
)
return
scoreLst
print
(
"Prediction02"
,
scoreLst
)
print
(
"Prediction"
,
dataDict
)
return
jsonify
(
dataJson
)
@
app
.
route
(
'/parents/'
,
methods
=
[
'POST'
,
'GET'
])
...
...
web-app/backend/test_vids/Testing_vid
deleted
100644 → 0
View file @
cddc0e2a
File deleted
web-app/frontend/package-lock.json
View file @
ed2d0796
This diff is collapsed.
Click to expand it.
web-app/frontend/src/pages/attention_demo/attentionspan.jsx
View file @
ed2d0796
...
...
@@ -70,6 +70,7 @@ const AttentionSpan_screen = () => {
console
.
log
(
"
testing
"
,
blob
);
const
data
=
new
FormData
();
data
.
append
(
"
file
"
,
blob
);
data
.
append
(
"
filename
"
,
"
att.mp4
"
)
data
.
append
(
"
questionIndex
"
,
id
);
await
API
.
post
(
"
upload
"
,
data
,
{
headers
:
{
...
...
@@ -77,7 +78,8 @@ const AttentionSpan_screen = () => {
},
})
.
then
((
res
)
=>
{
setattention
(
res
.
data
);
console
.
log
(
res
.
data
[
0
])
setattention
(
res
.
data
[
0
]);
setisClicked
(
true
);
})
.
catch
((
err
)
=>
{
...
...
@@ -221,15 +223,15 @@ const AttentionSpan_screen = () => {
<>
<
p
>
Low level attention :
{
"
"
}
{
attention
[
0
]
*
100
}
{
Math
.
round
(
attention
.
low_attention
*
100
)
/
100
}
</
p
>
<
p
>
Mid level attention :
{
"
"
}
{
attention
[
1
]
*
100
}
{
attention
.
mid_attention
*
100
}
</
p
>
<
p
>
High level attention :
{
"
"
}
{
attention
[
2
]
*
100
}
{
attention
.
high_attention
*
100
}
</
p
>
</>
)
}
...
...
web-app/package-lock.json
deleted
100644 → 0
View file @
cddc0e2a
{
"lockfileVersion"
:
1
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment