Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210610347
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210610347
Commits
09dfbd63
Commit
09dfbd63
authored
3 years ago
by
何向东
Browse files
Options
Downloads
Patches
Plain Diff
训练过程中裁切图像
parent
15e14537
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
dataset.py
+7
-2
7 additions, 2 deletions
dataset.py
with
7 additions
and
2 deletions
dataset.py
+
7
−
2
View file @
09dfbd63
...
...
@@ -3,6 +3,7 @@ import os
from
PIL
import
Image
import
cv2
import
mindspore.dataset
as
ds
import
random
class
GetDatasetGenerator
:
...
...
@@ -16,12 +17,16 @@ class GetDatasetGenerator:
line
=
f
.
readline
()
# 读取下一行
def
__getitem__
(
self
,
index
):
size1
=
3400
size2
=
3600
r1
=
random
.
randint
(
0
,
6800
-
size1
)
r2
=
random
.
randint
(
0
,
7200
-
size2
)
image
=
np
.
float32
(
cv2
.
imread
(
self
.
path
+
"
/JPEGImages/
"
+
self
.
__data
[
index
]
+
"
.bmp
"
))
image
=
image
.
swapaxes
(
1
,
2
).
swapaxes
(
0
,
1
)
image
=
image
[
3
,
r1
:
r1
+
size1
,
r2
:
r2
+
size2
]
mask
=
Image
.
open
(
self
.
path
+
"
/SegmentationClass/
"
+
self
.
__data
[
index
]
+
"
.png
"
)
mask
=
np
.
int32
(
np
.
asarray
(
mask
))
print
(
image
.
shape
)
print
(
mask
.
shape
)
mask
=
mask
[
r1
:
r1
+
size1
,
r2
:
r2
+
size2
]
return
image
,
mask
def
__len__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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