Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Fix] fix local_visualizer.py: only visualize when there is at least one instance #2231

Conversation

404Vector
Copy link
Contributor

@404Vector 404Vector commented Jan 20, 2023

  • fix [AttributeError: ‘InstanceData’ object has no attribute ‘bboxes_3d’] error

An error occurs when drawing a 3d box on an image to evaluate model performance as shown below.

python tools/test.py configs/smoke/smoke_dla34_dlaneck_gn-all_4xb8-6x_kitti-mono3d.py checkpoints/smoke/smoke_dla34_pytorch_dlaneck_gn-all_8x4_6x_kitti-mono3d_20210929_015553-d46d9bb0.pth --show --show-dir='work_dirs/test' --task='mono_det'

Motivation

I wanted to draw a 3D BBox using tools/test.py.
However, it could not be drawn due to an internal error.
I'll fix the error with this PR.

Modification

file : mmdet3d/visualization/local_visualizer.py

class : Det3DLocalVisualizer Class

method : add_datasample, _draw_instances_3d

Looking at the data_sample object at runtime, it has gt_instances_3d.
But inside gt_instances_3d the data doesn't exist.
Fix the bug by modifying the code as shown below.

  • before
if 'gt_instances_3d' in data_sample:
    gt_data_3d = self._draw_instances_3d(
          data_input, data_sample.gt_instances_3d,
          data_sample.metainfo, vis_task, palette)
  • after
if 'gt_instances_3d' in data_sample:
     if 'bboxes_3d' in data_sample.gt_instances_3d:
          gt_data_3d = self._draw_instances_3d(
               data_input, data_sample.gt_instances_3d,
               data_sample.metainfo, vis_task, palette)

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

fix #2119

 - fix "AttributeError: ‘InstanceData’ object has no attribute ‘bboxes_3d’" error
@CLAassistant
Copy link

CLAassistant commented Jan 20, 2023

CLA assistant check
All committers have signed the CLA.

@404Vector 404Vector changed the title fix local_visualizer.py: modify add_datasample [Fix] fix local_visualizer.py: modify add_datasample Jan 20, 2023
@ZwwWayne ZwwWayne requested a review from ZCMax January 29, 2023 06:42
@ZwwWayne ZwwWayne added this to the 1.1.0rc4 milestone Jan 29, 2023
@Xiangxu-0103
Copy link
Collaborator

Please pull the latest code to fix lint issue and change your base to dev-1.x branch

@404Vector
Copy link
Contributor Author

404Vector commented Feb 6, 2023

@Xiangxu-0103

  • Check for conflicts between the latest version (dev-1.x) and my work
  • Merge the dev-1.x branch into my branch
  • Apply suggested change and Check if the code is working properly
  • Add Code for pred_instances_3d and Check if the code is working properly
  • Pre-commit

@Xiangxu-0103
Copy link
Collaborator

Xiangxu-0103 commented Feb 6, 2023

download
Please change the merged branch to dev-1.x instead of 1.1.

@404Vector 404Vector changed the base branch from 1.1 to dev-1.x February 6, 2023 08:05
@Tai-Wang Tai-Wang changed the title [Fix] fix local_visualizer.py: modify add_datasample [Fix] fix local_visualizer.py: only visualize when there is at least one instance Feb 8, 2023
…pty instance

 - Add exception handling when instances are empty
 - Delete the exception handling previously added to add_datasample
@404Vector 404Vector requested review from ZwwWayne and Xiangxu-0103 and removed request for ZwwWayne February 9, 2023 02:30
@404Vector
Copy link
Contributor Author

@Xiangxu-0103 Please approve the circle ci work flow :)

@codecov
Copy link

codecov bot commented Feb 14, 2023

Codecov Report

Base: 46.39% // Head: 46.39% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (d5d0847) compared to base (377597b).
Patch coverage: 0.00% of modified lines in pull request are covered.

❗ Current head d5d0847 differs from pull request most recent head 3b25986. Consider uploading reports for the commit 3b25986 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           dev-1.x    #2231      +/-   ##
===========================================
- Coverage    46.39%   46.39%   -0.01%     
===========================================
  Files          259      259              
  Lines        21401    21404       +3     
  Branches      3379     3380       +1     
===========================================
  Hits          9930     9930              
- Misses       10827    10829       +2     
- Partials       644      645       +1     
Flag Coverage Δ
unittests 46.39% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmdet3d/visualization/local_visualizer.py 33.90% <0.00%> (-0.36%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jason102811
Copy link

Hi @404Vector !First of all, we want to express our gratitude for your significant PR in the MMDet. Your contribution is highly appreciated, and we are grateful for your efforts in helping improve this open-source project during your personal time. We believe that many developers will benefit from your PR.

We would also like to invite you to join our Special Interest Group (SIG) private channel on Discord, where you can share your experiences, ideas, and build connections with like-minded peers. To join the SIG channel, simply message moderator— OpenMMLab on Discord or briefly share your open-source contributions in the #introductions channel and we will assist you. Look forward to seeing you there! Join us :https://discord.gg/UjgXkPWNqA

If you have WeChat account,welcome to join our community on WeChat. You can add our assistant :openmmlabwx. Please add "mmsig + Github ID" as a remark when adding friends:)
Thank you again for your contribution❤

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants