question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object are localized but not classified

See original GitHub issue

❓ Questions and Help

I fine-tuned Faster R-CNN with backbone FPN-50 on Cityscapes dataset. Objects can be localized accurately but are always classified incorrectly, such as: all ‘car’ => ‘bus’, ‘bus’ => ‘car’ , ‘person’ => ‘truck’, ‘bicycle’ => ‘motorcycle’, etc. predictions.get_field(“labels”) is always incorrect. I don’t know what’s wrong. Please help me!

aachen_000018_000019_leftimg8bit

aachen_000028_000019_leftimg8bit

I fine-tune the network as follow:

  1. Remove layers having ‘cls_score’ and ‘bbox_pred’, and save model:
model = build_detection_model(cfg)
device = torch.device(cfg.MODEL.DEVICE)
model.to(device)
optimizer = make_optimizer(cfg, model)
scheduler = make_lr_scheduler(cfg, optimizer)
save_to_disk = get_rank() == 0
checkpointer = DetectronCheckpointer(cfg, model, optimizer, scheduler, cfg.OUTPUT_DIR, save_to_disk)
checkpointer.load(cfg.MODEL.WEIGHT, init=True)
checkpointer.save(path_output)

maskrcnn_benchmark/utils/checkpoint.py is modified as:

class Checkpointer(object):
    def load(self, f=None, init=False):
        if self.has_checkpoint():
            # override argument with existing checkpoint
            f = self.get_checkpoint_file()
        if not f:
            # no checkpoint could be found
            self.logger.info("No checkpoint found. Initializing model from scratch")
            return {}
        self.logger.info("Loading checkpoint from {}".format(f))
        checkpoint = self._load_file(f)
        if init:
            checkpoint['model'] = {k.replace('module.', ''): v for k, v in checkpoint['model'].items()
                                    if 'cls_score' not in k and 'bbox_pred' not in k and 'mask_fcn_logits' not in k}
        self._load_model(checkpoint)
        if "optimizer" in checkpoint and self.optimizer:
            self.logger.info("Loading optimizer from {}".format(f))
            self.optimizer.load_state_dict(checkpoint.pop("optimizer"))
        if "scheduler" in checkpoint and self.scheduler:
            self.logger.info("Loading scheduler from {}".format(f))
            self.scheduler.load_state_dict(checkpoint.pop("scheduler"))
  1. Change config file: NUM_CLASSES: 8, for background and 7 object classes
  2. Load model and train as normal. Here is loss: newplot

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sandeep-d-patilcommented, Jun 30, 2020

Hey @luisdecker you can check out my repo, have tried to make a cityscapes dataset, similar to matterport repo. Hope this helps!

1reaction
tuanhanhdmprofcommented, Jul 2, 2019

@tuanhanhdmprof mình đã cố gắng sử dụng file convert này https://github.com/facebookresearch/Detectron/blob/master/tools/convert_cityscapes_to_coco.py nhưng vẫn không thành công. Bạn có thể chỉ rõ cho mình nên sắp xếp thư mục dataset như thế nào được không?

Mình nhầm ý trên. Hướng dẫn để convert nhé:

  1. Download file json của cityscapes về.
  2. Download / pip install cityscapesScripts.
  3. tổ chức thư mục: – root ---- gtFine_trainvaltest ---- Detectron ---- output
  4. run lệnh sau: python ./Detectron/tools/convert_cityscapes_to_coco.py --dataset cityscapes_instance_only --datadir . --outdir ./output/

cái thứ 3 cấu trúc lại thì sửa lại lệnh run trên là ok

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object Localisation without Classification - Cross Validated
I searched a lot for a method to do so, and found resources for achieving localization with classification, but neither do I want...
Read more >
Classification, Localization & Detection - Cogneethi
Given an image with one object, we tell what kind of object it is. This is the case of classification. Localization. Next comes...
Read more >
Object Localization with Classification in Real-Time | by Shobhit
Object detection is more complicated than classification, which can also identify the objects but doesn't indicate where the object is.
Read more >
Localization and Object Detection with Deep Learning
Classification/Recognition: Given an image with an object, find out what that object is. · Localization: Find where the object is and draw a ......
Read more >
5 Significant Object Detection Challenges and Solutions
1. Dual priorities: object classification and localization. The first major complication of object detection is its added goal: not only do ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found