Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DOTA_devkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
REMY Arnaud
DOTA_devkit
Commits
0d9ff463
Commit
0d9ff463
authored
6 years ago
by
dingjian
Browse files
Options
Downloads
Patches
Plain Diff
fix multi process bug for python2
parent
afd0aa1a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ImgSplit_multi_process.py
+10
-6
10 additions, 6 deletions
ImgSplit_multi_process.py
SplitOnlyImage_multi_process.py
+8
-2
8 additions, 2 deletions
SplitOnlyImage_multi_process.py
with
18 additions
and
8 deletions
ImgSplit_multi_process.py
+
10
−
6
View file @
0d9ff463
...
...
@@ -38,6 +38,8 @@ def cal_line_length(point1, point2):
return
math
.
sqrt
(
math
.
pow
(
point1
[
0
]
-
point2
[
0
],
2
)
+
math
.
pow
(
point1
[
1
]
-
point2
[
1
],
2
))
def
split_single_warp
(
name
,
split_base
,
rate
,
extent
):
split_base
.
SplitSingle
(
name
,
rate
,
extent
)
class
splitbase
():
def
__init__
(
self
,
...
...
@@ -78,6 +80,7 @@ class splitbase():
self
.
choosebestpoint
=
choosebestpoint
self
.
ext
=
ext
self
.
padding
=
padding
self
.
num_process
=
num_process
self
.
pool
=
Pool
(
num_process
)
print
(
'
padding:
'
,
padding
)
...
...
@@ -258,14 +261,15 @@ class splitbase():
"""
:param rate: resize rate before cut
"""
imagelist
=
GetFileFromThisRootDir
(
self
.
imagepath
)
imagenames
=
[
util
.
custombasename
(
x
)
for
x
in
imagelist
if
(
util
.
custombasename
(
x
)
!=
'
Thumbs
'
)]
if
self
.
num_process
==
1
:
for
name
in
imagenames
:
self
.
SplitSingle
(
name
,
rate
,
self
.
ext
)
else
:
worker
=
partial
(
self
.
SplitSingle
,
rate
=
rate
,
extent
=
self
.
ext
)
#
# for name in imagenames:
# self.SplitSingle(name, rate, self.ext)
# worker = partial(self.SplitSingle, rate=rate, extent=self.ext)
worker
=
partial
(
split_single_warp
,
split_base
=
self
,
rate
=
rate
,
extent
=
self
.
ext
)
self
.
pool
.
map
(
worker
,
imagenames
)
def
__getstate__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
SplitOnlyImage_multi_process.py
+
8
−
2
View file @
0d9ff463
...
...
@@ -6,6 +6,9 @@ import dota_utils as util
from
multiprocessing
import
Pool
from
functools
import
partial
def
split_single_warp
(
name
,
split_base
,
rate
,
extent
):
split_base
.
SplitSingle
(
name
,
rate
,
extent
)
class
splitbase
():
def
__init__
(
self
,
srcpath
,
...
...
@@ -53,6 +56,9 @@ class splitbase():
weight
=
np
.
shape
(
resizeimg
)[
1
]
height
=
np
.
shape
(
resizeimg
)[
0
]
# if (max(weight, height) < self.subsize/2):
# return
left
,
up
=
0
,
0
while
(
left
<
weight
):
if
(
left
+
self
.
subsize
>=
weight
):
...
...
@@ -77,8 +83,8 @@ class splitbase():
imagelist
=
util
.
GetFileFromThisRootDir
(
self
.
srcpath
)
imagenames
=
[
util
.
custombasename
(
x
)
for
x
in
imagelist
if
(
util
.
custombasename
(
x
)
!=
'
Thumbs
'
)]
worker
=
partial
(
self
.
SplitSingle
,
rate
=
rate
,
extent
=
self
.
ext
)
#
worker = partial(self.SplitSingle, rate=rate, extent=self.ext)
worker
=
partial
(
split_single_warp
,
split_base
=
self
,
rate
=
rate
,
extent
=
self
.
ext
)
self
.
pool
.
map
(
worker
,
imagenames
)
#
# for name in imagenames:
...
...
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