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
a1be92c1
Commit
a1be92c1
authored
2 years ago
by
Guillaume Duret
Browse files
Options
Downloads
Patches
Plain Diff
cleaning main
parent
326983e4
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
main.py
+9
-228
9 additions, 228 deletions
main.py
with
9 additions
and
228 deletions
main.py
+
9
−
228
View file @
a1be92c1
...
@@ -10,57 +10,10 @@ from bbox_3d import generate_3d_bbox
...
@@ -10,57 +10,10 @@ from bbox_3d import generate_3d_bbox
import
shutil
import
shutil
def
compute_categories_id
(
data_name
,
world
):
#Category = 'banana1'
#Category = 'pear2'
#Category = "orange2"
# Opening JSON file
f
=
open
(
f
'
{
data_name
}
/Meta/
{
world
}
.json
'
)
# returns JSON object as
# a dictionary
data
=
json
.
load
(
f
)
# Iterating through the json
# list
catergories_label_to_id
=
{}
catergories_id_to_label
=
{}
catergories_instance_array_cat_to_id
=
{}
catergories_instance_array_id_to_cat
=
{}
for
k
in
data
[
'
categories
'
]:
catergories_label_to_id
[
k
[
'
label
'
]]
=
k
[
'
id
'
]
catergories_id_to_label
[
k
[
'
id
'
]]
=
k
[
'
label
'
]
catergories_instance_array_cat_to_id
[
k
[
'
label
'
]]
=
[]
for
k
in
data
[
'
objects
'
]:
#print(k)
#catergories_instance_array[catergories_id_to_label[i['category_id']]]
catergories_instance_array_id_to_cat
[
k
[
'
id
'
]]
=
catergories_id_to_label
[
k
[
'
category_id
'
]]
catergories_instance_array_cat_to_id
[
catergories_id_to_label
[
k
[
'
category_id
'
]]].
append
(
k
[
'
id
'
])
# if i['category_id'] == id_category :
# print("Hello fruits instance")
# id_instances.append(i['id'])
# print(i['id'])
# print("catergories_instance_array_cat_to_id : ", catergories_instance_array_cat_to_id)
# print("catergories_instance_array_id_to_cat : ", catergories_instance_array_id_to_cat)
# Closing file
f
.
close
()
return
catergories_instance_array_id_to_cat
,
catergories_instance_array_cat_to_id
def
generate_folders
(
name
,
list_categories
):
def
generate_folders
(
name
,
list_categories
):
is_exist
=
os
.
path
.
exists
(
name
)
is_exist
=
os
.
path
.
exists
(
name
)
if
not
is_exist
:
if
not
is_exist
:
os
.
mkdir
(
name
)
os
.
mkdir
(
name
)
folders
=
[
"
RGB
"
,
"
Depth
"
,
"
Mask
"
,
"
Meta
"
,
"
Pose
"
,
"
Bbox_2d
"
,
"
Bbox_2d_loose
"
,
"
Instance_Segmentation
"
,
"
Semantic_Segmentation
"
,
"
Instance_Mask
"
,
"
Occlusion
"
,
"
Models
"
,
"
Pose_transformed
"
,
"
Bbox
"
,
"
FPS
"
]
folders
=
[
"
RGB
"
,
"
Depth
"
,
"
Mask
"
,
"
Meta
"
,
"
Pose
"
,
"
Bbox_2d
"
,
"
Bbox_2d_loose
"
,
"
Instance_Segmentation
"
,
"
Semantic_Segmentation
"
,
"
Instance_Mask
"
,
"
Occlusion
"
,
"
Models
"
,
"
Pose_transformed
"
,
"
Bbox
"
,
"
FPS
"
]
for
f
in
folders
:
for
f
in
folders
:
is_exist
=
os
.
path
.
exists
(
f
"
{
name
}
/
{
f
}
"
)
is_exist
=
os
.
path
.
exists
(
f
"
{
name
}
/
{
f
}
"
)
...
@@ -71,194 +24,26 @@ def generate_folders(name, list_categories):
...
@@ -71,194 +24,26 @@ def generate_folders(name, list_categories):
for
cat
in
list_categories
:
for
cat
in
list_categories
:
os
.
makedirs
(
f
"
{
name
}
/Generated/
{
f
}
/
{
cat
}
"
)
os
.
makedirs
(
f
"
{
name
}
/Generated/
{
f
}
/
{
cat
}
"
)
# def compute_categories_id(dataset_src, world):
# #Category = 'banana1'
# #Category = 'pear2'
# #Category = "orange2"
# # Opening JSON file
# f = open(f'{dataset_src}/{world}/meta.json')
# # returns JSON object as
# # a dictionary
# data = json.load(f)
# # Iterating through the json
# # list
# id_category = 0
# catergories_label_to_id={}
# catergories_id_to_label={}
# catergories_instance_array_cat_to_id={}
# catergories_instance_array_id_to_cat={}
# for i in data['categories']:
# catergories_label_to_id[i['label']]=i['id']
# catergories_id_to_label[i['id']]=i['label']
# catergories_instance_array_cat_to_id[i['label']]=[]
# for i in data['objects']:
# print(i)
# #catergories_instance_array[catergories_id_to_label[i['category_id']]]
# catergories_instance_array_id_to_cat[i['id']] = catergories_id_to_label[i['category_id']]
# catergories_instance_array_cat_to_id[catergories_id_to_label[i['category_id']]].append(i['id'])
# # if i['category_id'] == id_category :
# # print("Hello fruits instance")
# # id_instances.append(i['id'])
# # print(i['id'])
# print("catergories_instance_array_cat_to_id : ", catergories_instance_array_cat_to_id)
# print("catergories_instance_array_id_to_cat : ", catergories_instance_array_id_to_cat)
# # Closing file
# f.close()
# return catergories_instance_array_id_to_cat, catergories_instance_array_cat_to_id
# def get_id_wanted(wanted_category):
# #Category = 'banana1'
# #Category = 'pear2'
# #Category = "orange2"
# # Opening JSON file
# f = open('/media/gduret/DATA/dataset/s2rg/Fruits_all_medium/data/1/meta.json')
# # returns JSON object as
# # a dictionary
# data = json.load(f)
# # Iterating through the json
# # list
# id_category = 0
# for i in data['categories']:
# print(i)
# if i['label'] == wanted_category :
# print("Hello fruits")
# id_category = i['id']
# print(id_category)
# id_instances = []
# for i in data['objects']:
# print(i)
# if i['category_id'] == id_category :
# print("Hello fruits instance")
# id_instances.append(i['id'])
# print(i['id'])
# print(id_instances)
# # Closing file
# f.close()
# return id_instances
# def compute_id_good_occ(dataset_src, world, camera, type_data, frame, catergories_instance_array_id_to_cat, catergories_instance_array_cat_to_id, Occ_wanted):
# f2 = open(f'{dataset_src}/{world}/grabber_{camera}/{type_data}/occlusion/{frame}.json')
# data2 = json.load(f2)
# catergories_occ_array = {}
# for cat in catergories_instance_array_cat_to_id :
# #print(cat)
# catergories_occ_array[cat] = []
# for i in data2:
# #print('i : ',i)
# #print(i['id'])
# #print(id_instances)
# if i['occlusion_value'] > 0.5 :
# catergories_occ_array[catergories_instance_array_id_to_cat[i['id']]].append(i['id'])
# # if i['id'] in id_instances :
# # print("Hello banana instance occ")
# # if i['occlusion_value'] > 0.5 :
# # id_instances_good.append(i['id'])
# # print(i['id'])
# # print(i['occlusion_value'])
# print(catergories_occ_array)
# # Closing file
# f2.close()
# return catergories_occ_array
# def get_id_good_occ(Occ_wanted):
# f2 = open('/media/gduret/DATA/dataset/s2rg/Fruits_all_medium/data/1/grabber_1/ground_truth_rgb/occlusion/4_158000000.json')
# data2 = json.load(f2)
# id_instances_good = []
# for i in data2:
# print('i : ',i)
# print(i['id'])
# print(id_instances)
# if i['id'] in id_instances :
# print("Hello banana instance occ")
# if i['occlusion_value'] > 0.5 :
# id_instances_good.append(i['id'])
# print(i['id'])
# print(i['occlusion_value'])
# print(id_instances_good)
# # Closing file
# f2.close()
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
#dataset_src = "/media/mahmoud/E/Fruits_easy/data"
### parameters ###
# futur parameters :
Categories
=
[]
# to read
Categories
=
[]
# to read
Nb_instance
=
1
Nb_instance
=
1
occ_target
=
0.5
occ_target
=
0.5
#catergories_instance_array_id_to_cat, catergories_instance_array_cat_to_id = compute_categories_id(dataset_name, 1)
dataset_src
=
"
/media/gduret/DATA/dataset/s2rg/Fruits_all_medium/data
"
dataset_src
=
"
/media/gduret/DATA/dataset/s2rg/Fruits_all_medium/data
"
#dataset_src = "/media/mahmoud/E/Fruits_easy/data"
choice
=
"
low
"
choice
=
"
low
"
# depth of rgb resolution datas
data_options
=
{
"
high
"
:
"
ground_truth_rgb
"
,
data_options
=
{
"
high
"
:
"
ground_truth_rgb
"
,
"
low
"
:
"
ground_truth_depth
"
}
"
low
"
:
"
ground_truth_depth
"
}
dataset_type
=
data_options
[
choice
]
dataset_type
=
data_options
[
choice
]
#compute_id_good_occ(dataset_src, 1, 1, dataset_type, "1_926000000", catergories_instance_array_id_to_cat, catergories_instance_array_cat_to_id, Occ_target)
dataset_name
=
f
"
GUIMOD_
{
choice
}
"
dataset_name
=
f
"
GUIMOD_
{
choice
}
"
list_categories
=
[
"
banana1
"
,
"
kiwi1
"
,
"
pear2
"
,
"
strawberry1
"
,
"
apricot
"
,
"
orange2
"
,
"
peach1
"
,
"
lemon2
"
,
"
apple2
"
]
list_categories
=
[
"
banana1
"
,
"
kiwi1
"
,
"
pear2
"
,
"
strawberry1
"
,
"
apricot
"
,
"
orange2
"
,
"
peach1
"
,
"
lemon2
"
,
"
apple2
"
]
generate_folders
(
dataset_name
,
list_categories
)
# frame = "1_600000000"
frame
=
"
1_926000000
"
Nb_camera
=
15
Nb_world
=
2
generate_folders
(
dataset_name
,
list_categories
)
for
cat
in
list_categories
:
for
cat
in
list_categories
:
src_bbox
=
f
"
Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
src_bbox
=
f
"
Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/Generated/Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/Generated/Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
...
@@ -275,10 +60,6 @@ if __name__ == '__main__':
...
@@ -275,10 +60,6 @@ if __name__ == '__main__':
np
.
savetxt
(
f
'
{
dataset_name
}
/Generated/camera_
{
choice
}
.txt
'
,
camera
)
np
.
savetxt
(
f
'
{
dataset_name
}
/Generated/camera_
{
choice
}
.txt
'
,
camera
)
# frame = "1_600000000"
frame
=
"
1_926000000
"
Nb_camera
=
15
Nb_world
=
2
reform_data
(
dataset_src
,
dataset_name
,
dataset_type
,
frame
,
Nb_camera
,
Nb_world
)
reform_data
(
dataset_src
,
dataset_name
,
dataset_type
,
frame
,
Nb_camera
,
Nb_world
)
transform_pose
(
dataset_name
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
)
transform_pose
(
dataset_name
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
)
...
...
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