(out_dict, num_rays_to_visu=10, xlim=(0, 6))
| 649 | |
| 650 | |
| 651 | def plot_samples(out_dict, num_rays_to_visu=10, xlim=(0, 6)): |
| 652 | fig = plt.figure(figsize=plt.figaspect(0.5)) |
| 653 | |
| 654 | ax = plt.subplot(2, 1, 1) |
| 655 | plt.title('sigma ray samples') |
| 656 | |
| 657 | if 'combined' in out_dict: |
| 658 | if isinstance(out_dict['combined']['model_in']['t_intervals'], list): |
| 659 | t_intervals = out_dict['combined']['model_in']['t_intervals'][-1][0, ..., 0] |
| 660 | else: |
| 661 | t_intervals = out_dict['combined']['model_in']['t_intervals'][0, ..., 0] |
| 662 | else: |
| 663 | t_intervals = out_dict['sigma']['model_in']['t_intervals'][0, ..., 0] |
| 664 | |
| 665 | t_transformed = torch.cumsum(t_intervals, dim=-1).cpu().detach() |
| 666 | |
| 667 | num_rays = t_transformed.shape[0] |
| 668 | ts = t_transformed[num_rays//2:num_rays//2+num_rays_to_visu, :-1] |
| 669 | num_samples = ts.shape[1] |
| 670 | idcs = torch.arange(0, num_rays_to_visu).reshape(-1, 1).repeat(1, num_samples).float() |
| 671 | idcs2 = torch.arange(0, num_samples).repeat(num_rays_to_visu).float() |
| 672 | plt.scatter(ts.reshape(-1), idcs.reshape(-1), marker='|', c=idcs2.reshape(-1)/num_samples, cmap='prism') |
| 673 | ax.set_ylabel('ray idx') |
| 674 | ax.set_xlabel('sample position') |
| 675 | ax.set_yticklabels([]) |
| 676 | plt.xlim(xlim) |
| 677 | |
| 678 | ax = plt.subplot(2, 1, 2) |
| 679 | plt.title('rgb ray samples') |
| 680 | t_transformed = torch.cumsum(t_intervals, dim=-1).cpu().detach() # we could have t but it requires many more changes |
| 681 | num_rays = t_transformed.shape[0] |
| 682 | ts = t_transformed[num_rays//2:num_rays//2+num_rays_to_visu, :-1] |
| 683 | num_samples = ts.shape[1] |
| 684 | idcs = torch.arange(0, num_rays_to_visu).reshape(-1, 1).repeat(1, num_samples).float() |
| 685 | idcs2 = torch.arange(0, num_samples).repeat(num_rays_to_visu).float() |
| 686 | plt.scatter(ts.reshape(-1), idcs.reshape(-1), marker='|', c=idcs2.reshape(-1)/num_samples, cmap='prism') |
| 687 | ax.set_ylabel('ray idx') |
| 688 | ax.set_xlabel('sample position') |
| 689 | ax.set_yticklabels([]) |
| 690 | plt.xlim(xlim) |
| 691 | |
| 692 | return fig |
| 693 | |
| 694 | |
| 695 | def process_batch_in_chunks(in_dict, model, max_chunk_size=1024, progress=None): |
no outgoing calls
no test coverage detected