Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pvnet_FruitBIn
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Guillaume Duret
Pvnet_FruitBIn
Commits
c1531d6d
Commit
c1531d6d
authored
2 years ago
by
Guillaume Duret
Browse files
Options
Downloads
Patches
Plain Diff
evaluation running
parent
092cc0fd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eval_pose.py
+42
-23
42 additions, 23 deletions
eval_pose.py
with
42 additions
and
23 deletions
eval_pose.py
+
42
−
23
View file @
c1531d6d
...
...
@@ -8,13 +8,14 @@ import open3d as o3d
import
argparse
import
os
import
sys
from
plyfile
import
PlyData
,
PlyElement
def
read_diameter
(
object_name
):
filename
=
f
'
Generated_Worlds_/Generated/
{
class_name
}
/diameter.txt
'
filename
=
f
'
Generated_Worlds_/Generated/
{
class_name
}
/
{
class_name
}
_
diameter.txt
'
with
open
(
filename
)
as
f
:
diameter_in_cm
=
float
(
f
.
readline
())
return
diameter_in_cm
*
0.01
#return diameter_in_cm * 0.01
return
diameter_in_cm
def
transform_pts_Rt
(
pts
,
R
,
t
):
...
...
@@ -245,6 +246,7 @@ def eval_pose(r_est, t_est, r_gt, t_gt, pc, k, diameter, sym=False):
if
__name__
==
'
__main__
'
:
ap
=
argparse
.
ArgumentParser
()
ap
.
add_argument
(
"
--path_evaluation
"
,
type
=
str
,
required
=
True
)
ap
.
add_argument
(
"
-cls_name
"
,
"
--class_name
"
,
type
=
str
,
default
=
'
kiwi1
'
,
help
=
"
[apple2, apricot, banana1, kiwi1, lemon2, orange2, peach1, pear2]
"
)
...
...
@@ -252,57 +254,74 @@ if __name__ == '__main__':
default
=
False
)
args
=
vars
(
ap
.
parse_args
())
class_name
=
args
[
"
class_name
"
]
symmetry
=
args
[
"
symmetry
"
]
basePath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'
/Generated_Worlds_/Generated_Worlds_Evaluating/
'
+
class_name
images_ls
,
labels_ls
,
mask_ls
,
choice_ls
=
data
.
getAllValData
(
class_name
)
print
(
len
(
images_ls
))
basePath
=
args
[
"
path_evaluation
"
]
+
"
/
"
+
args
[
"
class_name
"
]
#basePath = os.path.dirname(
# os.path.realpath(__file__)) + '/Generated_Worlds_/Generated_Worlds_Evaluating/' + class_name
#images_ls, labels_ls, mask_ls, choice_ls = data.getAllValData(class_name)
#print(len(images_ls))
pc_path
=
f
'
/gpfswork/rech/uli/ubn15wo/guimod/Models/
{
class_name
}
/
{
class_name
}
.ply
'
#pcd = o3d.io.read_point_cloud(pc_path)
#pc = np.asarray(pcd.points)
plydata
=
PlyData
.
read
(
pc_path
)
elm
=
plydata
.
elements
data
=
np
.
asarray
(
elm
[
0
][:])
pc
=
np
.
zeros
((
len
(
data
),
3
))
print
(
"
len(data)
"
,
len
(
data
))
print
(
"
len(pc)
"
,
len
(
pc
))
diameter
=
read_diameter
(
class_name
)
print
(
diameter
)
for
i
in
range
(
len
(
data
)):
pc
[
i
][
0
],
pc
[
i
][
1
],
pc
[
i
][
2
]
=
data
[
i
][
0
],
data
[
i
][
1
],
data
[
i
][
2
]
pc_path
=
f
'
/
{
basePath
}
/Models/
{
class_name
}
.ply
'
pcd
=
o3d
.
io
.
read_point_cloud
(
pc_path
)
pc
=
np
.
asarray
(
pcd
.
points
)
add_res_ls
=
[]
proj_res_ls
=
[]
count_add
=
0
count_iadd
=
0
count_proj
=
0
length_data
=
len
(
os
.
listdir
(
f
"
{
basePath
}
/Pose_prediction
"
))
print
(
"
number of evaluating data :
"
,
length_data
)
for
idx
in
range
(
len
(
images_ls
)):
for
files
in
os
.
listdir
(
f
"
{
basePath
}
/Pose_prediction
"
):
# ============== Loading Pose ===============
pose_est
=
np
.
load
(
f
'
{
basePath
}
/Pose_prediction/
{
idx
}
.npy
'
)
pose_est
=
np
.
load
(
f
'
{
basePath
}
/Pose_prediction/
{
files
}
'
)
r_est
=
pose_est
[:
3
,
:
3
]
t_est
=
pose_est
[:
3
,
3
]
t_est
=
np
.
array
(
pose_est
[:
3
,
3
]).
reshape
(
3
,
1
)
print
(
"
t_est
"
,
t_est
)
pose_gt
=
np
.
load
(
f
'
{
basePath
}
/Pose_transformed/
{
idx
}
.npy
'
)
pose_gt
=
np
.
load
(
f
'
{
basePath
}
/Pose_transformed/
{
files
}
'
)
r_gt
=
np
.
array
(
pose_gt
[
0
:
3
,
0
:
3
],
dtype
=
'
float64
'
)
t_gt
=
np
.
array
(
pose_gt
[
0
:
3
,
3
],
dtype
=
'
float64
'
).
reshape
(
3
,
1
)
print
(
"
t_gt
"
,
t_gt
)
# ============== Evaluation ===============
k
=
np
.
array
([[
543.25272224
,
0.
,
320.25
],
[
0.
,
724.33696299
,
240.33333333
],
[
0.
,
0.
,
1.
]])
diameter
=
read_diameter
(
class_name
)
[
0.
,
0.
,
1.
]])
add_res
,
is_add
,
proj_res
,
is_proj
,
adi_res
,
is_adi
=
eval_pose
(
r_est
,
t_est
,
r_gt
,
t_gt
,
pc
,
k
,
diameter
,
symmetry
)
if
is_add
:
count_add
+=
1
if
is_proj
:
count_proj
+=
1
if
is_adi
:
count_iadd
+=
1
print
(
f
"
ADD_Res:
{
count_add
/
len
(
images_ls
)
}
"
)
print
(
f
"
ADI_Res:
{
count_iadd
/
len
(
images_ls
)
}
"
)
print
(
f
"
Proj_Res:
{
count_proj
/
len
(
images_ls
)
}
"
)
print
(
f
"
ADD_Res:
{
count_add
/
len
gth_data
}
"
)
print
(
f
"
ADI_Res:
{
count_iadd
/
len
gth_data
}
"
)
print
(
f
"
Proj_Res:
{
count_proj
/
len
gth_data
}
"
)
print
(
f
"
======================
"
)
print
(
"
Done
"
)
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