facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.54k stars 7.49k forks source link

[Detectron2]I train the model 'FCOS' and after 54999 iter ,the model evaluate on the 'coco_val_2017' can only achieve mAP=0? #5191

Closed FLYDust1101 closed 10 months ago

FLYDust1101 commented 10 months ago

When it train, it run the code run_step() -- class TrainBase When it eval, use detectron2.evaluation.inference_on_dataset

### But why it outputs mAP=0 like: ??? Outputs: [01/07 12:42:58 d2.evaluation.coco_evaluation]: Evaluating predictions with unofficial COCO API... Loading and preparing results... DONE (t=0.14s) creating index... index created! [01/07 12:42:58 d2.evaluation.fast_eval_api]: Evaluate annotation type bbox [01/07 12:43:04 d2.evaluation.fast_eval_api]: COCOeval_opt.evaluate() finished in 5.97 seconds. [01/07 12:43:04 d2.evaluation.fast_eval_api]: Accumulating evaluation results... [01/07 12:43:05 d2.evaluation.fast_eval_api]: COCOeval_opt.accumulate() finished in 0.67 seconds. Average Precision (AP) @[ IoU=0.50:0.95 area= all maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50 area= all maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.75 area= all maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 area= small maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 area=medium maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 area= large maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 area= all maxDets= 1 ] = 0.001 Average Recall (AR) @[ IoU=0.50:0.95 area= all maxDets= 10 ] = 0.001 Average Recall (AR) @[ IoU=0.50:0.95 area= all maxDets=100 ] = 0.001 Average Recall (AR) @[ IoU=0.50:0.95 area= small maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 area=medium maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 area= large maxDets=100 ] = 0.002 [01/07 12:43:05 d2.evaluation.coco_evaluation]: Evaluation results for bbox: AP AP50 AP75 APs APm APl
0.000 0.001 nan 0.000 0.001 0.000
[01/07 12:43:05 d2.evaluation.coco_evaluation]: Some metrics cannot be computed and is shown as NaN. [01/07 12:43:05 d2.evaluation.coco_evaluation]: Per-category bbox AP: category AP category AP category AP
person 0.000 bicycle 0.000 car 0.000
motorcycle 0.000 airplane 0.000 bus 0.000
train 0.000 truck 0.000 boat 0.000
traffic light 0.000 fire hydrant 0.000 stop sign 0.000
parking meter 0.000 bench 0.000 bird 0.000
cat 0.000 dog 0.000 horse 0.000
sheep 0.000 cow 0.000 elephant 0.000
bear 0.000 zebra 0.000 giraffe 0.000
backpack 0.000 umbrella 0.000 handbag 0.000
tie 0.000 suitcase 0.000 frisbee 0.000
skis 0.000 snowboard 0.000 sports ball 0.000
kite 0.000 baseball bat 0.000 baseball glove 0.000
skateboard 0.000 surfboard 0.000 tennis racket 0.000
bottle 0.000 wine glass 0.000 cup 0.000
fork 0.000 knife 0.000 spoon 0.000
bowl 0.000 banana 0.000 apple 0.000
sandwich 0.000 orange 0.000 broccoli 0.000
carrot 0.000 hot dog 0.000 pizza 0.000
donut 0.000 cake 0.000 chair 0.000
couch 0.000 potted plant 0.000 bed 0.019
dining table 0.000 toilet 0.000 tv 0.000
laptop 0.000 mouse 0.000 remote 0.000
keyboard 0.000 cell phone 0.000 microwave 0.000
oven 0.000 toaster 0.000 sink 0.000
refrigerator 0.000 book 0.000 clock 0.000
vase 0.000 scissors 0.000 teddy bear 0.000
hair drier 0.000 toothbrush 0.000

