Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
maskrcnn
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
人工智能
maskrcnn
Commits
51025ef9
Commit
51025ef9
authored
Jul 05, 2019
by
吴升宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata
parent
2e62281c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
20 deletions
+51
-20
predictor.py
demo/predictor.py
+28
-3
webcam.py
demo/webcam.py
+14
-1
work.py
demo/work.py
+8
-15
celery.py
proj/celery.py
+1
-1
No files found.
demo/predictor.py
View file @
51025ef9
...
...
@@ -293,13 +293,36 @@ class COCODemo(object):
colors
=
self
.
compute_colors_for_labels
(
labels
)
.
tolist
()
img
=
None
point_list
=
[]
contour_max
=
[]
max_len
=
0
for
mask
,
color
in
zip
(
masks
,
colors
):
thresh
=
mask
[
0
,
:,
:,
None
]
contours
,
hierarchy
=
cv2_util
.
findContours
(
thresh
,
cv2
.
RETR_TREE
,
cv2
.
CHAIN_APPROX_SIMPLE
)
color
=
[
0
,
0
,
0
]
img
=
cv2
.
drawContours
(
image
,
contours
,
-
1
,
color
,
3
)
#print(contours)
#print(len(contours))
print
(
type
(
contours
))
for
contour
in
contours
:
print
(
len
(
contour
))
if
len
(
contour
)
>
max_len
:
max_len
=
len
(
contour
)
contour_max
=
contours
color
=
[
0
,
0
,
0
]
import
numpy
as
np
#np.array([contour_max])
abc
=
[]
for
i
in
contour_max
:
for
j
in
i
:
abc
.
append
(
str
(
j
[
0
][
0
])
+
'|'
+
str
(
j
[
0
][
1
]))
print
(
len
(
abc
))
#print(abc)
print
(
'==================================='
)
img
=
cv2
.
drawContours
(
image
,
contour_max
,
-
1
,
color
,
3
)
if
img
is
None
:
return
...
...
@@ -319,9 +342,11 @@ class COCODemo(object):
# 把图片皮肤颜色变为白色
# img = skin_to_white(img)
print
(
abc
)
composite
=
img
return
composite
if
not
abc
:
return
return
composite
,
abc
def
overlay_keypoints
(
self
,
image
,
predictions
):
keypoints
=
predictions
.
get_field
(
"keypoints"
)
...
...
demo/webcam.py
View file @
51025ef9
...
...
@@ -64,7 +64,20 @@ def img_to_three_color_map(source_path, target_path):
print
(
target_path
)
print
(
source_path
)
img
=
cv2
.
imread
(
source_path
)
composite
=
coco_demo
.
run_on_opencv_image
(
img
)
composite
,
point_list
=
coco_demo
.
run_on_opencv_image
(
img
)
#print(point_list)
point
=
str
(
point_list
)
point
=
point
.
replace
(
'['
,
''
)
point
=
point
.
replace
(
']'
,
''
)
point
=
point
.
replace
(
"'"
,
""
)
point
=
point
.
replace
(
' '
,
''
)
source
=
source_path
.
split
(
'/'
)[
-
1
]
point
=
point
.
replace
(
','
,
' '
)
point
=
point
.
replace
(
'|'
,
','
)
with
open
(
'/srv/apps/maskrcnn-benchmark/strangecropd/a.txt'
,
'a+'
)
as
f
:
res
=
source
+
' '
+
point
+
'
\n
'
f
.
write
(
res
)
if
composite
is
not
None
:
cv2
.
imwrite
(
target_path
,
composite
)
# cam = cv2.VideoCapture(0)
...
...
demo/work.py
View file @
51025ef9
...
...
@@ -16,21 +16,14 @@ def write_redis(source_path, target_path):
def
main
():
path
=
'/data/images/dataset_0523/'
rs
=
os
.
walk
(
path
)
for
a
,
b
,
files
in
rs
:
if
b
==
[]:
for
file
in
files
[:
5000
]:
dir
=
a
.
replace
(
'dataset_0523'
,
'dataset_0523_first'
)
fold
=
os
.
path
.
exists
(
dir
)
if
not
fold
:
os
.
mkdir
(
dir
)
source_path
=
a
+
file
target_path
=
dir
+
file
print
(
source_path
)
print
(
target_path
)
#write_redis(source_path, target_path)
path
=
'/srv/apps/maskrcnn-benchmark/strangecrop/'
rs
=
os
.
listdir
(
path
)
for
r
in
rs
:
source_file
=
path
+
r
target_file
=
source_file
.
replace
(
'crop'
,
'cropd'
)
write_redis
(
source_file
,
target_file
)
print
(
source_file
,
target_file
)
if
__name__
==
'__main__'
:
...
...
proj/celery.py
View file @
51025ef9
...
...
@@ -3,7 +3,7 @@ from __future__ import absolute_import
from
celery
import
Celery
import
os
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
"
1
"
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
"
3
"
app
=
Celery
(
'proj'
,
include
=
[
'proj.tasks'
])
app
.
config_from_object
(
'proj.config'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment