Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nimbusnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
vdongre2
nimbusnet
Commits
e3217bc8
Commit
e3217bc8
authored
5 years ago
by
aua2
Browse files
Options
Downloads
Patches
Plain Diff
feat: add numpy array extraction script
parent
c529257e
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
extract.py
+41
-0
41 additions, 0 deletions
extract.py
with
41 additions
and
0 deletions
extract.py
0 → 100644
+
41
−
0
View file @
e3217bc8
import
h5py
import
os
import
numpy
as
np
from
tqdm
import
tqdm
giant_array
=
[]
giant_label_array
=
[]
home
=
'
/home/hackathon/output_64_Javier_labelled
'
for
path
in
tqdm
(
os
.
scandir
(
home
)):
if
path
.
path
.
endswith
(
"
.hdf
"
):
file_path
=
str
(
path
.
path
)
else
:
continue
try
:
#grab h5py file object
hf_file
=
h5py
.
File
(
file_path
,
'
r
'
)
except
:
continue
#list the main groups; image number in this case
hf_keys
=
list
(
hf_file
.
keys
())
#access all data within images; save into an array if you like
#automatically extracted as numpy arrays
for
image_num
in
hf_keys
:
Classification_Accuracy
=
hf_file
[
image_num
+
'
/ClassificationAccuracy
'
][()]
Feature_Labels
=
hf_file
[
image_num
+
'
/FeatureLabels
'
][()]
Image_Classification
=
hf_file
[
image_num
+
'
/ImageClassification
'
][()]
Image_Features
=
hf_file
[
image_num
+
'
/ImageFeatures
'
][()]
giant_array
.
append
(
Image_Features
)
giant_label_array
.
append
(
Image_Classification
)
giant_numpy_array
=
np
.
array
(
giant_array
)
giant_numpy_label_array
=
np
.
array
(
giant_label_array
)
print
(
giant_numpy_array
.
shape
)
print
(
giant_numpy_label_array
.
shape
)
np
.
save
(
'
/home/user/modis_full
'
,
giant_numpy_array
)
np
.
save
(
'
/home/user/modis_full_labels
'
,
giant_numpy_label_array
)
\ No newline at end of file
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