Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sign-Language-AI-Model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
AC4908
Sign-Language-AI-Model
Merge requests
!1
Couldn't fetch the linked file.
made so code can be trained on GPU
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
made so code can be trained on GPU
test_expanding_model
into
main
Overview
0
Commits
15
Pipelines
0
Changes
7
Merged
AC4908
requested to merge
test_expanding_model
into
main
4 months ago
Overview
0
Commits
15
Pipelines
0
Changes
7
Expand
update readme to install environment
0
0
Merge request reports
Viewing commit
668e8ce6
Prev
Next
Show latest version
7 files
+
102
−
57
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
668e8ce6
update what image is send
· 668e8ce6
Michiel_VE
authored
9 months ago
Func/ClassifierModule.py
+
8
−
7
Options
import
keras
import
numpy
as
np
import
cv2
from
cvzone.HandTrackingModule
import
HandDetector
class
Classifier
:
@@ -20,7 +21,8 @@ class Classifier:
else
:
print
(
"
No Labels Found
"
)
def
getPrediction
(
self
,
img
,
draw
=
True
,
pos
=
(
50
,
50
),
scale
=
2
,
color
=
(
0
,
255
,
0
)):
def
getPrediction
(
self
,
img
):
cv2
.
imshow
(
"
imgFixed classifier
"
,
img
)
img_resized
=
cv2
.
resize
(
img
,
(
224
,
224
))
image_array
=
np
.
asarray
(
img_resized
)
normalized_image_array
=
(
image_array
.
astype
(
np
.
float32
)
/
127.0
)
-
1
@@ -30,30 +32,29 @@ class Classifier:
prediction
=
self
.
model
.
predict
(
self
.
data
)
index_val
=
np
.
argmax
(
prediction
)
if
draw
and
self
.
labels_path
:
label_text
=
str
(
self
.
list_labels
[
index_val
])
cv2
.
putText
(
img
,
label_text
,
pos
,
cv2
.
FONT_HERSHEY_COMPLEX
,
scale
,
color
,
2
)
return
list
(
prediction
[
0
]),
index_val
def
main
():
cap
=
cv2
.
VideoCapture
(
0
)
detector
=
HandDetector
(
maxHands
=
1
)
mask_classifier
=
Classifier
(
'
Model/keras_model.h5
'
,
'
Model/labels.txt
'
)
while
True
:
ret
,
frame
=
cap
.
read
()
hands
,
img
=
detector
.
findHands
(
frame
)
if
not
ret
:
print
(
"
Failed to capture frame
"
)
break
prediction
=
mask_classifier
.
getPrediction
(
frame
)
prediction
=
mask_classifier
.
getPrediction
(
img
)
print
(
"
Prediction:
"
,
prediction
)
cv2
.
imshow
(
"
Image
"
,
frame
)
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
'
q
'
):
break
Loading