Comments (5)
To uniformly sample a contour, we assign the vertex number for each segment of the contour.
img_gt_poly = uniformsample(poly, len(poly) * snake_config.gt_poly_num)
tt_idx = np.argmin(np.power(img_gt_poly - ex_pts[0], 2).sum(axis=1))
img_gt_poly = np.roll(img_gt_poly, -tt_idx, axis=0)[::len(poly)]
def uniformsample(pgtnp_px2, newpnum):
pnum, cnum = pgtnp_px2.shape
assert cnum == 2
idxnext_p = (np.arange(pnum, dtype=np.int32) + 1) % pnum
pgtnext_px2 = pgtnp_px2[idxnext_p]
edgelen_p = np.sqrt(np.sum((pgtnext_px2 - pgtnp_px2) ** 2, axis=1))
edgeidxsort_p = np.argsort(edgelen_p)
# two cases
# we need to remove gt points
# we simply remove shortest paths
if pnum > newpnum:
edgeidxkeep_k = edgeidxsort_p[pnum - newpnum:]
edgeidxsort_k = np.sort(edgeidxkeep_k)
pgtnp_kx2 = pgtnp_px2[edgeidxsort_k]
assert pgtnp_kx2.shape[0] == newpnum
return pgtnp_kx2
# we need to add gt points
# we simply add it uniformly
else:
edgenum = np.round(edgelen_p * newpnum / np.sum(edgelen_p)).astype(np.int32)
for i in range(pnum):
if edgenum[i] == 0:
edgenum[i] = 1
# after round, it may has 1 or 2 mismatch
edgenumsum = np.sum(edgenum)
if edgenumsum != newpnum:
if edgenumsum > newpnum:
id = -1
passnum = edgenumsum - newpnum
while passnum > 0:
edgeid = edgeidxsort_p[id]
if edgenum[edgeid] > passnum:
edgenum[edgeid] -= passnum
passnum -= passnum
else:
passnum -= edgenum[edgeid] - 1
edgenum[edgeid] -= edgenum[edgeid] - 1
id -= 1
else:
id = -1
edgeid = edgeidxsort_p[id]
edgenum[edgeid] += newpnum - edgenumsum
assert np.sum(edgenum) == newpnum
psample = []
for i in range(pnum):
pb_1x2 = pgtnp_px2[i:i + 1]
pe_1x2 = pgtnext_px2[i:i + 1]
pnewnum = edgenum[i]
wnp_kx1 = np.arange(edgenum[i], dtype=np.float32).reshape(-1, 1) / edgenum[i]
pmids = pb_1x2 * (1 - wnp_kx1) + pe_1x2 * wnp_kx1
psample.append(pmids)
psamplenp = np.concatenate(psample, axis=0)
return psamplenp
from snake.
Thanks for the prompt reply!
from snake.
@pengsida Hi Sida, do you sample the N=128 points from poly processed on the output of MaskRCNN, which is 28x28x256?
from snake.
I sample the points around the ground truth object contour.
from snake.
I sample the points around the ground truth object contour.
Thanks for your reply.
from snake.
Related Issues (20)
- Code errors and broken links HOT 1
- Mask map HOT 3
- 更换backbone HOT 4
- 修改loss函数 HOT 1
- 对比实验评估问题 HOT 1
- Cityscapes数据集缺失问题
- Cityscapes数据集缺失问题 HOT 2
- “THC/THC.h”: No such file or directory HOT 5
- dla-34改dla60 HOT 1
- RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED HOT 2
- SBD数据集貌似失效了,请问可以更新一下链接嘛! HOT 1
- ex_loss 和py_loss的含义 HOT 1
- 使用自己制作COCO数据集报错的问题 HOT 1
- 如何能够在目标检测的框上面显示类别 HOT 2
- dance这篇论文在snake的基础上改进,修改了损失函数 HOT 1
- 作者您好,关于如何显示测试结果的分类别mAP? HOT 1
- 请问作者每一次迭代的效果图在代码中是怎么实现的 HOT 1
- 损失曲线问题
- Costum dataset
- windows10,python3.7,vs2022构建失败:dcn_v2,extreme_utils,roi_align_layer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snake.