|
42 | 42 | 'roi_perspective_transform',
|
43 | 43 | 'generate_proposal_labels',
|
44 | 44 | 'generate_proposals',
|
45 |
| -] |
46 |
| - |
47 |
| -__auto__ = [ |
48 | 45 | 'iou_similarity',
|
49 | 46 | 'box_coder',
|
50 | 47 | 'polygon_box_transform',
|
51 | 48 | ]
|
52 | 49 |
|
53 |
| -__all__ += __auto__ |
54 |
| - |
55 |
| -for _OP in set(__auto__): |
56 |
| - globals()[_OP] = generate_layer_fn(_OP) |
57 |
| - |
58 | 50 |
|
59 | 51 | def rpn_target_assign(bbox_pred,
|
60 | 52 | cls_logits,
|
@@ -308,6 +300,101 @@ class number, M is number of bounding boxes. For each category
|
308 | 300 | return nmsed_outs
|
309 | 301 |
|
310 | 302 |
|
| 303 | +@templatedoc() |
| 304 | +def iou_similarity(x, y, name=None): |
| 305 | + """ |
| 306 | + ${comment} |
| 307 | +
|
| 308 | + Args: |
| 309 | + x(${x_type}): ${x_comment} |
| 310 | + y(${y_type}): ${y_comment} |
| 311 | +
|
| 312 | + Returns: |
| 313 | + out(${out_type}): ${out_comment} |
| 314 | + """ |
| 315 | + helper = LayerHelper("iou_similarity", **locals()) |
| 316 | + if name is None: |
| 317 | + out = helper.create_tmp_variable(dtype=x.dtype) |
| 318 | + else: |
| 319 | + out = helper.create_variable( |
| 320 | + name=name, dtype=x.dtype, persistable=False) |
| 321 | + |
| 322 | + helper.append_op( |
| 323 | + type="iou_similarity", |
| 324 | + inputs={"X": x, |
| 325 | + "Y": y}, |
| 326 | + attrs={}, |
| 327 | + outputs={"Out": out}) |
| 328 | + return out |
| 329 | + |
| 330 | + |
| 331 | +@templatedoc() |
| 332 | +def box_coder(prior_box, |
| 333 | + prior_box_var, |
| 334 | + target_box, |
| 335 | + code_type="encode_center_size", |
| 336 | + box_normalized=True, |
| 337 | + name=None): |
| 338 | + """ |
| 339 | + ${comment} |
| 340 | +
|
| 341 | + Args: |
| 342 | + prior_box(${prior_box_type}): ${prior_box_comment} |
| 343 | + prior_box_var(${prior_box_var_type}): ${prior_box_var_comment} |
| 344 | + target_box(${target_box_type}): ${target_box_comment} |
| 345 | + code_type(${code_type_type}): ${code_type_comment} |
| 346 | + box_normalized(${box_normalized_type}): ${box_normalized_comment} |
| 347 | +
|
| 348 | + Returns: |
| 349 | + output_box(${output_box_type}): ${output_box_comment} |
| 350 | + """ |
| 351 | + helper = LayerHelper("box_coder", **locals()) |
| 352 | + |
| 353 | + if name is None: |
| 354 | + output_box = helper.create_tmp_variable(dtype=prior_box.dtype) |
| 355 | + else: |
| 356 | + output_box = helper.create_variable( |
| 357 | + name=name, dtype=prior_box.dtype, persistable=False) |
| 358 | + |
| 359 | + helper.append_op( |
| 360 | + type="box_coder", |
| 361 | + inputs={ |
| 362 | + "PriorBox": prior_box, |
| 363 | + "PriorBoxVar": prior_box_var, |
| 364 | + "TargetBox": target_box |
| 365 | + }, |
| 366 | + attrs={"code_type": code_type, |
| 367 | + "box_normalized": box_normalized}, |
| 368 | + outputs={"OutputBox": output_box}) |
| 369 | + return output_box |
| 370 | + |
| 371 | + |
| 372 | +@templatedoc() |
| 373 | +def polygon_box_transform(input, name=None): |
| 374 | + """ |
| 375 | + ${comment} |
| 376 | +
|
| 377 | + Args: |
| 378 | + input(${input_type}): ${input_comment} |
| 379 | +
|
| 380 | + Returns: |
| 381 | + output(${output_type}): ${output_comment} |
| 382 | + """ |
| 383 | + helper = LayerHelper("polygon_box_transform", **locals()) |
| 384 | + if name is None: |
| 385 | + output = helper.create_tmp_variable(dtype=input.dtype) |
| 386 | + else: |
| 387 | + output = helper.create_variable( |
| 388 | + name=name, dtype=prior_box.input, persistable=False) |
| 389 | + |
| 390 | + helper.append_op( |
| 391 | + type="polygon_box_transform", |
| 392 | + inputs={"Input": input}, |
| 393 | + attrs={}, |
| 394 | + outputs={"Output": output}) |
| 395 | + return output |
| 396 | + |
| 397 | + |
311 | 398 | @templatedoc()
|
312 | 399 | def detection_map(detect_res,
|
313 | 400 | label,
|
|
0 commit comments