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

Training issues #24

Open
lydcv opened this issue Jan 10, 2025 · 5 comments
Open

Training issues #24

lydcv opened this issue Jan 10, 2025 · 5 comments

Comments

@lydcv
Copy link

lydcv commented Jan 10, 2025

I'm sorry to disturb your rest. Could you please share the calculation code for FLOPS, Param, and FPS used for meta-learning method FPD? I haven't completed it yet, and I hope you can help me despite your busy schedule. Thank you very much!

@wangchen1801
Copy link
Owner

from ptflops import get_model_complexity_info
from thop import profile
for idx, data_batch in enumerate(data_loader):
    macs, params = get_model_complexity_info(model, (1, 3, 800, 1333), as_strings=True,
                                             print_per_layer_stat=False, verbose=True)
    print('{:<30}  {:<8}'.format('Computational complexity: ', macs))
    print('{:<30}  {:<8}'.format('Number of parameters: ', params))

    # flops, params = profile(model.cuda(), inputs=data_batch['img'][0].cuda())
    # print('FLOPs = ' + str(flops / 1000 ** 3) + 'G')
    # print('Params = ' + str(params / 1000 ** 2) + 'M')

you can try 'profile' and 'get_model_complexity_info' to calculate FLOPS and Params.

@lydcv
Copy link
Author

lydcv commented Jan 10, 2025

from ptflops import get_model_complexity_info
from thop import profile
for idx, data_batch in enumerate(data_loader):
    macs, params = get_model_complexity_info(model, (1, 3, 800, 1333), as_strings=True,
                                             print_per_layer_stat=False, verbose=True)
    print('{:<30}  {:<8}'.format('Computational complexity: ', macs))
    print('{:<30}  {:<8}'.format('Number of parameters: ', params))

    # flops, params = profile(model.cuda(), inputs=data_batch['img'][0].cuda())
    # print('FLOPs = ' + str(flops / 1000 ** 3) + 'G')
    # print('Params = ' + str(params / 1000 ** 2) + 'M')

you can try 'profile' and 'get_model_complexity_info' to calculate FLOPS and Params.

May I ask if you would like to directly place it in test. py and select the base training weight of 20000pth or a fine tuned weight such as the 1-shot weight of 800.pth for testing and printing? Thank you again for your help despite your busy schedule, and I wish you a happy new year!!

@wangchen1801
Copy link
Owner

Yes, you can either put it in test.py or manually load an image. Happy new year too!

@lydcv
Copy link
Author

lydcv commented Jan 11, 2025

Yes, you can either put it in test.py or manually load an image. Happy new year too!
I'm sorry, I still got an error. I placed it at the end of test. py, but when executing Python test. py configs/fpd/voc/split1/fpd_r101_c4_2xb4_oc-split1_base training. py work-dirs/split1_base/latest.tpth -- eval mAP, the error still appears. Thank you for taking the time to help again! The error is as follows:
OrderedDict([('AP50', 0.907), ('mAP', 0.9074152708053589)])
Warning: module Bottleneck is treated as a zero-op.
Warning: module ResLayer is treated as a zero-op.
Warning: module ResNetWithMetaConv is treated as a zero-op.
Warning: module Sigmoid is treated as a zero-op.
Warning: module MetaRCNNResLayer is treated as a zero-op.
Warning: module RoIAlign is treated as a zero-op.
Warning: module SingleRoIExtractor is treated as a zero-op.
Warning: module CrossEntropyLoss is treated as a zero-op.
Warning: module SmoothL1Loss is treated as a zero-op.
Warning: module MetaBBoxHead is treated as a zero-op.
Warning: module Embedding is treated as a zero-op.
Warning: module PrototypesDistillation is treated as a zero-op.
Warning: module PrototypesAssignment is treated as a zero-op.
Warning: module L1Loss is treated as a zero-op.
Warning: module RPNHead is treated as a zero-op.
Warning: module FPDRoIHead is treated as a zero-op.
Warning: module FPD is treated as a zero-op.
Warning: module MMDataParallel is treated as a zero-op.
Traceback (most recent call last):
File "test.py", line 265, in
main()
File "test.py", line 255, in main
macs, params = get_model_complexity_info(model, (1, 3, 800, 1333), as_strings=True,
File "/root/miniconda3/lib/python3.8/site-packages/ptflops/flops_counter.py", line 43, in get_model_complexity_info
_ = flops_model(batch)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/mmcv/parallel/data_parallel.py", line 42, in forward
return super().forward(*inputs, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 165, in forward
return self.module(*inputs[0], **kwargs[0])
File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/mmcv/runner/fp16_utils.py", line 98, in new_func
return old_func(*args, **kwargs)
File "/root/autodl-tmp/FPD/fpd/query_support.py", line 179, in forward
return self.forward_train(query_data, support_data, **kwargs)
File "/root/autodl-tmp/FPD/fpd/query_support.py", line 269, in forward_train
query_img = query_data['img']
TypeError: new(): invalid data type 'str'

@lydcv
Copy link
Author

lydcv commented Jan 11, 2025

May I ask if you have added forward_dummy to fpd_detector.py to handle it? Could you share the complete code process? I'm really sorry to bother you all the time. Thank you for taking the time to help me!

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

No branches or pull requests

2 participants