Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
synthetic_drivers
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
aura_autobehave
synthetic_drivers
Commits
7a327ffb
Commit
7a327ffb
authored
2 years ago
by
Romain Guesdon
Browse files
Options
Downloads
Patches
Plain Diff
Fix human switch
parent
c75f2718
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
global_script.py
+9
-8
9 additions, 8 deletions
global_script.py
scripts/human.py
+9
-9
9 additions, 9 deletions
scripts/human.py
scripts/random_pose.py
+3
-5
3 additions, 5 deletions
scripts/random_pose.py
with
21 additions
and
22 deletions
global_script.py
+
9
−
8
View file @
7a327ffb
...
...
@@ -73,11 +73,11 @@ cars = []
for
src_path
,
name
in
{
r
"
car_models\suv_car\car.blend
"
:
'
SUV
'
,
#
r"car_models\red_car\red.blend": 'Red',
#
r"car_models\pickup_car\pickup.blend": 'PickUp',
#
r"car_models\family_car\family_car.blend": 'Family',
#
r"car_models\coupe_car\coupe_car.blend": 'Coupe',
#
r"car_models\truck\truck_open.blend": 'Truck',
r
"
car_models\red_car\red.blend
"
:
'
Red
'
,
r
"
car_models\pickup_car\pickup.blend
"
:
'
PickUp
'
,
r
"
car_models\family_car\family_car.blend
"
:
'
Family
'
,
r
"
car_models\coupe_car\coupe_car.blend
"
:
'
Coupe
'
,
r
"
car_models\truck\truck_open.blend
"
:
'
Truck
'
,
}.
items
():
with
D
.
libraries
.
load
(
abs_path
(
src_path
))
as
(
data_from
,
data_to
):
...
...
@@ -152,7 +152,7 @@ light_params = {
},
'
night
'
:
{
'
energy_bounds
'
:
(
5
,
15
),
'
back_color_bounds
'
:
(
0.
05
,
0.15
),
'
back_color_bounds
'
:
(
0.
1
,
0.15
),
'
sun_color
'
:
(
1
,
0.5
,
0.2
)
}
...
...
@@ -194,7 +194,7 @@ if not CONTINUE or not os.path.isfile(info_path):
frame_rate
=
25
nb_scene
=
1
nb_pose
=
1
0
nb_pose
=
3
0
human_loader
.
max_len
=
min
(
human_loader
.
max_len
,
nb_scene
)
ratio_conf_man
=
int
(
nb_scene
/
len
(
human_loader
.
human_paths
))
if
CONTINUE
:
...
...
@@ -302,7 +302,8 @@ for sc in range(nb_scene):
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
# set output path so render won't get overwritten
C
.
scene
.
render
.
filepath
=
os
.
path
.
join
(
fp_img
,
f
"
{
file_root_name
}
_
{
po
}
"
+
f
'
_drive
'
if
use_targets
else
''
)
C
.
scene
.
render
.
filepath
=
os
.
path
.
join
(
fp_img
,
f
"
{
file_root_name
}
_
{
po
}
"
+
(
f
'
_drive
'
if
use_targets
else
''
))
bpy
.
ops
.
render
.
render
(
write_still
=
True
)
# render still
annotations_2D
=
[]
...
...
This diff is collapsed.
Click to expand it.
scripts/human.py
+
9
−
9
View file @
7a327ffb
...
...
@@ -234,11 +234,11 @@ def set_shrinkwraps(model, car=None):
class
HumanLoader
:
def
__init__
(
self
,
dir_path
,
max_len
=
10
):
self
.
human_paths
=
glob
.
glob
(
os
.
path
.
join
(
dir_path
,
'
*.fbx
'
))
#
random.shuffle(self.human_paths)
random
.
shuffle
(
self
.
human_paths
)
self
.
paths
=
{}
self
.
humans
=
{}
self
.
max_len
=
max_len
self
.
start_
idx
=
0
self
.
start_
loaded
=
0
self
.
current_idx
=
-
1
self
.
collection
=
D
.
collections
.
new
(
"
Humans
"
)
...
...
@@ -250,16 +250,16 @@ class HumanLoader:
def
load_next
(
self
):
if
self
.
max_len
>=
len
(
self
.
human_paths
):
# If asked too much
self
.
start_
idx
=
0
self
.
start_
loaded
=
0
if
len
(
self
.
paths
)
==
len
(
self
.
human_paths
):
# If everything already loaded
return
else
:
next_idx
=
len
(
self
.
human_paths
)
end_loaded
=
len
(
self
.
human_paths
)
else
:
next_idx
=
self
.
start_
idx
+
self
.
max_len
end_loaded
=
self
.
start_
loaded
+
self
.
max_len
human_paths
=
(
self
.
human_paths
*
2
)[
self
.
start_
idx
:
next_idx
]
human_paths
=
(
self
.
human_paths
*
2
)[
self
.
start_
loaded
:
end_loaded
]
human_paths
=
list
({
k
:
None
for
k
in
human_paths
})
already_loaded
=
[
hp
for
hp
in
human_paths
if
hp
in
self
.
paths
.
values
()]
...
...
@@ -277,12 +277,11 @@ class HumanLoader:
self
.
humans
[
human_path
]
=
Human
(
model
)
self
.
picker
=
utils
.
Randomizer
(
list
(
self
.
humans
.
values
()))
self
.
start_
idx
=
next_idx
%
len
(
self
.
human_paths
)
self
.
start_
loaded
=
end_loaded
%
len
(
self
.
human_paths
)
def
next
(
self
,
*
args
,
**
kwargs
):
self
.
current_idx
+=
1
if
not
self
.
current_idx
%
self
.
max_len
:
self
.
start_idx
=
self
.
current_idx
self
.
load_next
()
self
.
current_idx
=
0
return
self
.
picker
.
get
(
self
.
current_idx
,
*
args
,
**
kwargs
)
...
...
@@ -301,7 +300,8 @@ class HumanLoader:
def
clear_humans
(
exceptions
=
[]):
collection
=
D
.
collections
[
"
Humans
"
]
exceptions
=
exceptions
+
[
obj
.
children_recursive
for
obj
in
exceptions
]
exceptions
=
exceptions
+
[
ch
for
obj
in
exceptions
for
ch
in
obj
.
children_recursive
]
for
obj
in
collection
.
objects
:
if
obj
in
exceptions
:
continue
...
...
This diff is collapsed.
Click to expand it.
scripts/random_pose.py
+
3
−
5
View file @
7a327ffb
...
...
@@ -95,9 +95,8 @@ def hand_pose(pose, side, grasp=None):
hand_ratio
=
random
.
uniform
(
0.5
,
0.8
)
elif
grasp
is
False
:
hand_ratio
=
random
.
uniform
(
0.05
,
0.15
)
print
(
grasp
)
print
(
hand_ratio
)
else
:
hand_ratio
=
0
for
finger
in
[
'
thumb
'
,
'
index
'
,
'
middle
'
,
'
ring
'
,
'
pinky
'
]:
angles
=
r
([
40
,
40
,
40
])
if
finger
==
'
thumb
'
else
r
([
70
,
90
,
40
])
...
...
@@ -157,7 +156,7 @@ def random_pose_ik(subject, auto_ik=False, targets=None):
else
:
pose
.
bones
[
'
spine_03
'
].
rotation_euler
=
get_angles
([[
5
,
20
],
15
,
None
])
pose
.
bones
[
'
neck_01
'
].
rotation_euler
=
get_angles
(
bounds_vals
[
'
neck_01
'
])
pose
.
bones
[
'
neck_01
'
].
rotation_euler
=
get_angles
(
[[
5
,
25
],
0
,
10
])
pose
.
use_auto_ik
=
auto_ik
...
...
@@ -215,7 +214,6 @@ def random_pose_ik(subject, auto_ik=False, targets=None):
pose
.
bones
[
f
'
hand_
{
s
}
_IK
'
].
rotation_euler
=
Vector
((
0
,
0
,
0
))
pose
.
bones
[
f
'
hand_
{
s
}
_IK
'
].
rotation_euler
=
(
((
matrix_world
@
pose
.
bones
[
f
'
hand_
{
s
}
_IK
'
].
matrix
).
inverted
()
@
target
.
matrix_world
).
to_euler
())
print
(
"
_close
"
in
target
.
name
)
hand_pose
(
pose
,
side
=
s
,
grasp
=
"
_close
"
in
target
.
name
)
target
=
target
.
location
...
...
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