Nantes Université
Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
L
Lgeval
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Service d'assistance
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
CROHME
Lgeval
Validations
6a592b28
Valider
6a592b28
rédigé
il y a 4 ans
par
ayushkumarshah
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
feat: Use argparse and uupdate description
parent
559b7bea
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
bin/confHist
+114
-30
114 ajouts, 30 suppressions
bin/confHist
src/confHists.py
+35
-19
35 ajouts, 19 suppressions
src/confHists.py
avec
149 ajouts
et
49 suppressions
bin/confHist
+
114
−
30
Voir le fichier @
6a592b28
#!/bin/bash
usage
()
{
echo
"Usage: confHist (output_dir target_dir) | fileList -gs|--graphSize <value>"
echo
-e
"
\t\t
[-m|--minCount <value>] [-s|--strokes] [-i|--lgimgDir <directory>]"
echo
-e
"
\t\t
[-p|--dotpdfDir <directory>] [--split] [--filter] [-h|--help]"
echo
""
echo
"------- Required Arguments -------"
echo
"output_dir Output lg files directory"
echo
"target_dir Ground truth lg files directory"
echo
"fileList File whose each line contains outputfile_path targetfile_path"
echo
-e
"
\t\t\t\t\t
is used for comparison."
echo
"Note: Use either the 2 directories or the fileList"
echo
-e
"-gs or --graphSize <value>
\t\t
The number of objects/primitives in targets to analyze"
echo
""
echo
"------- Optional Arguments -------"
echo
-e
"-m or --minCount <value>
\t
The minimum number of times an error should occur before"
echo
-e
"
\t\t\t\t
detailed information is provided in the confusion histogram"
echo
-e
"
\t\t\t\t
By default, all errors are shown (minCount = 1)"
echo
-e
"-s or --strokes
\t\t
Construct stroke(primitive) confusion histograms in addition"
echo
-e
"
\t\t\t\t
to object confusion histograms"
echo
-e
"-i or --lgimgDir <directory>
\t
The directory containing the expression images of the lg files"
echo
-e
"-p or --dotpdfDir <directory>
\t
The directory containing the expression images of the lg files"
echo
-e
"-sp or --split
\t\t\t
Separate the more frequent(>minCount) errors and (<=minCount)"
echo
-e
"
\t\t\t\t
errors"
echo
-e
"-f or --filter
\t\t\t
Ignore the less frequent(<=minCount) errors"
echo
-e
"-h or --help
\t\t\t
Print usage and this help message and exit"
}
if
[
$#
-
lt
2
]
if
[
$#
-
eq
0
]
then
echo
"LgEval confHist: Structure Confusion Histogram Generator"
echo
"Copyright (c) R. Zanibbi, H. Mouchere, 2013-2014"
echo
""
echo
"Usage: confHist dir1 dir2 graphSize [minCount] [strokes] OR"
echo
" confHist fileList graphSize [minCount] [strokes]"
echo
"Usage: confHist (output_dir target_dir) | fileList -gs|--graphSize <value>"
echo
-e
"
\t\t
[-m|--minCount <value>] [-s|--strokes] [-i|--lgimgDir <directory>]"
echo
-e
"
\t\t
[-p|--dotpdfDir <directory>] [--split] [--filter] [-h|--help]"
echo
"For details on arguments usage: confHist -h or confHist --help"
echo
""
echo
"Creates an .html file containing structure confusion histograms"
echo
"at the object level. The histograms visualize errors by their"
echo
"frequency when comparing files in dir1 vs. dir2 (dir2 is 'ground truth')."
echo
"It is assumed that every .lg file in dir1 exists in dir2, and a file"
echo
"dir1_vs_dir2 is created as output."
echo
""
echo
"If a file list is provided, then each line of the file"
echo
"(format: 'outputfile_path targetfile_path') is used for comparison."
echo
""
echo
"graphSize is the number of objects/primitives in targets to analyze."
echo
"minCount is the minimum number of times an error should occur before"
echo
"detailed information is provided in the confusion histogram. By default,"
echo
"all errors are shown (minCount = 1)."
echo
"frequency when comparing files in output_dir vs. target_dir (target_dir is 'ground truth')."
echo
"It is assumed that every .lg file in output_dir exists in target_dir, and a file"
echo
"output_dir_vs_target_dir is created as output."
echo
""
echo
"If an optional argument is provided (<strokes>), then stroke"
echo
"confusion histograms will be constructed in addition to object"
echo
"confusion histograms."
echo
""
echo
"Output is written to the file CH_<dir1_vs_dir2>.html or"
echo
"CH_<fileList>.html, depending upon the arguments used."
echo
"Output is written to the file confHist_outputs/CH_<output_dir_vs_target_dir>.html"
echo
"or confHist_outputs/CH_<fileList>.html, depending upon the arguments used."
exit
0
fi
GRAPH_SIZE
=
""
MIN_COUNT
=
1
STROKES
=
0
LGIMG_DIR
=
"../"
DOTPDF_DIR
=
"../"
SPLIT
=
0
FILTER
=
1
POSITIONAL
=()
while
[[
$#
-gt
0
]]
do
key
=
"
$1
"
case
$key
in
-h
|
--help
)
usage
exit
0
;;
-gs
|
--graphSize
)
GRAPH_SIZE
=
"
$2
"
shift
# past argument
shift
# past value
;;
-m
|
--minCount
)
MIN_COUNT
=
"
$2
"
shift
# past argument
shift
# past value
;;
-s
|
--strokes
)
STROKES
=
1
shift
# past argument
;;
-i
|
--lgimgDir
)
LGIMG_DIR
=
"
$2
"
shift
# past argument
shift
# past value
;;
-p
|
--dotpdfDir
)
DOTPDF_DIR
=
"
$2
"
shift
# past argument
shift
# past value
;;
-sp
|
--split
)
SPLIT
=
1
shift
# past argument
;;
-f
|
--filter
)
FILTER
=
1
shift
# past argument
;;
*
)
# unknown option
POSITIONAL+
=(
"
$1
"
)
# save it in an array for later
shift
# past argument
;;
esac
done
set
--
"
${
POSITIONAL
[@]
}
"
# restore positional parameters
if
[[
-z
"
$GRAPH_SIZE
"
]]
then
echo
"Error: Please enter graph size using -gs value OR --graphSize value"
exit
1
fi
OUT_DIR
=
"confHist_outputs"
if
[
!
-d
$OUT_DIR
]
then
...
...
@@ -40,25 +119,25 @@ fi
if
[
-d
$1
]
then
# Remove trailing slashes.
dir
1
=
${
1
%/
}
dir
2
=
${
2
%/
}
base1
=
`
basename
$dir
1
`
base2
=
`
basename
$dir
2
`
output_
dir
=
${
1
%/
}
target_
dir
=
${
2
%/
}
base1
=
`
basename
$
output_
dir
`
base2
=
`
basename
$
target_
dir
`
INFILE
=
"
$OUT_DIR
/
${
base1
}
_vs_
${
base2
}
"
# Two directories passed (hopefully).
# NOTE: Assumes same number of .lg files with
# matching names.
ls
$dir
1
/
*
.lg
>
_f1
ls
$dir
2
/
*
.lg
>
_f2
ls
$
output_
dir
/
*
.lg
>
_f1
ls
$
target_
dir
/
*
.lg
>
_f2
L1
=
`
wc
-l
_f1 |
awk
'{print $1}'
`
L2
=
`
wc
-l
_f2 |
awk
'{print $1}'
`
if
[
"
$L1
"
!=
"
$L2
"
]
then
echo
" !! Error: differing number of .lg files:"
echo
" (
$L1
)
$dir
1
"
echo
" (
$L2
)
$dir
2
"
echo
" (
$L1
)
$
output_
dir
"
echo
" (
$L2
)
$
target_
dir
"
rm
-f
_f1 _f2
exit
1
fi
...
...
@@ -67,11 +146,16 @@ then
rm
-f
_f1 _f2
# HACK: ${@:3} selects args starting from the third.
python
$LgEvalDir
/src/confHists.py
$INFILE
${
@
:3
}
python
$LgEvalDir
/src/confHists.py
--fileList
$INFILE
--graphSize
$GRAPH_SIZE
\
--minCount
$MIN_COUNT
--strokes
$STROKES
--lgimgDir
$LGIMG_DIR
\
--dotpdfDir
$DOTPDF_DIR
--split
$SPLIT
--filter
$FILTER
#rm $INFILE
else
# User-provided file list.
python
$LgEvalDir
/src/confHists.py
$@
echo
$@
python
$LgEvalDir
/src/confHists.py
--fileList
$@
--graphSize
$GRAPH_SIZE
\
--minCount
$MIN_COUNT
--strokes
$STROKES
--lgimgDir
$LGIMG_DIR
\
--dotpdfDir
$DOTPDF_DIR
--split
$SPLIT
--filter
$FILTER
fi
exit
0
This diff is collapsed.
Cliquez pour l'agrandir.
src/confHists.py
+
35
−
19
Voir le fichier @
6a592b28
...
...
@@ -11,23 +11,23 @@ import sys
import
csv
import
time
import
os
import
argparse
from
lg
import
*
from
lgio
import
*
import
SmGrConfMatrix
import
compareTools
def
main
(
fileList
,
minCount
,
confMat
,
confMatObj
,
subgraphSize
,
img_dir
=
None
):
def
main
(
fileList
,
minCount
=
1
,
confMat
=
False
,
confMatObj
=
True
,
subgraphSize
=
1
,
img_dir
=
''
,
dotpdfDir
=
''
):
fileReader
=
csv
.
reader
(
open
(
fileList
),
delimiter
=
'
'
)
htmlStream
=
None
matrix
=
SmGrConfMatrix
.
ConfMatrix
()
matrixObj
=
SmGrConfMatrix
.
ConfMatrixObject
()
# if not osp.exists("confHist_outputs"):
# os.makedirs("confHist_outputs")
if
not
os
.
path
.
exists
(
"
confHist_outputs/lg2dot_png
"
):
os
.
makedirs
(
"
confHist_outputs/lg2dot_png
"
)
if
not
os
.
path
.
exists
(
"
confHist_outputs/lg2dot_pdf
"
):
os
.
makedirs
(
"
confHist_outputs/lg2dot_pdf
"
)
for
row
in
fileReader
:
# Skip comments and empty lines.
if
not
row
==
[]
and
not
row
[
0
].
strip
()[
0
]
==
"
#
"
:
...
...
@@ -204,18 +204,34 @@ def main(fileList, minCount, confMat, confMatObj, subgraphSize, img_dir=None):
htmlStream
.
write
(
'
</html>
'
)
htmlStream
.
close
()
# (RZ) Lazy - not checking arguments on assumption this is called from the
# strConfHist script.
minCount
=
1
fileList
=
sys
.
argv
[
1
]
subgraphSize
=
int
(
sys
.
argv
[
2
])
if
len
(
sys
.
argv
)
>
3
:
minCount
=
int
(
sys
.
argv
[
3
])
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
"
ConfHist Arguments
"
)
parser
.
add_argument
(
"
--fileList
"
,
type
=
str
,
required
=
True
,
help
=
"
The file containing list of lg file pairs to evaluate
"
)
parser
.
add_argument
(
"
-gs
"
,
"
--graphSize
"
,
type
=
int
,
required
=
True
,
help
=
"
The number of objects/primitives in targets to analyze
"
)
parser
.
add_argument
(
"
-m
"
,
"
--minCount
"
,
type
=
int
,
default
=
1
,
help
=
"
The minimum number of times an error should occur
"
)
parser
.
add_argument
(
"
-s
"
,
"
--strokes
"
,
type
=
int
,
default
=
0
,
help
=
"
Flag whether to construct stroke (primitive) confusion histograms
"
)
parser
.
add_argument
(
"
-i
"
,
"
--lgimgDir
"
,
type
=
str
,
help
=
"
The directory containing the expression images of the lg files
"
)
parser
.
add_argument
(
"
-p
"
,
"
--dotpdfDir
"
,
type
=
str
,
help
=
"
The directory containing the lg2dot comparison pdf outputs
"
)
parser
.
add_argument
(
"
-sp
"
,
"
--split
"
,
type
=
int
,
default
=
0
,
help
=
"
Flag whether to construct stroke (primitive) confusion histograms
"
)
parser
.
add_argument
(
"
-f
"
,
"
--filter
"
,
type
=
int
,
default
=
1
,
help
=
"
Flag whether to construct stroke (primitive) confusion histograms
"
)
args
=
parser
.
parse_args
()
return
args
confMatObj
=
True
confMat
=
True
if
len
(
sys
.
argv
)
>
4
else
False
# img_dir = '../../../../data/test2019_inkml2img' # 3branch...
img_dir
=
'
../../../../data/infty/IMG
'
# infty_contour...
# img_dir = '../../../Data/Expressions/IMG' # lpga_rf...
main
(
fileList
,
minCount
,
confMat
,
confMatObj
,
subgraphSize
,
img_dir
=
img_dir
)
if
__name__
==
"
__main__
"
:
args
=
parse_args
()
print
(
args
)
# img_dir = '../../../../data/test2019_inkml2img' # 3branch...
# img_dir = '../../../../data/infty/IMG' # infty_contour...
# img_dir = '../../../Data/Expressions/IMG' # lpga_rf...
img_dir
=
os
.
path
.
join
(
"
../..
"
,
args
.
lgimgDir
)
main
(
args
.
fileList
,
minCount
=
args
.
minCount
,
confMat
=
bool
(
args
.
strokes
),
subgraphSize
=
args
.
graphSize
,
img_dir
=
img_dir
,
dotpdfDir
=
args
.
dotpdfDir
)
This diff is collapsed.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter