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
e63e4e45
Commit
e63e4e45
authored
Oct 09, 2022
by
Adithya Kahawanugoda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mentalChrom' into 'master'
Clear backend in mental chronometry See merge request
!16
parents
06976858
12c4f5e8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
42 deletions
+198
-42
web-app/backend/server.py
web-app/backend/server.py
+143
-2
web-app/frontend/src/assets/info.png
web-app/frontend/src/assets/info.png
+0
-0
web-app/frontend/src/components/activities/ActivityContainer.jsx
.../frontend/src/components/activities/ActivityContainer.jsx
+25
-7
web-app/frontend/src/components/activities/mentalChronometryEval/pairCancerlation/PairCancerlationContainer.jsx
...ometryEval/pairCancerlation/PairCancerlationContainer.jsx
+15
-30
web-app/frontend/src/pages/student/Student.jsx
web-app/frontend/src/pages/student/Student.jsx
+15
-3
No files found.
web-app/backend/server.py
View file @
e63e4e45
...
...
@@ -56,7 +56,6 @@ def predictAttention():
return
scoreLst
@
app
.
route
(
'/parents/'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
data2
():
...
...
@@ -77,6 +76,7 @@ def data2():
'status'
:
'Parents details are added to the system successfully!'
,
})
@
app
.
route
(
'/users/'
,
methods
=
[
'POST'
,
'GET'
])
@
cross_origin
()
def
data
():
...
...
@@ -195,14 +195,155 @@ def onedata(id):
print
(
'
\n
# Update successful #
\n
'
)
return
jsonify
({
'status'
:
'Data id: '
+
id
+
' is updated!'
})
# Mental Cronometry API
@
app
.
route
(
"/predictletters"
,
methods
=
[
"POST"
])
def
predict
():
letterClassificationmodel
=
load_model
(
'letterClassification.h5'
,
compile
=
False
)
req
=
request
.
get_json
(
force
=
True
)
encoded
=
req
[
"image"
]
decoded
=
base64
.
b64decode
(
encoded
)
with
open
(
"imgt.png"
,
"wb"
)
as
fh
:
fh
.
write
(
base64
.
decodebytes
(
decoded
))
pil_image
=
Image
.
open
(
io
.
BytesIO
(
decoded
))
.
resize
(
(
224
,
224
),
Image
.
LANCZOS
)
.
convert
(
"RGB"
)
image
=
pil_image
image
.
save
(
"imgtest.png"
)
data
=
np
.
ndarray
(
shape
=
(
1
,
224
,
224
,
3
),
dtype
=
np
.
float32
)
size
=
(
224
,
224
)
image_array
=
np
.
asarray
(
image
)
image_array
=
cv
.
resize
(
image_array
,
(
224
,
224
))
normalized_image_array
=
(
image_array
.
astype
(
np
.
float32
)
/
127.0
)
-
1
data
[
0
]
=
normalized_image_array
word_dict
=
{
0
:
'B'
,
1
:
'D'
,
2
:
'M'
,
3
:
'P'
,
4
:
'R'
,
5
:
'S'
,
6
:
'U'
,
7
:
'Y'
}
prediction
=
word_dict
[
np
.
argmax
(
letterClassificationmodel
.
predict
(
data
))]
prediction2
=
letterClassificationmodel
.
predict
(
data
)
response
=
{
"prediction"
:
prediction
}
return
jsonify
(
response
)
@
app
.
route
(
"/predicthanddrwnshapes"
,
methods
=
[
"POST"
])
def
predictHandDrawnShapes
():
handDrawnShapeClassificationmodel
=
load_model
(
'shapeClassification2.h5'
,
compile
=
False
)
req
=
request
.
get_json
(
force
=
True
)
encoded
=
req
[
"image"
]
decoded
=
base64
.
b64decode
(
encoded
)
with
open
(
"imgt.png"
,
"wb"
)
as
fh
:
fh
.
write
(
base64
.
decodebytes
(
decoded
))
pil_image
=
Image
.
open
(
io
.
BytesIO
(
decoded
))
.
resize
(
(
224
,
224
),
Image
.
LANCZOS
)
.
convert
(
"RGB"
)
image
=
pil_image
image
.
save
(
"imgtest.png"
)
data
=
np
.
ndarray
(
shape
=
(
1
,
224
,
224
,
3
),
dtype
=
np
.
float32
)
size
=
(
224
,
224
)
image_array
=
np
.
asarray
(
image
)
image_array
=
cv
.
resize
(
image_array
,
(
224
,
224
))
normalized_image_array
=
(
image_array
.
astype
(
np
.
float32
)
/
127.0
)
-
1
data
[
0
]
=
normalized_image_array
word_dict
=
{
0
:
'circle'
,
1
:
'square'
,
2
:
'triangle'
}
prediction
=
word_dict
[
np
.
argmax
(
handDrawnShapeClassificationmodel
.
predict
(
data
))]
prediction2
=
handDrawnShapeClassificationmodel
.
predict
(
data
)
response
=
{
"prediction"
:
prediction
}
return
jsonify
(
response
)
@
app
.
route
(
"/predictShapePattern"
,
methods
=
[
"POST"
])
def
predictShapePattern
():
shapePatternModel
=
load_model
(
'shapeClassification1.h5'
,
compile
=
False
)
req
=
request
.
get_json
(
force
=
True
)
encoded
=
req
[
"image"
]
decoded
=
base64
.
b64decode
(
encoded
)
with
open
(
"imgt.png"
,
"wb"
)
as
fh
:
fh
.
write
(
base64
.
decodebytes
(
decoded
))
pil_image
=
Image
.
open
(
io
.
BytesIO
(
decoded
))
.
resize
(
(
224
,
224
),
Image
.
LANCZOS
)
.
convert
(
"RGB"
)
image
=
pil_image
image
.
save
(
"imgtest1.png"
)
img
=
cv
.
imread
(
'imgtest1.png'
)
h
,
w
,
channels
=
img
.
shape
half
=
w
//
2
left_part
=
img
[:,
:
half
]
right_part
=
img
[:,
half
:]
half2
=
h
//
2
top
=
img
[:
half2
,
:]
bottom
=
img
[
half2
:,
:]
right_part
=
cv
.
resize
(
right_part
,
(
224
,
224
))
left_part
=
cv
.
resize
(
left_part
,
(
224
,
224
))
cv
.
imwrite
(
'right.jpg'
,
right_part
)
cv
.
imwrite
(
'left.jpg'
,
left_part
)
imgArray
=
[
"left.jpg"
,
"right.jpg"
]
for
img
in
imgArray
:
data
=
np
.
ndarray
(
shape
=
(
1
,
224
,
224
,
3
),
dtype
=
np
.
float32
)
image
=
Image
.
open
(
img
)
size
=
(
224
,
224
)
image_array
=
np
.
asarray
(
image
)
image_array
=
cv
.
resize
(
image_array
,
(
224
,
224
))
normalized_image_array
=
(
image_array
.
astype
(
np
.
float32
)
/
127.0
)
-
1
data
[
0
]
=
normalized_image_array
word_dict
=
{
0
:
'circle'
,
1
:
'square'
,
2
:
'star'
,
3
:
'triangle'
}
prediction
=
word_dict
[
np
.
argmax
(
shapePatternModel
.
predict
(
data
))]
prediction2
=
shapePatternModel
.
predict
(
data
)
response
=
{
"prediction"
:
prediction
}
print
(
prediction
)
return
jsonify
(
response
)
# @app.route("/testDB")
# def test():
# db.db.collection.insert_one({"name": "John"})
# return "Connected to the data base!"
# Running app
if
__name__
==
"__main__"
:
app
.
secret_key
=
os
.
urandom
(
24
)
app
.
run
(
debug
=
True
,
use_reloader
=
False
)
flask_cors
.
CORS
(
app
,
expose_headers
=
'Authorization'
)
web-app/frontend/src/assets/info.png
0 → 100644
View file @
e63e4e45
12 KB
web-app/frontend/src/components/activities/ActivityContainer.jsx
View file @
e63e4e45
...
...
@@ -11,65 +11,83 @@ const ActivityContainer = () => {
const
nextActivityHandler
=
()
=>
{
setCurrentActivityNo
(
currentActivityNo
+
1
);
};
const
changeColor
=
()
=>
{
let
currentDiv
=
document
.
getElementsById
({
currentActivityNo
});
alert
(
"
hi
"
);
};
return
(
<
div
className=
"activity-container-angry-grid"
>
<
div
id=
"activity-container-item-0"
>
<
div
id=
"1"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
1
);
changeColor
();
}
}
>
Picture Concept
1
</
div
>
<
div
id=
"2"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
2
);
changeColor
();
}
}
>
Arithmetic
2
</
div
>
<
div
id=
"3"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
3
);
changeColor
();
}
}
>
Letter Pattern
3
</
div
>
<
div
id=
"4"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
4
);
changeColor
();
}
}
>
Coding
4
</
div
>
<
div
id=
"5"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
5
);
changeColor
();
}
}
>
Pair Cancerlation
5
</
div
>
<
div
id=
"6"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
6
);
changeColor
();
}
}
>
Colour Numbers
6
</
div
>
<
div
id=
"7"
className=
"activity-container-navigator-item"
onClick=
{
()
=>
{
setCurrentActivityNo
(
7
);
changeColor
();
}
}
>
Digit Span
7
</
div
>
</
div
>
<
div
id=
"activity-container-item-1"
>
...
...
web-app/frontend/src/components/activities/mentalChronometryEval/pairCancerlation/PairCancerlationContainer.jsx
View file @
e63e4e45
...
...
@@ -48,17 +48,10 @@ const PairCancerlationContainer = () => {
calculateTime
();
});
const
[
setImage
]
=
useState
(
null
);
const
[
crop
,
setCrop
]
=
useState
({
aspect
:
16
/
9
,
unit
:
"
px
"
,
width
:
120
,
height
:
60
,
x
:
25
,
y
:
25
,
});
const
[
crop
,
setCrop
]
=
useState
({
aspect
:
16
/
9
});
const
getCroppedImg
=
async
()
=>
{
const
canvas
=
document
.
createElement
(
"
canvas
"
);
const
canvas
=
document
.
getElementById
(
"
canvas
"
);
const
image
=
document
.
getElementById
(
"
result
"
);
const
ctx
=
canvas
.
getContext
(
"
2d
"
);
ctx
.
clearRect
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
...
...
@@ -72,7 +65,7 @@ const PairCancerlationContainer = () => {
const
imageWidthRatio
=
image
.
naturalWidth
/
image
.
width
;
const
imageHeightRatio
=
image
.
naturalHeight
/
image
.
height
;
//
console.log(crop);
console
.
log
(
crop
);
ctx
.
drawImage
(
image
,
crop
.
x
*
imageWidthRatio
,
...
...
@@ -84,14 +77,13 @@ const PairCancerlationContainer = () => {
crop
.
width
,
crop
.
height
);
console
.
log
(
crop
.
width
);
console
.
log
(
crop
.
height
);
const
base64
=
canvas
.
toDataURL
(
"
image/png
"
);
let
imagetoPred
=
base64
.
replace
(
"
data:image/png;base64,
"
,
""
);
console
.
log
(
imagetoPred
);
console
.
log
(
base64
);
let
message
=
{
image
:
imagetoPred
};
...
...
@@ -143,12 +135,7 @@ const PairCancerlationContainer = () => {
{
"
"
}
<
div
>
{
"
"
}
<
img
id=
"result"
src=
{
PCA1
}
alt=
"description"
onLoad=
{
setImage
}
/>
{
"
"
}
<
img
src=
{
PCA1
}
alt=
"description"
/>
{
"
"
}
</
div
>
</
div
>
<
div
className=
"grid grid-cols-1 h-fit m-10"
>
...
...
@@ -203,18 +190,16 @@ const PairCancerlationContainer = () => {
/>
</
button
>
</
div
>
{
false
&&
(
<
canvas
id=
"canvas"
width=
{
crop
.
width
}
height=
{
crop
.
height
}
style=
{
{
border
:
"
1px solid black
"
,
objectFit
:
"
contain
"
,
}
}
/>
)
}
(
<
canvas
id=
"canvas"
width=
{
crop
.
width
}
height=
{
crop
.
height
}
style=
{
{
border
:
"
1px solid black
"
,
objectFit
:
"
contain
"
,
}
}
/>
</
div
>
</
div
>
</
div
>
...
...
web-app/frontend/src/pages/student/Student.jsx
View file @
e63e4e45
...
...
@@ -7,6 +7,7 @@ import { Popover, Transition } from "@headlessui/react";
import
{
MenuIcon
,
XIcon
}
from
"
@heroicons/react/outline
"
;
import
logo
from
"
../../assets/logo1.png
"
;
import
sl_kids
from
"
../../assets/image.png
"
;
import
info
from
"
../../assets/info.png
"
;
const
Student
=
()
=>
{
const
navigate
=
useNavigate
();
...
...
@@ -48,7 +49,7 @@ const Student = () => {
<
span
className=
"sr-only"
>
Workflow
</
span
>
<
img
alt=
"Workflow"
className=
"h-
8 w-auto sm:h-2
0"
className=
"h-
40 w-auto sm:h-4
0"
src=
{
logo
}
/>
</
a
>
...
...
@@ -65,7 +66,7 @@ const Student = () => {
</
div
>
</
div
>
</
div
>
<
div
className=
"hidden md:block md:ml-10 md:pr-4 md:space-x-8"
>
{
/*
<div className="hidden md:block md:ml-10 md:pr-4 md:space-x-8">
{navigation.map((item) => (
<a
key={item.name}
...
...
@@ -76,7 +77,7 @@ const Student = () => {
{item.name}
</a>
))}
</
div
>
</div>
*/
}
</
nav
>
</
div
>
...
...
@@ -172,6 +173,17 @@ const Student = () => {
</
a
>
</
div
>
</
div
>
<
div
className=
"mt-5 sm:mt-8 sm:flex sm:justify-center lg:justify-start"
>
<
div
className=
"rounded-md shadow"
>
<
a
href=
"/features"
className=
"w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-black bg-[#b4c2f5] hover:bg-indigo-700 md:py-4 md:text-lg md:px-10"
>
<
img
className=
"h-8 w-auto"
src=
{
info
}
></
img
>
{
"
"
}
Info
</
a
>
</
div
>
</
div
>
</
div
>
</
main
>
</
div
>
...
...
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