Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
inovisao
crossvalidation-repetition-object-detection
Commits
cf9e1be5
Commit
cf9e1be5
authored
Sep 15, 2021
by
Gilberto Astolfi
Browse files
adicionando estrutura voc2007
parent
1e0f81f2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
1 deletion
+60
-1
__pycache__/augmentation.cpython-37.pyc
__pycache__/augmentation.cpython-37.pyc
+0
-0
__pycache__/cross_validation.cpython-37.pyc
__pycache__/cross_validation.cpython-37.pyc
+0
-0
__pycache__/repetitions.cpython-37.pyc
__pycache__/repetitions.cpython-37.pyc
+0
-0
__pycache__/transformation_image.cpython-37.pyc
__pycache__/transformation_image.cpython-37.pyc
+0
-0
augmentation.py
augmentation.py
+1
-0
estruturaVOC2007.py
estruturaVOC2007.py
+58
-0
main.py
main.py
+1
-1
No files found.
__pycache__/augmentation.cpython-37.pyc
0 → 100644
View file @
cf9e1be5
File added
__pycache__/cross_validation.cpython-37.pyc
0 → 100644
View file @
cf9e1be5
File added
__pycache__/repetitions.cpython-37.pyc
0 → 100644
View file @
cf9e1be5
File added
__pycache__/transformation_image.cpython-37.pyc
0 → 100644
View file @
cf9e1be5
File added
augmentation.py
View file @
cf9e1be5
...
...
@@ -361,6 +361,7 @@ class DataAugmentation:
def
oversampling
(
self
):
print
(
'Iniciando oversampling...'
)
print
(
self
.
root_path
)
folds
=
os
.
listdir
(
self
.
root_path
)
for
fold
in
folds
:
path_train
=
self
.
root_path
+
'/'
+
fold
+
'/train'
...
...
estruturaVOC2007.py
0 → 100644
View file @
cf9e1be5
import
os
import
glob
from
shutil
import
copyfile
,
rmtree
import
argparse
def
criar_diretorio
(
path_dir
):
if
not
os
.
path
.
exists
(
path_dir
):
os
.
makedirs
(
path_dir
)
def
remove_VOC
(
path_fold_voc
):
if
os
.
path
.
exists
(
path_fold_voc
):
print
(
'Removendo estrutura de pastas VOC2007'
)
rmtree
(
path_fold_voc
,
ignore_errors
=
True
)
def
criar_VOC
(
path_folds
,
path_fold_voc
):
remove_VOC
(
path_fold_voc
)
for
pth
in
os
.
listdir
(
path_folds
):
print
(
'Criando estutura VOC2007 para: '
+
pth
)
path_ann
=
path_fold_voc
+
'/'
+
pth
+
'/VOC2007/Annotations'
path_jpg
=
path_fold_voc
+
'/'
+
pth
+
'/VOC2007/JPEGImages'
path_txt
=
path_fold_voc
+
'/'
+
pth
+
'/VOC2007/ImageSets/Main'
criar_diretorio
(
path_ann
)
criar_diretorio
(
path_jpg
)
criar_diretorio
(
path_txt
)
path_fold
=
path_folds
+
'/'
+
pth
for
pt_conjunto
in
os
.
listdir
(
path_fold
):
pt_txt_conjunto
=
path_txt
+
'/'
+
pt_conjunto
+
'.txt'
path_conjunto
=
path_fold
+
'/'
+
pt_conjunto
for
cl
in
os
.
listdir
(
path_conjunto
):
path_class
=
path_conjunto
+
'/'
+
cl
files
=
glob
.
glob
(
path_class
+
"/*"
)
for
file
in
files
:
basename
=
os
.
path
.
basename
(
file
)
name
,
extension
=
os
.
path
.
splitext
(
basename
)
if
extension
==
'.jpg'
:
destino
=
path_jpg
+
'/'
+
basename
copyfile
(
file
,
destino
)
elif
extension
==
'.xml'
:
destino
=
path_ann
+
'/'
+
basename
copyfile
(
file
,
destino
)
f
=
open
(
pt_txt_conjunto
,
'a'
)
f
.
write
(
name
+
'
\n
'
)
f
.
close
()
print
(
'Finalizado a estutura VOC2007 para: '
+
pth
)
print
(
'Finalizado a estutura VOC2007 para todas as folds.'
)
if
__name__
==
'__main__'
:
# python3 estruturaVOC2007.py ../fold ../out_fold_voc
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'path_in'
,
metavar
=
'path_in'
,
type
=
str
,
help
=
'A root directory where are folds.'
)
parser
.
add_argument
(
'path_out'
,
metavar
=
'path_out'
,
type
=
str
,
help
=
'Path where the output will be created'
)
args
=
parser
.
parse_args
()
path_in
=
args
.
path_in
path_out
=
args
.
path_out
criar_VOC
(
path_in
,
path_out
)
\ No newline at end of file
main.py
View file @
cf9e1be5
...
...
@@ -6,7 +6,7 @@ import argparse
if
__name__
==
'__main__'
:
# python3 main.py .
/data
/Pests
3C1P ./data/folds repetition 30
True 0 True
# python3 main.py .
.
/Pests
4C2P ../folds cross 5
True 0 True
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'path_in'
,
metavar
=
'path_in'
,
type
=
str
,
help
=
'A root directory where are annotated images.'
)
parser
.
add_argument
(
'path_out'
,
metavar
=
'path_out'
,
type
=
str
,
help
=
'Path where the output will be created'
)
...
...
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