Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FCN-CD-PyTorch
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
Container 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
manli
FCN-CD-PyTorch
Commits
73e08097
Unverified
Commit
73e08097
authored
4 years ago
by
Lin Manhui
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #5 from Larry-Zheng/master
Feat: cache for OSCD images
parents
29041640
7d951e6d
No related branches found
No related tags found
1 merge request
!2
Update outdated code
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/data/OSCD.py
+30
-1
30 additions, 1 deletion
src/data/OSCD.py
with
30 additions
and
1 deletion
src/data/OSCD.py
+
30
−
1
View file @
73e08097
...
...
@@ -50,7 +50,36 @@ class OSCDDataset(CDDataset):
t1_list
=
[[
join
(
image_dir
,
city
,
'
imgs_1_rect
'
,
band
+
'
.tif
'
)
for
band
in
self
.
__BAND_NAMES
]
for
city
in
cities
]
t2_list
=
[[
join
(
image_dir
,
city
,
'
imgs_2_rect
'
,
band
+
'
.tif
'
)
for
band
in
self
.
__BAND_NAMES
]
for
city
in
cities
]
label_list
=
[
join
(
label_dir
,
city
,
'
cm
'
,
city
+
'
-cm.tif
'
)
for
city
in
cities
]
#准备数据
print
(
'
preparing %s data ...
\n
'
%
self
.
phase
)
pb
=
tqdm
(
list
(
range
(
len
(
t1_list
))))
self
.
t1_imgs
=
[]
self
.
t2_imgs
=
[]
for
i
in
pb
:
self
.
t1_imgs
.
append
(
self
.
fetch_image
(
t1_list
[
i
]))
self
.
t2_imgs
.
append
(
self
.
fetch_image
(
t2_list
[
i
]))
return
t1_list
,
t2_list
,
label_list
#重写该方法
def
__getitem__
(
self
,
index
):
if
index
>=
len
(
self
):
raise
IndexError
index
=
index
%
self
.
len
t1
=
self
.
t1_imgs
[
index
]
t2
=
self
.
t2_imgs
[
index
]
label
=
self
.
fetch_label
(
self
.
label_list
[
index
])
t1
,
t2
,
label
=
self
.
preprocess
(
t1
,
t2
,
label
)
if
self
.
phase
==
'
train
'
:
return
t1
,
t2
,
label
else
:
return
self
.
get_name
(
index
),
t1
,
t2
,
label
def
fetch_image
(
self
,
image_paths
):
return
np
.
stack
([
default_loader
(
p
)
for
p
in
image_paths
],
axis
=-
1
).
astype
(
np
.
float32
)
...
...
@@ -67,4 +96,4 @@ class OSCDDataset(CDDataset):
self
.
label_pool
[
label_path
]
=
label
return
label
\ 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