Closed yypsWinnie closed 8 months ago
Hi~It's seems like you are using MMSegmentation1.x. Please install same version of MMSegmentation based on project environment file official-CMID/Pretrain/environment.yml
.
Hi~I would like to ask you how to use the trained encoder in your code for change detection in downstream tasks.
Hi~ @ayh456. You can simply download the backbone you want to use and load the pre-trained backbone in your own change detection training framework. Otherwise, if you'd like to use the BiT you can also download the pre-trained backbone and follow the instruction mentioned there.
Thanks for your interest!
Hi~ @ayh456. You can simply download the backbone you want to use and load the pre-trained backbone in your own change detection training framework. Otherwise, if you'd like to use the BiT you can also download the pre-trained backbone and follow the instruction mentioned there.
Thanks for your interest!
thank you
Hi~I ran into this problem when running your code,Traceback (most recent call last):
File "D:\PycharmProject\official-CMID-main\extract.py", line 30, in
Would like to ask how to solve it, thank you very much
Hi~I ran into this problem when running your code,Traceback (most recent call last): File "D:\PycharmProject\official-CMID-main\extract.py", line 30, in main() File "D:\PycharmProject\official-CMID-main\extract.py", line 21, in main checkpoint = torch.load(checkpoint_path, map_location="cpu")["model"] File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\serialization.py", line 1014, in load return _load(opened_zipfile, File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\serialization.py", line 1422, in _load result = unpickler.load() File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\serialization.py", line 1415, in find_class return super().find_class(mod_name, name) ModuleNotFoundError: No module named 'Exploring'
Would like to ask how to solve it, thank you very much
This issue has been solved Thank you very much
Hi~ @ayh456. You can choose one of the following methods to fix your problem:
extract.py
:
import sys
sys.path.append("YourOwnPath/Pretrain")
Please make sure replace the path YourOwnPath/Pretrain
to the abosolute path of Pretrain in your system.
Hi~ @ayh456. You can choose one of the following methods to fix your problem:
- Directly download the extracted backbone from the main page (download from the backbone only button), which don't need to extract the backbone and can be used by downstream tasks.
- Add the following line to the start of
extract.py
:import sys sys.path.append("YourOwnPath/Pretrain")
Please make sure replace the path
YourOwnPath/Pretrain
to the abosolute path of Pretrain in your system.
thank you
Hi~I ran into this problem when running your code,Traceback (most recent call last): File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 208, in main(config) File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 127, in main data_loader_train = build_loader(config, mode="pretrain") File "D:\PycharmProject\official-CMID-main\Pretrain\Dataset\build_loader.py", line 101, in build_loader return build_loader_pretrain(config) File "D:\PycharmProject\official-CMID-main\Pretrain\Dataset\build_loader.py", line 27, in build_loader_pretrain dataset = ImageFolder(config.data_path, transform) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torchvision\datasets\folder.py", line 309, in init super().init( File "D:\APP\anaconda\envs\dsp\lib\site-packages\torchvision\datasets\folder.py", line 144, in init classes, class_to_idx = self.find_classes(self.root) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torchvision\datasets\folder.py", line 218, in find_classes return find_classes(directory) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torchvision\datasets\folder.py", line 42, in find_classes raise FileNotFoundError(f"Couldn't find any class folder in {directory}.") FileNotFoundError: Couldn't find any class folder in E:\madata\Million-AID\test\test.zip\Image. Would like to ask how to solve it, thank you very much
Hi~ @KINOPIO-1P .
It seems like your input folder path is not correct. Please make sure unzip all the MillionAID text file and place them in the same folder (for example yourOwnPath/MillionAid/test
). And the run the pretrain file with --data-path yourOwnPath/MillionAID
.
The folder structure of MillionAID
may be like:
MillionAID
|
|_test
|
|_img1.jpg
....
Thanks for your interest for our work.
thank you
Can you help me solve this problem?thank you!
Traceback (most recent call last):
File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 208, in
Hi~ @ayh456.
The PlotTensor
is used for visualizing make reconstruction results and I plot four images each time for simplicity.
You can fix this by adjusting batch size to the one that can be devided by 4 or adjust the nrow
in function lot_reconstructio
and plot_residual_reconstruction
at Pretrain\model\pretrain_model.py
.
Or you can simply comment out the following two lines of code in Pretrain\main_pretrain.py
:
if is_main_process():
hooks.extend([PlotSaver(save_interval=1)])
Hi~ @ayh456. The
PlotTensor
is used for visualizing make reconstruction results and I plot four images each time for simplicity. You can fix this by adjusting batch size to the one that can be devided by 4 or adjust thenrow
in functionlot_reconstructio
andplot_residual_reconstruction
atPretrain\model\pretrain_model.py
.Or you can simply comment out the following two lines of code in
Pretrain\main_pretrain.py
:if is_main_process(): hooks.extend([PlotSaver(save_interval=1)])
thank you
Can you help me solve this problem?thank you!
Traceback (most recent call last):
File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 208, in
Hello, I would like to ask why the generated change detection result plot is not black and white? Or is there a problem with my code running
Hi~ @ayh456. What implementation code you used to visualize the change detection result? From your question above, I think it's reconstruction result not change detection result.
Hi~ @ayh456. What implementation code you used to visualize the change detection result? From your question above, I think it's reconstruction result not change detection result.
The code you provided
Hi~ @ayh456. What implementation code you used to visualize the change detection result? From your question above, I think it's reconstruction result not change detection result. You can help me see this problem scolding Traceback (most recent call last): File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 208, in main(config) File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 166, in main trainer.train(load_checkpoint=config.resume_path) File "D:\PycharmProject\official-CMID-main\Pretrain\Exploring\trainer.py", line 407, in train self._train_one_epoch() File "D:\PycharmProject\official-CMID-main\Pretrain\Exploring\trainer.py", line 391, in _train_one_epoch self.train_on_iter() File "D:\PycharmProject\official-CMID-main\Pretrain\Exploring\trainer.py", line 372, in train_on_iter self.loss_dict = self.model(batch, self.device) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, **kwargs) File "D:\PycharmProject\official-CMID-main\Pretrain\models\pretrain_model.py", line 399, in forward backbone_dict = super(MoCoBased, self).mim_forward(imgBatch, device) File "D:\PycharmProject\official-CMID-main\Pretrain\models\pretrain_model.py", line 286, in mim_forward top_k_max = min(1, logits.size(1)) IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
Hi~ @ayh456 I think you are wrong for using pretrain code for change detection. Please follow the change detection instruction under folder ChangeDetection
to used pretrained CMID for change detection. The visualize code should be visualization.py.
Hi~ @ayh456 I think you are wrong for using pretrain code for change detection. Please follow the change detection instruction under folder
ChangeDetection
to used pretrained CMID for change detection. The visualize code should be visualization.py.
I want to try to use the CMID pre-training file, and I run into this problem。
Can you help me solve this problem encountered by the pre-training code of the CMID model? Thank you very much! Traceback (most recent call last): File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 208, in main(config) File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 166, in main trainer.train(load_checkpoint=config.resume_path) File "D:\PycharmProject\official-CMID-main\Pretrain\Exploring\trainer.py", line 407, in train self._train_one_epoch() File "D:\PycharmProject\official-CMID-main\Pretrain\Exploring\trainer.py", line 391, in _train_one_epoch self.train_on_iter() File "D:\PycharmProject\official-CMID-main\Pretrain\Exploring\trainer.py", line 372, in train_on_iter self.loss_dict = self.model(batch, self.device) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "D:\APP\anaconda\envs\dsp\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, **kwargs) File "D:\PycharmProject\official-CMID-main\Pretrain\models\pretrain_model.py", line 399, in forward backbone_dict = super(MoCoBased, self).mim_forward(imgBatch, device) File "D:\PycharmProject\official-CMID-main\Pretrain\models\pretrain_model.py", line 286, in mim_forward top_k_max = min(1, logits.size(1)) IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
Hi~ @ayh456. If you want to pretrained on MillionAID. Please use /Pretrain/pt_swin_config.yaml
or /Pretrain/pt_config.yaml
, where set the ft_classify
to false
. Otherwise, if you want to monitor classification result during pretraining, please use the dataset that contain class label (MillionAID not contain the result), write correct dataset loading code, and change the corresponding attributes (i.e. ft_classify
, num_classes
and dataset
).
Hi~ @ayh456. If you want to pretrained on MillionAID. Please use
/Pretrain/pt_swin_config.yaml
or/Pretrain/pt_config.yaml
, where set theft_classify
tofalse
. Otherwise, if you want to monitor classification result during pretraining, please use the dataset that contain class label (MillionAID not contain the result), write correct dataset loading code, and change the corresponding attributes (i.e.ft_classify
,num_classes
anddataset
).
thank you
Hello, I changed it the way you said and still reported the same error
Traceback (most recent call last):
File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 209, in
进程已结束,退出代码1
Could you give more information about your running script? I can't understand your error if you follow the correct instruction.
I added parameters to the code main_pretrain to run. parser.add_argument('--batch-size', default='1', type=int, help="batch size for single GPU") parser.add_argument('--lr', default=0.001, type=int, help="number of total epochs to run") parser.add_argument('--min-lr', default=0.00001, type=int, help="number of total epochs to run") parser.add_argument('--transform_type',default='parallel', type=str, help="number of total epochs to run") parser.add_argument('--mask_patch_size', default=32, type=int, help="number of total epochs to run") parser.add_argument('--mask_stage', default=0, type=int, help="number of total epochs to run") parser.add_argument('--mask_color', default='mean', type=str, help="number of total epochs to run") parser.add_argument('--segmentation', default='False', type=str, help="number of total epochs to run") parser.add_argument('--size', default=[224, 224], type=int, help="number of total epochs to run") parser.add_argument('--mask_ratio', default=0.6, type=int, help="number of total epochs to run") parser.add_argument('--dataset', default='madata', type=str, help="number of total epochs to run") parser.add_argument('--backbone', default='resnet50', type=str, help="number of total epochs to run") parser.add_argument('--data-path',default=r'E:\madata\Million-AID\test\test.zip', type=str, help='path to dataset') parser.add_argument('--eval-data-path', default='none',type=str, help='path to evaluate dataset') parser.add_argument('--workers', type=int, default=8, help="workers of dataloader") parser.add_argument('--auto_resume', action="store_true", help='resume from checkpoint') parser.add_argument("--resume_path", type=str, default=None, help="resume checkpoint path") parser.add_argument('--accumulation-steps', type=int, default=1, help="gradient accumulation steps") parser.add_argument('--use-checkpoint', action='store_true', help="whether to use gradient checkpointing to save memory") parser.add_argument('--enable_amp', type=str2bool, default=True, help='mixed precision') parser.add_argument('--output', default='output', type=str, metavar='PATH', help='root of output folder, the full path is
# wandb
parser.add_argument("--wandb", type=str2bool, default=False, help="wandb logger")
parser.add_argument("--entity", type=str, default="pumpkinn", help="wandb entity")
parser.add_argument("--project", type=str, default="MaskIndexNet", help="wandb project")
parser.add_argument("--out_stride", type=int, default=32, help="wandb name")
parser.add_argument("--residual", type=str, default='False', help="warmup epoch")
parser.add_argument("--out_stage", type=int, default=4, help="warmup epoch")
parser.add_argument("--loss_weight", type=int, default=1.0, help="warmup epoch")
parser.add_argument("--reduction", type=str, default='none', help="warmup epoch")
parser.add_argument("--activate", type=str, default='sigmoid', help="warmup epoch")
parser.add_argument("--alpha", type=int, default=0.2, help="warmup epoch")
parser.add_argument("--focal_gamma", type=int, default=1.0, help="warmup epoch")
parser.add_argument("--fft_weight", type=int, default=1.0, help="warmup epoch")
parser.add_argument("--fft_focal", type=str, default='True', help="warmup epoch")
parser.add_argument("--fft_unmask_weight", type=int, default=0.001, help="warmup epoch")
parser.add_argument("--fft_unmask_replace", type=str, default='mixed', help="warmup epoch")
parser.add_argument("--encoder_in_channels", type=int, default=3, help="warmup epoch")
parser.add_argument("--num_classes", type=int, default=6, help="warmup epoch")
parser.add_argument("--in_chans", type=int, default=3, help="warmup epoch")
parser.add_argument("--nproc_per_node", type=int, default=4, help="warmup epoch")
parser.add_argument("--base_momentum", type=int, default=0.996, help="warmup epoch")
parser.add_argument("--final_momentum", type=int, default=1.0, help="warmup epoch")
parser.add_argument("--temperature", type=int, default=0.2, help="warmup epoch")
parser.add_argument("--queue_size", type=int, default=65536, help="warmup epoch")
parser.add_argument("--num_matches", type=int, default=20, help="warmup epoch")
parser.add_argument("--global_branch", type=str, default='True', help="warmup epoch")
parser.add_argument("--hidden_dim", type=int, default=2048, help="warmup epoch")
parser.add_argument("--out_dim", type=int, default=256, help="warmup epoch")
parser.add_argument("--use_bn", type=str, default='True', help="warmup epoch")
parser.add_argument("--unmask_weight", type=int, default=0., help="warmup epoch")
parser.add_argument("--class_feat_size", type=str, default=2048, help="warmup epoch")
parser.add_argument("--wd", type=int, default=0.02, help="warmup epoch")
parser.add_argument("--name", type=str, default='cosine', help="warmup epoch")
parser.add_argument("--warmup_factor", type=int, default=0.01, help="warmup epoch")
parser.add_argument("--warmup_method", type=str, default='linear', help="warmup epoch")
parser.add_argument("--num_layers", type=int, default=3, help="warmup epoch")
parser.add_argument("--warmup_epochs", type=int, default=10, help="warmup epoch")
parser.add_argument("--optimizer", type=str, default='adan', help="warmup epoch")
parser.add_argument("--bottleneck_dim", type=int, default=256, help="warmup epoch")
parser.add_argument("--center_momentum", type=int, default=0.9, help="warmup epoch")
parser.add_argument("--warmup_branch_temp", type=int, default=0.04, help="warmup epoch")
parser.add_argument("--online_temp", type=int, default=0.1, help="warmup epoch")
parser.add_argument("--epochs", type=int, default=400, help="warmup epoch")
parser.add_argument("--model_warmup_epoch", type=int, default=-1, help="warmup epoch")
parser.add_argument("--branch_temp", type=int, default=0.07, help="warmup epoch")
parser.add_argument("--warmup_branch_temp_epochs", type=int, default=50, help="warmup epoch")
# HardWare
parser.add_argument("--accelerator", default="gpu", type=str, choices=["cpu", "gpu", "mps"], help="accelerator")
# distributed training
parser.add_argument("--local_rank", default=1, type=int, help="rank for distribute traning")
parser.add_argument("--knn_eval", type=bool, default=False, help="If true, using knn evaluation")
What command line you use to run the code?
Run on pycharm.
Please add correct command line parameters, such as -c ./pt_config.yaml
. pt_config.yaml
should be correct path of pt_config.yaml
.
thank you!!!
My command line: -c ./pt_config.yaml --batch-size 1 --data-path E:\madata\Million-AID\test\test.zip --eval-data-path None --workers 8 --accelerator gpu --output Pretrain/output --enable_amp True
Encountered this error:
Traceback (most recent call last):
File "D:\PycharmProject\official-CMID-main\Pretrain\main_pretrain.py", line 222, in
Hi~ @ayh456. Please ensure that the batch size is greater than or equal to 2 and is a power of 2.
Hi~ @ayh456. Please ensure that the batch size is greater than or equal to 2 and is a power of 2.
Thank you
Hello, I try to follow your guidance, use the ' conda env create-n CMID-f Pretrain / environment.yml ' command to install the environment, but may be because I use the Linux system, get the error information like 'cannot find backcall=0.2.0=pyh9f0ad1d_0'.
After that, I deleted '=pyh9f0ad1d_0' based on the information I found, and again got some information that the package could not find. I think it is also because the Linux system is inconsistent with you. I got your python = 3.9, pytorch = 1.12.0 and other information from Pretrain / environment.yml, and then manually installed some important packages and replaced the corresponding dataset and config folder according to the steps. But I still get the following error information :
Traceback (most recent call last):
File "tools/train.py", line 17, in
I 'm not sure because there are still some packages that are not installed correctly, but I can 't install each package manually, and I don 't know that you are not convenient to use requirements.txt to give your complete list of dependencies, so I can try to complete all the packages.
Thanks very much !
Hi~@yypsWinnie .Thanks for your interest.
I am totally sorry for that. The "Albu" is a self-implemented function that used for a competition and is not related to this project.
I forgot to delete this function from __init__.py
. You can simply delete importing this function from __init__.py
.
I also fix this mistake in updated fiel __init__.py
and you can try this new file.
As for the envirnoment, I have no access to exact same environment currently. But I think it's just necessary to install same version of following pacakages with this projcet and other pacakages are not related for correct re-implementation, which you can install your own version according to your system:
Closed as long periods of inactivity, feel free to reopen if there is any problem.
I clone mmsegmentatio and your code, and followed you description of "please replace the files of the same name under mmseg/datasets/pipelines with the file under this folder.
please replace the configuration of Potsdam dataset in mmseg/datasets/potsdam.py with this file."
But when I run the program I got information: Traceback (most recent call last): File "tools/train.py", line 104, in
main()
File "tools/train.py", line 93, in main
runner = Runner.from_cfg(cfg)
File "/home/tyust/program/anaconda3/envs/cmid/lib/python3.8/site-packages/mmengine/runner/runner.py", line 445, in from_cfg
runner = cls(
File "/home/tyust/program/anaconda3/envs/cmid/lib/python3.8/site-packages/mmengine/runner/runner.py", line 355, in init
self.setup_env(env_cfg)
File "/home/tyust/program/anaconda3/envs/cmid/lib/python3.8/site-packages/mmengine/runner/runner.py", line 649, in setup_env
if env_cfg.get('cudnn_benchmark'):
AttributeError: 'NoneType' object has no attribute 'get'
May I ask for some help? What else did you modify the code, please?