Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Feature]: support image visualization for tensorboard and wandb #15

Merged
merged 3 commits into from
Apr 21, 2022
Merged

[Feature]: support image visualization for tensorboard and wandb #15

merged 3 commits into from
Apr 21, 2022

Conversation

Cathy0908
Copy link
Collaborator

@Cathy0908 Cathy0908 commented Apr 20, 2022

Tensorboard visulization is as follows:

image

Wandb visulization is as follows:

image

The step interval shown in the figure is the number of steps of N epoch, N is the eval intervel.

Usage:

# evaluation
...
eval_config = dict(
    interval=1,
    visualization_config=dict(
        vis_num=10,  # number of images to show
        score_thr=0.5,  # boxes scores below the score_thr will be filtered out 
    ) 
)
...
log_config = dict(
    interval=10,
    hooks=[
        dict(type='TextLoggerHook'),
        dict(type='TensorboardLoggerHookV2'),
        dict(type='WandbLoggerHookV2'),
    ])

@@ -23,4 +23,5 @@
dict(type='CenterCrop', size=224),
dict(type='ToTensor'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Collect', keys=['img', 'gt_labels'])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has nothing to do with this pr, fix previous bug, please refer to: #6

org = (text_baseline + text_size[1],
text_baseline + text_size[1] + cur_height)

# support chinese text
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support chinese font


filename = img_metas[i]['ori_filename']
self.writer.add_image(
f'{vis_key}/{filename}',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add group_name vis_key



def download_font(save_path=None):
url_path = 'http://pai-vision-data-hz.oss-accelerate.aliyuncs.com/EasyCV/pkgs/simhei.ttf'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this font to git and auto package it into our python whl

Copy link
Collaborator Author

@Cathy0908 Cathy0908 Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put simhei.ttf to resource dir, and support package to whl and zip

img, torch.Tensor
), 'Only support np.ndarray and torch.Tensor type!'

filename = img_metas[i]['ori_filename']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is filename sufficient for visualization? img_metas is not straightforward

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add doc, img_metas is optional

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if imag_metas does not exsits in vis_result, line 29 will throw exception

@@ -168,7 +175,8 @@
interval=100,
hooks=[
dict(type='TextLoggerHook'),
dict(type='TensorboardLoggerHook')
dict(type='TensorboardLoggerHookV2'),
# dict(type='WandbLoggerHookV2'),
Copy link
Collaborator

@wenmengzhou wenmengzhou Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wandb config example should be added in another file or using comment format

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wandb initialization config is missing

pil_image = PILImage.fromarray(img, mode='RGB')
filename = img_metas[i].get(
'ori_filename',
'image') if img_metas is not None else 'image'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image_${i}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wenmengzhou wenmengzhou added the enhancement New feature or request label Apr 21, 2022
@Cathy0908 Cathy0908 merged commit 9a3826f into alibaba:master Apr 21, 2022
@wenmengzhou wenmengzhou linked an issue Apr 22, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Framework] Visualization enhancement
2 participants