OrderedDict([('bbox', {'AP': 0.00024255127390703898, 'AP50': 0.0005441165354860879, 'AP75': nan, 'APs': 0.0, 'APm': 0.0005503269509548185, 'APl': 0.0004439579840761939, 'AP-person': 0.0, 'AP-bicycle': 0.0, 'AP-car': 0.0, 'AP-motorcycle': 0.0, 'AP-airplane': 0.0, 'AP-bus': 0.0, 'AP-train': 0.0, 'AP-truck': 0.0, 'AP-boat': 0.0, 'AP-traffic light': 0.0, 'AP-fire hydrant': 0.0, 'AP-stop sign': 0.0, 'AP-parking meter': 5.207820307022969e-05, 'AP-bench': 0.0, 'AP-bird': 0.0, 'AP-cat': 0.0, 'AP-dog': 0.0, 'AP-horse': 0.0, 'AP-sheep': 0.0, 'AP-cow': 0.0, 'AP-elephant': 0.0, 'AP-bear': 0.0, 'AP-zebra': 0.0, 'AP-giraffe': 0.0, 'AP-backpack': 0.0, 'AP-umbrella': 0.0, 'AP-handbag': 0.0, 'AP-tie': 0.0, 'AP-suitcase': 0.0, 'AP-frisbee': 0.0, 'AP-skis': 0.0, 'AP-snowboard': 0.0, 'AP-sports ball': 0.0, 'AP-kite': 0.0, 'AP-baseball bat': 0.0, 'AP-baseball glove': 0.0, 'AP-skateboard': 0.0, 'AP-surfboard': 0.0, 'AP-tennis racket': 0.0, 'AP-bottle': 0.0, 'AP-wine glass': 0.0, 'AP-cup': 0.0, 'AP-fork': 0.0, 'AP-knife': 0.0, 'AP-spoon': 0.0, 'AP-bowl': 0.0, 'AP-banana': 0.0, 'AP-apple': 0.0, 'AP-sandwich': 0.0, 'AP-orange': 0.0, 'AP-broccoli': 0.0, 'AP-carrot': 0.0, 'AP-hot dog': 0.0, 'AP-pizza': 0.0, 'AP-donut': 0.0, 'AP-cake': 0.0, 'AP-chair': 0.0, 'AP-couch': 0.0, 'AP-potted plant': 0.0, 'AP-bed': 0.019352023709492887, 'AP-dining table': 0.0, 'AP-toilet': 0.0, 'AP-tv': 0.0, 'AP-laptop': 0.0, 'AP-mouse': 0.0, 'AP-remote': 0.0, 'AP-keyboard': 0.0, 'AP-cell phone': 0.0, 'AP-microwave': 0.0, 'AP-oven': 0.0, 'AP-toaster': 0.0, 'AP-sink': 0.0, 'AP-refrigerator': 0.0, 'AP-book': 0.0, 'AP-clock': 0.0, 'AP-vase': 0.0, 'AP-scissors': 0.0, 'AP-teddy bear': 0.0, 'AP-hair drier': 0.0, 'AP-toothbrush': 0.0})])

Process finished with exit code 0

Configs:

CUDNN_BENCHMARK: false DATALOADER: ASPECT_RATIO_GROUPING: true FILTER_EMPTY_ANNOTATIONS: true NUM_WORKERS: 0 REPEAT_THRESHOLD: 0.0 SAMPLER_TRAIN: TrainingSampler DATASETS: CROSS_DATASET: false PRECOMPUTED_PROPOSAL_TOPK_TEST: 1000 PRECOMPUTED_PROPOSAL_TOPK_TRAIN: 2000 PROPOSAL_FILES_TEST: [] PROPOSAL_FILES_TRAIN: [] TEST:

Codes

from trainer import FCOSTrainer import os from modeling.fcos.FCOS import FCOS from detectron2.layers import ShapeSpec

from detectron2.checkpoint import DetectionCheckpointer from detectron2.engine import default_argument_parser, default_setup, launch from detectron2.config import get_cfg from add_model_config import add_fcos_config from detectron2.engine import DefaultTrainer,DefaultPredictor from detectron2.evaluation import DatasetEvaluators,

from detectron2.evaluation import inference_on_dataset from detectron2.data import build_detection_test_loader, MetadataCatalog from detectron2.data.datasets import register_coco_instances

def setup(args): cfg = get_cfg() add_fcos_config(cfg) # 配置文件1 - 原始定义 cfg.merge_from_file(args.config_file) # 配置文件2 - 覆盖 cfg.merge_from_list(args.opts) cfg.MODEL.WEIGHTS = "D:\lyb\demo1\output_0\model_0029999.pth"

cfg.DATASETS.TEST = (dataset_name,)

cfg.freeze()
default_setup(cfg, args)
return cfg

def main(args): cfg = setup(args) Trainer = DefaultTrainer(cfg)

if args.eval_only:
    model = Trainer.build_model(cfg)

    data_loader = build_detection_test_loader(cfg, cfg.DATASETS.TEST[0])

    print('loading from:{}'.format(cfg.MODEL.WEIGHTS))

    eval_results = inference_on_dataset(
    model,
    data_loader,
    DatasetEvaluators([COCOEvaluator(cfg.DATASETS.TEST[0], ("bbox",), False, output_dir='./1_6_inference/'), ]))

    print(eval_results)
    return eval_results 

return Trainer.train()

if name == "main": args = default_argument_parser().parse_args() print("Command Line Args:", args) launch( main, args.num_gpus, num_machines=args.num_machines, machine_rank=args.machine_rank, dist_url=args.dist_url, args=(args,), )

github-actions[bot] commented 10 months ago

You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template. The following information is missing: "Instructions To Reproduce the Issue and Full Logs"; "Your Environment";

github-actions[bot] commented 10 months ago

Requested information was not provided in 7 days, so we're closing this issue.

Please open new issue if information becomes available. Otherwise, use github discussions for free-form discussions.