Closed Keiku closed 2 years ago
I may have misused demo instead of a bug. I check https://github.com/open-mmlab/mmdetection/issues/1405 .
I'm sorry. solved.
I'm sorry. solved.
Hi! Were you able to train QueryInst with COCO dataset successfully? If yes, please let me know.
@invincible-28
I executed the following command to save the image. I think that there is no problem with the same command in QueryInst.
python demo/image_demo.py data/tiny_coco/val2017/000000580410.jpg work_dirs/demo/000000580410.jpg configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py checkpoints/mask_rcnn_r50_fpn_1x_coco_20200205-d4b0c5d6.pth --device cuda
You can save the image by adding model.show_result(args.img, result, out_file=args.out_file)
to image_demo.py
. The following image_demo.py
has been modified with version of mmdetection-2.18.1. Not the latest version.
# Copyright (c) OpenMMLab. All rights reserved.
import asyncio
from argparse import ArgumentParser
from mmdet.apis import (async_inference_detector, inference_detector,
init_detector, show_result_pyplot)
def parse_args():
parser = ArgumentParser()
parser.add_argument('img', help='Image file')
parser.add_argument('out_file', help='Output Image file')
parser.add_argument('config', help='Config file')
parser.add_argument('checkpoint', help='Checkpoint file')
parser.add_argument(
'--device', default='cuda:0', help='Device used for inference')
parser.add_argument(
'--score-thr', type=float, default=0.3, help='bbox score threshold')
parser.add_argument(
'--async-test',
action='store_true',
help='whether to set async options for async inference.')
args = parser.parse_args()
return args
def main(args):
# build the model from a config file and a checkpoint file
model = init_detector(args.config, args.checkpoint, device=args.device)
# test a single image
result = inference_detector(model, args.img)
# show the results
show_result_pyplot(model, args.img, result, score_thr=args.score_thr)
model.show_result(args.img, result, out_file=args.out_file)
async def async_main(args):
# build the model from a config file and a checkpoint file
model = init_detector(args.config, args.checkpoint, device=args.device)
# test a single image
tasks = asyncio.create_task(async_inference_detector(model, args.img))
result = await asyncio.gather(tasks)
# show the results
show_result_pyplot(model, args.img, result[0], score_thr=args.score_thr)
if __name__ == '__main__':
args = parse_args()
if args.async_test:
asyncio.run(async_main(args))
else:
main(args)
Hi, Thanks for the quick reply.
But I want to train the network with this command: python tools/train.py configs/queryinst/queryinst_r50_fpn_1x_coco.py
I am facing a lot of issues even after setting up the environment correctly. So, just wanted to know if someone else has already tried to train QueryInst on COCO from scratch.
In my environment, QueryInst was able to train and infer without any problems. Check if there is any problem in building the environment.
okay great to know.
I followed these steps to setup the environment: • conda create -n e7 • conda activate e7 • conda install python=3.7 • source ../Add_to_Environment_Variables.sh • conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=11.0 -c pytorch • pip install mmcv-full==1.3.9 -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html • git clone https://github.com/NVIDIA/apex.git • pip install -r requirements.txt • export CUDA_HOME=/usr/local/cuda-11.0 • pip install -v --no-cache-dir --global-option="--cuda_ext" pytorch-extension • pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./ • cd QueryInst/ • python setup.py develop • mkdir data && cd data • ln -s /home/soumya_pf_pt/documents/coco coco • python tools/train.py configs/queryinst/queryinst_r50_fpn_1x_coco.py
Now I get this error when I try to train:
2022-03-31 11:27:51,839 - mmdet - INFO - workflow: [('train', 1)], max: 12 epochs
Traceback (most recent call last):
File "tools/train.py", line 187, in
In cuda 10.2, I am running the following command.
pip install -U pip
pip install ipdb
pip install mmcv-full==1.3.17 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.10.0/index.html
pip3 install torch torchvision
pip install mmdet==2.18.1
pip install scipy
pip install seaborn
pip install tensorboard
pip install jupyter notebook jupytext
In cuda 11.3, I am running the following command.
pip install -U pip
pip install ipdb
pip install mmcv-full==1.4.7 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10.0/index.html
pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html
pip install mmdet==2.22.0
pip install scipy
pip install seaborn
pip install tensorboard
pip install jupyter notebook jupytext
@invincible-28 The version of mmcv-full may be out of date.
okay, I will try to run with mmcv-full==1.4.7 and check.
I was able to start training the network with my previous setup of the environment. (mmcv-full==1.3.9) But, it is interrupted after the completion of every epoch. Did you also face a similar issue?
@invincible-28 QueryInst was released in mmdetection v2.18.0. For mmdetection v2.18.0, mmcv-full is supported in 1.3.17 or later.
Prerequisites — MMDetection 2.23.0 documentation https://mmdetection.readthedocs.io/en/latest/get_started.html
@Keiku Thank you very much for pointing it out. I am able to train QueryInst with COCO now!
@invincible-28 That's good. Which version did you use after all?
I used mmcv-full==1.3.17
@Keiku Hey! Have you trained QueryInst with custom dataset? If yes, could you please share which version of mmcv-full did you use?
Because, when I tried training on my custom data, I get this error: 'Ground Truth Not Found!'
@invincible-28
Here are the steps to apply a simple custom dataset.
dataset_type = 'CocoDataset'
# Define a classes
classes = ('class1', 'class2', '...', 'class_4', )
data_root = 'data/your_dataset/'
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
type='CocoDataset',
# Add a custom class definition
classes=classes,
ann_file='data/your_dataset/annotations/your_dataset.json',
img_prefix='data/your_dataset/images/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(
type='Collect',
keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks'])
]),
QueryInst takes a lot of time, so let's practice with Mask R-CNN first.
Yes, I did follow all these steps. I referred to this tutorial: https://mmdetection.readthedocs.io/en/latest/2_new_data_model.html
I was able to fix that error. https://github.com/open-mmlab/mmdetection/issues/7863#issue-1218544240
Hi @Keiku I am training this network with a very small custom dataset, so wanted to use data augmentation to increase the size of the dataset. I see that it is already been implemented here: /home/soumya_pf_pt/anaconda3/envs/env_greenai/QueryInst/mmdet/datasets/pipelines/transforms.py. Is that correct what I have analysed or am I missing something? This network in itself is implementing various data augmentation techniques using the albumentations library. Is it?
@invincible-28 Does "small" mean dataset size? Or is it image size? If it is dataset size, I think that there is not much change even if data augmentation is done. If it is an image size, I think that data augmentation that increases the resolution is good.
My recommendation is the strong_baselines strategy. The following will be helpful.
New, improved Detectron2 Mask R-CNN baselines https://ai.facebook.com/blog/advancing-computer-vision-research-with-new-detectron2-mask-r-cnn-baselines/
@Keiku By 'small', I mean the dataset size. So, my question is: This network, queryinst in itself is implementing various data augmentation techniques using the albumentations library. Is it?
@invincible-28 queryinst is loading '../_base_/datasets/coco_instance.py'
, so it doesn't use albumations.
@Keiku queryinst has 6 configuration files with test time augmentation. One of them is:
(From line 9 to 14)
@invincible-28 I'm not using hustvl/QueryInst
so I'm not sure. Ask hustvl directly.
The following is train_pipeline, so it's not a test time augmentation.
dict(
type='Resize',
img_scale=[(1333, value) for value in min_values],
multiscale_mode='value',
keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
okay. Did you encounter this error anytime?
_cv2.error: OpenCV(4.5.5) /io/opencv/modules/core/src/copy.cpp:1026: error: (-215:Assertion failed) top >= 0 && bottom >= 0 && left >= 0 && right >= 0 && _src.dims() <= 2 in function 'copyMakeBorder'_
Describe the bug A clear and concise description of what the bug is.
I ran
demo/image_demo.py
with QueryInst, but nothing is output.Reproduction
I set the dataset to tiny coco and used the officially distributed pretrained model.
tiny coco for coco verification.
Environment
python mmdet/utils/collect_env.py
to collect necessary environment information and paste it here.$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.)I am experimenting in the following repository. Keiku/QueryInst-Examples: Some examples on QueryInst
Error traceback If applicable, paste the error trackback here.
Bug fix If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!