(debayer_op)
| 1482 | |
| 1483 | @params(fn.experimental.debayer, fn.debayer) |
| 1484 | def test_debayer(debayer_op): |
| 1485 | from debayer_test_utils import rgb2bayer, bayer_patterns, blue_position |
| 1486 | |
| 1487 | def debayer_pipline(max_batch_size, inputs, device): |
| 1488 | batches = [list(zip(*batch)) for batch in inputs] |
| 1489 | img_batches = [list(imgs) for imgs, _ in batches] |
| 1490 | blue_positions = [list(positions) for _, positions in batches] |
| 1491 | |
| 1492 | @pipeline_def |
| 1493 | def piepline(): |
| 1494 | bayered = fn.external_source(source=img_batches) |
| 1495 | positions = fn.external_source(source=blue_positions) |
| 1496 | if device == "gpu": |
| 1497 | bayered = bayered.gpu() |
| 1498 | return debayer_op(bayered, blue_position=positions) |
| 1499 | |
| 1500 | return piepline(batch_size=max_batch_size, num_threads=4, device_id=0) |
| 1501 | |
| 1502 | def sample_gen(): |
| 1503 | rng = np.random.default_rng(seed=101) |
| 1504 | j = 0 |
| 1505 | while True: |
| 1506 | pattern = bayer_patterns[j % len(bayer_patterns)] |
| 1507 | h, w = 2 * np.int32(rng.uniform(2, 3, 2)) |
| 1508 | r, g, b = np.full((h, w), j), np.full((h, w), j + 1), np.full((h, w), j + 2) |
| 1509 | rgb = np.uint8(np.stack([r, g, b], axis=2)) |
| 1510 | yield ( |
| 1511 | rgb2bayer(rgb, pattern), |
| 1512 | np.array(blue_position(pattern), dtype=np.int32), |
| 1513 | ) |
| 1514 | j += 1 |
| 1515 | |
| 1516 | sample = sample_gen() |
| 1517 | batches = [ |
| 1518 | [next(sample) for _ in range(5)], |
| 1519 | [next(sample) for _ in range(13)], |
| 1520 | [next(sample) for _ in range(2)], |
| 1521 | ] |
| 1522 | |
| 1523 | check_pipeline(batches, debayer_pipline, devices=["gpu", "cpu"]) |
| 1524 | |
| 1525 | |
| 1526 | @params(fn.experimental.filter, fn.filter) |
nothing calls this directly
no test coverage detected