Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pixel_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ def decode_image(pixel_scores, link_scores,
raise ValueError('Unknow decode method:%s'%(config.decode_method))


import pyximport; pyximport.install()
from pixel_link_decode import decode_image_by_join

def min_area_rect(cnt):
Expand Down
33 changes: 33 additions & 0 deletions pixel_link_decode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import numpy as np

def get_neighbours(x, y):
return [(x - 1, y - 1), (x, y - 1), (x + 1, y - 1), \
(x - 1, y), (x + 1, y), \
(x - 1, y + 1), (x, y + 1), (x + 1, y + 1)]

def is_valid_cord(x, y, w, h):
return x >=0 and x < w and y >= 0 and y < h

def decode_image_by_join(pixel_scores, link_scores, pixel_conf_threshold, link_conf_threshold):
pixel_mask = pixel_scores >= pixel_conf_threshold
link_mask = link_scores >= link_conf_threshold
done_mask = np.zeros(pixel_mask.shape, np.bool)
result_mask = np.zeros(pixel_mask.shape, np.int32)
points = list(zip(*np.where(pixel_mask)))
h, w = np.shape(pixel_mask)
group_id = 0
for point in points:
if done_mask[point]:
continue
group_id += 1
group_q = [point]
result_mask[point] = group_id
while len(group_q):
y, x = group_q[-1]
group_q.pop()
if not done_mask[y,x]:
done_mask[y,x], result_mask[y,x] = True, group_id
for n_idx, (nx, ny) in enumerate(get_neighbours(x, y)):
if is_valid_cord(nx, ny, w, h) and pixel_mask[ny, nx] and (link_mask[y, x, n_idx] or link_mask[ny, nx, 7 - n_idx]):
group_q.append((ny, nx))
return result_mask
114 changes: 0 additions & 114 deletions pixel_link_decode.pyx

This file was deleted.

1 change: 0 additions & 1 deletion pixel_link_env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies:
- backports.functools-lru-cache==1.5
- bottle==0.12.13
- cycler==0.10.0
- cython==0.28.2
- enum34==1.1.6
- kiwisolver==1.0.1
- matplotlib==2.2.2
Expand Down