Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
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
FruitBin
Commits
6668f884
Commit
6668f884
authored
2 years ago
by
Guillaume Duret
Browse files
Options
Downloads
Patches
Plain Diff
good code
parent
4a5a68a3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compute_features.py
+17
-16
17 additions, 16 deletions
compute_features.py
main.py
+6
-22
6 additions, 22 deletions
main.py
with
23 additions
and
38 deletions
compute_features.py
+
17
−
16
View file @
6668f884
...
...
@@ -21,7 +21,7 @@ def process_compute(data_name, camera, camera_resized, new_size, Nb_camera, Worl
destination_folders_list
=
{}
for
scenario_loop
in
scenarios
:
destination_folders_list
[
scenario_loop
]
=
[
f
"
Generated_
{
scenario_loop
}
_Testing
"
,
f
"
Generated_
{
scenario_loop
}
_Evaluating
"
,
f
"
Generated_
{
scenario_loop
}
_Training
"
]
destination_folders_list
[
scenario_loop
]
=
[
f
"
Generated_
{
scenario_loop
}
_Testing
"
,
f
"
Generated_
{
scenario_loop
}
_Evaluating
"
,
f
"
Generated_
{
scenario_loop
}
_Training
"
,
f
"
Generated_
{
scenario_loop
}
_dont_save
"
]
list_count_categories
=
{}
for
scenario_loop
in
scenarios
:
...
...
@@ -34,9 +34,9 @@ def process_compute(data_name, camera, camera_resized, new_size, Nb_camera, Worl
for
i
in
range
(
World_begin
,
World_begin
+
Nb_world
):
# worlds
if
i
>
4
:
if
i
>
8000
:
destination_folders
[
"
Worlds
"
]
=
f
"
Generated_Worlds_Testing
"
elif
i
>
3
:
elif
i
>
6000
:
destination_folders
[
"
Worlds
"
]
=
f
"
Generated_Worlds_Evaluating
"
else
:
destination_folders
[
"
Worlds
"
]
=
f
"
Generated_Worlds_Training
"
...
...
@@ -53,14 +53,14 @@ def process_compute(data_name, camera, camera_resized, new_size, Nb_camera, Worl
else
:
destination_folders
[
"
Cameras
"
]
=
f
"
Generated_Cameras_Training
"
if
i
>
4
and
j
>
12
:
if
i
>
8000
and
j
>
12
:
destination_folders
[
"
Mix_all
"
]
=
f
"
Generated_Mix_all_Testing
"
elif
i
>
3
and
i
<=
4
and
j
>
9
and
j
>=
12
:
elif
i
>
6000
and
i
<=
8000
and
j
>
9
and
j
>=
12
:
destination_folders
[
"
Mix_all
"
]
=
f
"
Generated_Mix_all_Evaluating
"
elif
i
<=
3
and
j
<=
9
:
elif
i
<=
6000
and
j
<=
9
:
destination_folders
[
"
Mix_all
"
]
=
f
"
Generated_Mix_all_Training
"
else
:
destination_folders
[
"
Mix_all
"
]
=
"
dont_save
"
destination_folders
[
"
Mix_all
"
]
=
f
"
Generated_Mix_all_
dont_save
"
catergories_occ_array
=
compute_id_good_occ
(
data_name
,
p
,
catergories_instance_array_id_to_cat
,
catergories_instance_array_cat_to_id
,
occ_target
)
...
...
@@ -79,10 +79,10 @@ def process_compute(data_name, camera, camera_resized, new_size, Nb_camera, Worl
raise
TypeError
(
"
size of datas are differents !!
"
)
for
scenario_loop
in
scenarios
:
if
not
destination_folders
[
scenario_loop
]
==
"
dont_save
"
:
if
os
.
path
.
isfile
(
f
'
{
data_name
}
/
{
destination_folder
s
[
scenario
_loop
]
}
/Count_
{
p
-
1
}
.json
'
):
with
open
(
f
'
{
data_name
}
/
{
destination_folder
s
[
scenario
_loop
]
}
/Count_
{
p
-
1
}
.json
'
)
as
f
:
list_count_categories
[
scenario_loop
][
destination_folder
s
[
scenario
_loop
]
]
=
json
.
load
(
f
)
for
destination_folder_loop
in
destination_folders
_list
[
scenario_loop
]
:
if
os
.
path
.
isfile
(
f
'
{
data_name
}
/
{
destination_folder_loop
}
/Count_
{
p
-
1
}
.json
'
):
with
open
(
f
'
{
data_name
}
/
{
destination_folder_loop
}
/Count_
{
p
-
1
}
.json
'
)
as
f
:
list_count_categories
[
scenario_loop
][
destination_folder_loop
]
=
json
.
load
(
f
)
for
categories
in
list_categories
:
if
categories
in
catergories_occ_array
.
keys
():
...
...
@@ -111,16 +111,16 @@ def process_compute(data_name, camera, camera_resized, new_size, Nb_camera, Worl
meta
[
'
occlusion
'
]
=
occ_target
meta
[
'
Nb_instance_category
'
]
=
Nb_instance
if
not
os
.
path
.
isfile
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
.json
'
):
with
open
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
.json
'
,
mode
=
'
w
'
)
as
f
:
if
not
os
.
path
.
isfile
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
_
{
p
}
.json
'
):
with
open
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
_
{
p
}
.json
'
,
mode
=
'
w
'
)
as
f
:
feeds
=
{}
feeds
[
meta
[
'
id_generated
'
]]
=
meta
f
.
write
(
json
.
dumps
(
feeds
,
indent
=
2
))
else
:
with
open
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
.json
'
)
as
feedsjson
:
with
open
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
_
{
p
}
.json
'
)
as
feedsjson
:
feeds
=
json
.
load
(
feedsjson
)
feeds
[
meta
[
'
id_generated
'
]]
=
meta
with
open
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
.json
'
,
mode
=
'
w
'
)
as
f
:
with
open
(
f
'
{
data_name
}
/
{
destination_folders
[
scenario_loop
]
}
/
{
categories
}
/Meta_Gen/
{
categories
}
_
{
p
}
.json
'
,
mode
=
'
w
'
)
as
f
:
f
.
write
(
json
.
dumps
(
feeds
,
indent
=
4
))
if
(
Nb_instance
==
1
):
...
...
@@ -219,5 +219,6 @@ def process_compute(data_name, camera, camera_resized, new_size, Nb_camera, Worl
f
.
write
(
json
.
dumps
(
list_count_categories
[
scenario_loop
][
destination_folder_loop
],
indent
=
4
))
with
open
(
f
'
{
data_name
}
/Count_
{
p
}
.json
'
,
mode
=
'
w
'
)
as
f
:
f
.
write
(
json
.
dumps
(
list_count_categories
,
indent
=
4
))
#print(list_count_categories)
print
(
list_count_categories
)
print
(
f
'
{
data_name
}
/
{
destination_folder_loop
}
/Count_
{
p
}
.json
'
)
This diff is collapsed.
Click to expand it.
main.py
+
6
−
22
View file @
6668f884
...
...
@@ -36,9 +36,9 @@ def generate_folders(name, list_categories, scenario):
is_exist2
=
os
.
path
.
exists
(
f
"
{
name
}
/Generated_
{
scenario
}
_Testing/
{
cat
}
/
{
f
}
"
)
if
not
is_exist2
:
os
.
makedirs
(
f
"
{
name
}
/Generated_
{
scenario
}
_Testing/
{
cat
}
/
{
f
}
"
)
is_exist2
=
os
.
path
.
exists
(
f
"
{
name
}
/dont_save/
{
cat
}
/
{
f
}
"
)
is_exist2
=
os
.
path
.
exists
(
f
"
{
name
}
/
Generated_
{
scenario
}
_
dont_save/
{
cat
}
/
{
f
}
"
)
if
not
is_exist2
:
os
.
makedirs
(
f
"
{
name
}
/dont_save/
{
cat
}
/
{
f
}
"
)
os
.
makedirs
(
f
"
{
name
}
/
Generated_
{
scenario
}
_
dont_save/
{
cat
}
/
{
f
}
"
)
...
...
@@ -78,26 +78,10 @@ if __name__ == '__main__':
"
low
"
:
"
ground_truth_depth
"
}
dataset_type
=
data_options
[
choice
]
dataset_name
=
f
"
/gpfsscratch/rech/uli/ubn15wo/dataset/s2rg/Fruits_all_medium/GUIMOD_
{
choice
}
"
list_categories
=
[
"
banana1
"
,
"
kiwi1
"
,
"
pear2
"
,
"
strawberry1
"
,
"
apricot
"
,
"
orange2
"
,
"
peach1
"
,
"
lemon2
"
,
"
apple2
"
]
list_categories
=
[
"
banana1
"
,
"
kiwi1
"
,
"
pear2
"
,
"
apricot
"
,
"
orange2
"
,
"
peach1
"
,
"
lemon2
"
,
"
apple2
"
]
Nb_camera
=
15
#Nb_world = 10000
generate_folders
(
dataset_name
,
list_categories
)
for
cat
in
list_categories
:
src_bbox
=
f
"
Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/Generated/Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
shutil
.
copy
(
src_bbox
,
dst_bbox
)
for
categories
in
list_categories
:
point_cloud
=
f
'
{
dataset_name
}
/Generated/Models/
{
categories
}
/
{
categories
.
lower
()
}
.ply
'
pcd
=
o3d
.
io
.
read_point_cloud
(
point_cloud
)
#print("pcd", pcd)
fps_points
=
apply_fps
(
pcd
,
8
)
#print(fps_points)
np
.
savetxt
(
f
'
{
dataset_name
}
/Generated/FPS/
{
categories
}
_fps_3d.txt
'
,
fps_points
)
generate_folders
(
dataset_name
,
list_categories
,
scenario
)
if
choice
==
'
high
'
:
...
...
@@ -123,19 +107,19 @@ if __name__ == '__main__':
#np.savetxt(f'{dataset_name}/Generated/camera_{choice}.txt', camera)
reform_data
(
dataset_src
,
dataset_name
,
dataset_type
,
Nb_camera
,
args
.
World_begin
,
args
.
Nb_worlds
)
#
reform_data(dataset_src, dataset_name, dataset_type, Nb_camera, args.World_begin, args.Nb_worlds)
list_categories
=
[
"
banana1
"
,
"
kiwi1
"
,
"
pear2
"
,
"
strawberry1
"
,
"
apricot
"
,
"
orange2
"
,
"
peach1
"
,
"
lemon2
"
,
"
apple2
"
]
objs
=
{
"
banana1
"
:
[
0.02949700132012367249
,
0.1511049866676330566
,
0.06059300713241100311
],
"
kiwi1
"
:
[
0.04908600077033042908
,
0.07206099480390548706
,
0.04909799993038177490
],
"
pear2
"
:
[
0.06601099669933319092
,
0.1287339925765991211
,
0.06739201396703720093
],
"
strawberry1
"
:
[
0.01698100194334983826
,
0.02203200198709964752
,
0.01685700193047523499
],
"
apricot
"
:
[
0.04213499650359153748
,
0.05482299625873565674
,
0.04333199933171272278
],
"
orange2
"
:
[
0.07349500805139541626
,
0.07585700601339340210
,
0.07458199560642242432
],
"
peach1
"
:
[
0.07397901266813278198
,
0.07111301273107528687
,
0.07657301425933837891
],
"
lemon2
"
:
[
0.04686100035905838013
,
0.04684200137853622437
,
0.07244800776243209839
],
"
apple2
"
:
[
0.05203099921345710754
,
0.04766000062227249146
,
0.05089000239968299866
]}
# "strawberry1": [0.01698100194334983826, 0.02203200198709964752, 0.01685700193047523499],
for
categories
in
list_categories
:
point_cloud
=
f
"
Models/
{
categories
}
/
{
categories
.
lower
()
}
.ply
"
pcd
=
o3d
.
io
.
read_point_cloud
(
point_cloud
)
...
...
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