Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IT Management Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Formanek Balázs István
IT Management Project
Commits
fa82e642
Commit
fa82e642
authored
6 months ago
by
Vajay Mónika
Browse files
Options
Downloads
Patches
Plain Diff
fix saving pathes
parent
7041b274
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
merge_pickles.py
+6
-3
6 additions, 3 deletions
merge_pickles.py
training/data_collector.py
+5
-1
5 additions, 1 deletion
training/data_collector.py
training/test_model.py
+6
-1
6 additions, 1 deletion
training/test_model.py
training/train_model.py
+9
-3
9 additions, 3 deletions
training/train_model.py
with
26 additions
and
8 deletions
merge_pickles.py
+
6
−
3
View file @
fa82e642
...
...
@@ -3,7 +3,11 @@ import os
from
pprint
import
pprint
FOLDER_PATH
=
"
./Moni_train_data/
"
FOLDER_PATH
=
"
./train_data/
"
OUTPUT_FILE
=
'
PROBA_PROBA.pickle
'
# Output merged file
current_dir
=
os
.
path
.
dirname
(
__file__
)
OUTPUT_FOLDER
=
os
.
path
.
abspath
(
os
.
path
.
join
(
current_dir
,
'
merged_training_data
'
,
OUTPUT_FILE
))
#FOLDER_PATH = "./proba_data/"
def
change_label_name
(
input_path
,
old_label
,
new_label
):
...
...
@@ -64,6 +68,5 @@ def merge_pickle_files(input_files, output_file):
if
__name__
==
"
__main__
"
:
#change_label_name(FOLDER_PATH + "scrolling_right_Moni.pickle", "sscrolling right", "scrolling right")
input_files
=
os
.
listdir
(
FOLDER_PATH
)
# List of .pickle file paths
output_file
=
'
mouse_train_data_all.pickle
'
# Output merged file
merge_pickle_files
(
input_files
,
output_file
)
merge_pickle_files
(
input_files
,
OUTPUT_FOLDER
)
This diff is collapsed.
Click to expand it.
training/data_collector.py
+
5
−
1
View file @
fa82e642
...
...
@@ -2,6 +2,7 @@ import cv2
import
random
import
mediapipe
as
mp
import
pickle
import
os
def
landmarks2px
(
frame_sizes
,
landmark_list
):
if
len
(
landmark_list
)
==
0
:
...
...
@@ -162,8 +163,11 @@ def main():
cv2
.
destroyAllWindows
()
print
(
"
Save generated data
"
)
current_dir
=
os
.
path
.
dirname
(
__file__
)
filename
=
input
(
"
give filename:
"
)
f
=
open
(
filename
+
'
.pickle
'
,
'
wb
'
)
folder_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
current_dir
,
os
.
pardir
,
'
train_data
'
,
filename
))
f
=
open
(
folder_path
+
'
.pickle
'
,
'
wb
'
)
pickle
.
dump
({
'
data
'
:
data
,
'
label
'
:
labels
},
f
)
f
.
close
()
...
...
This diff is collapsed.
Click to expand it.
training/test_model.py
+
6
−
1
View file @
fa82e642
...
...
@@ -3,6 +3,9 @@ import random
import
mediapipe
as
mp
import
pickle
import
numpy
as
np
import
os
FILENAME
=
'
PROBA_PROBA.p
'
def
landmarks2px
(
frame_sizes
,
landmark_list
):
if
len
(
landmark_list
)
==
0
:
...
...
@@ -68,7 +71,9 @@ def write_landmark_on_frame(frame, landmark_list, landmark_list_px):
## main: open video and do hand detection
def
main
():
# load model
model_dict
=
pickle
.
load
(
open
(
'
./trained_Moni_data.p
'
,
'
rb
'
))
current_dir
=
os
.
path
.
dirname
(
__file__
)
model_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
current_dir
,
os
.
pardir
,
'
trained_models
'
,
FILENAME
))
model_dict
=
pickle
.
load
(
open
(
model_path
,
'
rb
'
))
model
=
model_dict
[
'
model
'
]
# create hand detection object
...
...
This diff is collapsed.
Click to expand it.
training/train_model.py
+
9
−
3
View file @
fa82e642
...
...
@@ -4,9 +4,14 @@ import numpy as np
from
sklearn.ensemble
import
RandomForestClassifier
from
sklearn.model_selection
import
train_test_split
from
sklearn.metrics
import
accuracy_score
import
os
filename
=
'
mouse_train_data_all
'
data_dict
=
pickle
.
load
(
open
(
filename
+
'
.pickle
'
,
'
rb
'
))
filename
=
'
PROBA_PROBA
'
current_dir
=
os
.
path
.
dirname
(
__file__
)
file_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
current_dir
,
os
.
pardir
,
'
merged_training_data
'
,
filename
))
data_dict
=
pickle
.
load
(
open
(
file_path
+
'
.pickle
'
,
'
rb
'
))
print
(
data_dict
.
keys
())
coordinates
=
np
.
asarray
(
data_dict
[
'
data
'
])
...
...
@@ -25,6 +30,7 @@ score = accuracy_score(y_predict, y_test)
print
(
f
'
accuracy:
{
score
*
100
}
%
'
)
f
=
open
(
'
trained_mouse_data.p
'
,
'
wb
'
)
output_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
current_dir
,
os
.
pardir
,
'
trained_models
'
,
filename
))
f
=
open
(
output_path
+
'
.p
'
,
'
wb
'
)
pickle
.
dump
({
'
model
'
:
model
},
f
)
f
.
close
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment