text_plain_output_1.png
from mmdet.apis import init_detector, inference_detector

import mmcv

import torch

CONFIG_FILE = './config.py'
CHECKPOINT_PATH = './model.pth'
TEST_IMG_DIR = '../input/global-wheat-detection/test'

import torch
device = 'cuda:0' if torch.cuda.is_available() else 'cpu'

config = mmcv.Config.fromfile(CONFIG_FILE)
config.model.pretrained = None
config.model.neck.rfp_backbone.pretrained = None
if False:
    img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
    config.data.test.pipeline = [dict(type='LoadImageFromFile'), dict(type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[dict(type='Resize', keep_ratio=True), dict(type='RandomFlip'), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img'])])]
model = init_detector(config, CHECKPOINT_PATH, device=device)
model.eval()