Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP-IA-Syntax-Error
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIGEOLAS-CHOURY Paul
TP-IA-Syntax-Error
Commits
f55f2fc6
Commit
f55f2fc6
authored
4 months ago
by
paul_pvc
Browse files
Options
Downloads
Patches
Plain Diff
cc
parent
f7b52fff
No related branches found
No related tags found
1 merge request
!1
Gris
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
TP.py
+9
-7
9 additions, 7 deletions
TP.py
TestTP.py
+1
-0
1 addition, 0 deletions
TestTP.py
with
10 additions
and
7 deletions
TP.py
+
9
−
7
View file @
f55f2fc6
...
...
@@ -30,8 +30,8 @@ def buildSampleFromPath(path1, path2, size=0):
return
S
def
computePixelBW
(
image
):
return
np
.
array
(
image
.
convert
(
"
L
"
))
def
computePixelBW
_histo
(
image
):
return
Image
.
fromarray
(
np
.
array
(
image
.
convert
(
"
L
"
))
).
histogram
()
def
computeDict
(
image_path
,
path
,
y_true_value
,
max_size
:
tuple
):
...
...
@@ -51,11 +51,11 @@ def computeDict(image_path, path, y_true_value, max_size: tuple):
resized
=
resizeImage
(
image
,
*
max_size
)
# On ne stocke pas resized image, on calcule tout avant de l'oublier
#print(computePixelBW_histo(resized))
return
{
"
name_path
"
:
full_path
,
#"resized_image": resized,
"
X_histo
"
:
computeHisto
(
resized
),
"
X_pixelbw
"
:
computePixelBW
(
resized
),
"
X_pixelbw
"
:
computePixelBW
_histo
(
resized
),
"
y_true_class
"
:
y_true_value
,
"
y_predicted_class
"
:
None
}
...
...
@@ -94,8 +94,10 @@ def fitFromHisto(S, algo):
S_train
,
S_test
,
y_train
,
y_test
=
train_test_split
(
S
,
y
,
test_size
=
0.2
,
random_state
=
42
)
X_train
=
np
.
array
([
np
.
array
(
l
[
"
X_histo
"
])
for
l
in
S_train
])
print
(
len
(
X_train
[
0
]))
X_train
=
np
.
array
([
np
.
array
(
l
[
"
X_histo
"
]
+
l
[
"
X_pixelbw
"
])
for
l
in
S_train
])
#X_train = df[["X_histo", "X_pixelbw"]]
#print(X_train)
#print(len(X_train[0]))
algo
.
fit
(
X_train
,
y_train
)
...
...
@@ -111,7 +113,7 @@ def predictFromHisto(S, model, list_dict=True):
:param list_dict: is the sample in list(dict)
:return: None
"""
tab
=
model
.
predict
(
np
.
array
([
x
[
"
X_histo
"
]
for
x
in
S
]))
tab
=
model
.
predict
(
np
.
array
([
x
[
"
X_histo
"
]
+
x
[
"
X_pixelbw
"
]
for
x
in
S
]))
if
list_dict
:
for
i
in
range
(
len
(
S
)):
S
[
i
][
"
y_predicted_class
"
]
=
tab
[
i
]
...
...
This diff is collapsed.
Click to expand it.
TestTP.py
+
1
−
0
View file @
f55f2fc6
...
...
@@ -2,6 +2,7 @@ from PIL import Image
from
sklearn.naive_bayes
import
GaussianNB
,
CategoricalNB
from
sklearn.svm
import
SVC
import
TP
from
xgboost
import
XGBClassifier
path1_t
=
"
./Init/Mer
"
path2_t
=
"
./Init/Ailleurs
"
...
...
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