Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Image classification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Corbani Pierre
Image classification
Commits
6ed0414c
Commit
6ed0414c
authored
1 year ago
by
Picorba
Browse files
Options
Downloads
Patches
Plain Diff
first commit
parents
Branches
Branches containing commit
No related tags found
1 merge request
!1
first commit
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
read_cifar_batch.py
+39
-0
39 additions, 0 deletions
read_cifar_batch.py
test.ipynb
+0
-0
0 additions, 0 deletions
test.ipynb
with
39 additions
and
0 deletions
read_cifar_batch.py
0 → 100644
+
39
−
0
View file @
6ed0414c
import
pickle
import
numpy
as
np
import
glob
def
unpickle
(
file
):
with
open
(
file
,
'
rb
'
)
as
fo
:
dict
=
pickle
.
load
(
fo
,
encoding
=
'
bytes
'
)
return
dict
def
read_cifar_batch
(
path_to_batch_file
):
dict
=
unpickle
(
path_to_batch_file
)
data
=
np
.
array
(
dict
[
b
'
data
'
],
dtype
=
np
.
float32
)
/
255
labels
=
np
.
array
(
dict
[
b
'
labels
'
],
dtype
=
np
.
int64
)
return
data
,
labels
def
read_cifar
(
path_to_batches_files
):
files
=
glob
.
glob
(
path_to_batches_files
)
data
,
labels
=
read_cifar_batch
(
files
[
0
])
for
i
in
range
(
1
,
len
(
files
)):
data_temp
,
labels_temp
=
read_cifar_batch
(
files
[
i
])
data
=
np
.
concatenate
((
data
,
data_temp
),
axis
=
0
)
labels
=
np
.
concatenate
((
labels
,
labels_temp
),
axis
=
0
)
return
data
,
labels
if
__name__
==
"
__main__
"
:
path
=
"
image-classification/data/cifar-10-batches-py/data_batch_1
"
read_cifar_batch
(
path
)
#plot the 9 first image of the batch
import
matplotlib.pyplot
as
plt
data
,
labels
=
read_cifar_batch
(
path
)
fig
,
axes
=
plt
.
subplots
(
3
,
3
)
fig
.
subplots_adjust
(
hspace
=
0.6
,
wspace
=
0.3
)
for
i
,
ax
in
enumerate
(
axes
.
flat
):
ax
.
imshow
(
data
[
i
].
reshape
(
3
,
32
,
32
).
transpose
([
1
,
2
,
0
]))
ax
.
set_xticks
([])
ax
.
set_yticks
([])
ax
.
set_xlabel
(
labels
[
i
])
plt
.
show
()
This diff is collapsed.
Click to expand it.
test.ipynb
0 → 100644
+
0
−
0
View file @
6ed0414c
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
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