Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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
2023-029
2023-029
Commits
91e900ea
Commit
91e900ea
authored
Aug 30, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
c21e6f61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
Project/Backend/Server_Node/controllers/marksCalculator.controller.js
...end/Server_Node/controllers/marksCalculator.controller.js
+16
-3
Project/Backend/Server_Node/prediction_config/C1T1/predict.py
...ect/Backend/Server_Node/prediction_config/C1T1/predict.py
+25
-1
No files found.
Project/Backend/Server_Node/controllers/marksCalculator.controller.js
View file @
91e900ea
...
...
@@ -5,6 +5,8 @@ export const marksCalculator = async (req, res) => {
const
targetClass
=
req
.
body
.
class
;
const
{
curriculumIndex
,
tutorialIndex
}
=
req
.
params
;
const
status
=
""
;
// console.log(curriculumIndex, tutorialIndex);
try
{
...
...
@@ -15,13 +17,24 @@ export const marksCalculator = async (req, res) => {
console
.
error
(
error
);
return
res
.
status
(
500
).
json
({
error
:
'
An error occurred
'
});
}
const
[
predictedClass
,
confidence
]
=
stdout
.
trim
().
split
(
'
,
'
);
const
[
predicted_class_name
,
confidence
]
=
stdout
.
trim
().
split
(
'
,
'
);
const
parsedConfidence
=
parseFloat
(
confidence
).
toFixed
(
2
);
let
status
=
""
;
if
(
predicted_class_name
===
targetClass
&&
parsedConfidence
>
85
)
{
status
=
"
pass
"
;
}
else
{
status
=
"
fail
"
;
}
res
.
status
(
200
).
json
({
code
:
"
01
"
,
result
:
{
predictedClass
,
confidence
:
parseFloat
(
confidence
).
toFixed
(
2
),
predicted_class_name
,
confidence
:
parsedConfidence
,
status
}
});
});
...
...
Project/Backend/Server_Node/prediction_config/C1T1/predict.py
View file @
91e900ea
...
...
@@ -56,6 +56,27 @@ class theCNN(nn.Module):
return
torch
.
softmax
(
self
.
output
(
x
),
axis
=
1
)
# Load the mapping dictionary
class_mapping
=
{
0
:
'Eight'
,
1
:
'Eleven'
,
2
:
'Fifty'
,
3
:
'Five'
,
4
:
'Four'
,
5
:
'Fourteen'
,
6
:
'Nine'
,
7
:
'One'
,
8
:
'Seven'
,
9
:
'Six'
,
10
:
'Ten'
,
11
:
'Thirteen'
,
12
:
'Thirty'
,
13
:
'Three'
,
14
:
'Twenty'
,
15
:
'Two'
}
# Load the trained model
model
=
theCNN
()
# Instantiate your model class
model
.
load_state_dict
(
torch
.
load
(
...
...
@@ -85,8 +106,11 @@ with torch.no_grad():
predicted_class
=
torch
.
argmax
(
outputs
[
0
])
.
item
()
confidence
=
outputs
[
0
][
predicted_class
]
.
item
()
# Get the predicted class name using the mapping dictionary
predicted_class_name
=
class_mapping
[
predicted_class
]
# Calculate similarity or confidence percentage
# target_class = sys.argv[2].lower() # Class name passed from the API
similarity
=
100
*
confidence
print
(
f
"{predicted_class},{similarity:.2f}"
)
print
(
f
"{predicted_class
_name
},{similarity:.2f}"
)
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