Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yolo_model_optimization
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
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikhin.vc
yolo_model_optimization
Commits
a9d59709
Commit
a9d59709
authored
Jun 01, 2023
by
Sikhin VC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added file copy logic
parent
70490026
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
yolo_optimization.py
yolo_optimization.py
+9
-6
No files found.
yolo_optimization.py
View file @
a9d59709
...
@@ -5,9 +5,10 @@ import shutil
...
@@ -5,9 +5,10 @@ import shutil
class
ModelOptimization
:
class
ModelOptimization
:
def
__init__
(
self
,
num_class
,
image_size
=
416
):
def
__init__
(
self
,
num_class
,
weight_path
,
image_size
=
416
):
self
.
num_class
=
num_class
self
.
num_class
=
num_class
self
.
image_size
=
image_size
self
.
image_size
=
image_size
self
.
weight_path
=
weight_path
def
change_configurations
(
self
):
def
change_configurations
(
self
):
logger
.
info
(
f
"Provided number of classes and image size are : {self.num_class} and {self.image_size}"
)
logger
.
info
(
f
"Provided number of classes and image size are : {self.num_class} and {self.image_size}"
)
...
@@ -28,10 +29,10 @@ class ModelOptimization:
...
@@ -28,10 +29,10 @@ class ModelOptimization:
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
info
(
f
"Failed to change configurations : {e}"
)
logger
.
info
(
f
"Failed to change configurations : {e}"
)
def
optimize_model
(
self
,
weight_path
):
def
optimize_model
(
self
):
try
:
try
:
shutil
.
copy
(
weight_path
,
'yolov5/build'
)
shutil
.
copy
(
self
.
weight_path
,
'yolov5/build'
)
weight_name_with_extension
=
os
.
path
.
basename
(
weight_path
)
weight_name_with_extension
=
os
.
path
.
basename
(
self
.
weight_path
)
weight_name
,
extension
=
os
.
path
.
splitext
(
weight_name_with_extension
)
weight_name
,
extension
=
os
.
path
.
splitext
(
weight_name_with_extension
)
current_directory
=
os
.
getcwd
()
current_directory
=
os
.
getcwd
()
logger
.
info
(
f
"Current directory is : {current_directory}"
)
logger
.
info
(
f
"Current directory is : {current_directory}"
)
...
@@ -51,6 +52,8 @@ class ModelOptimization:
...
@@ -51,6 +52,8 @@ class ModelOptimization:
logger
.
info
(
f
"Failed to optimized model : {e}"
)
logger
.
info
(
f
"Failed to optimized model : {e}"
)
# obj = ModelOptimization(num_class=2, image_size=244)
obj
=
ModelOptimization
(
num_class
=
1
,
weight_path
=
"/home/ilens/cam_42_best.wts"
,
image_size
=
416
)
# obj.change_configurations()
obj
.
change_configurations
()
obj
.
optimize_model
()
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