You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import os
import detectron2.utils.comm as comm
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import get_cfg
from detectron2.data import build_detection_train_loader
from detectron2.engine import DefaultTrainer, default_setup, default_argument_parser, launch
from detectron2.evaluation import COCOEvaluator, verify_results
from detectron2.data.datasets import register_coco_instances
from point_rend import add_pointrend_config
def register_datasets():
Omit
print("Datasets registered!")
class Trainer(DefaultTrainer):
@classmethod
def build_evaluator(cls, cfg, dataset_name, output_folder=None):
if output_folder is None:
output_folder = os.path.join(cfg.OUTPUT_DIR, "inference")
return COCOEvaluator(dataset_name, cfg, True, output_folder)
@classmethod
def build_train_loader(cls, cfg):
return build_detection_train_loader(cfg, mapper=None)
def setup(args):
"""
Create configs and perform basic setups.
"""
cfg = get_cfg()
add_pointrend_config(cfg)
cfg.merge_from_file(args.config_file)
cfg.merge_from_list(args.opts)
cfg.freeze()
default_setup(cfg, args)
cfg.DATASETS.TRAIN = ("LP_train",)
cfg.DATASETS.TEST = ("LP_test",)
cfg.DATALOADER.NUM_WORKERS = 1
cfg.MODEL.WEIGHTS = r"D:\python program\detectron2\projects\PointRend\configs\InstanceSegmentation\pointrend_rcnn_R_50_FPN_3x_coco.yaml"
cfg.SOLVER.IMS_PER_BATCH = 2
cfg.SOLVER.BASE_LR = 0.00025
cfg.SOLVER.MAX_ITER = 100
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 1
cfg.OUTPUT_DIR = r"D:\python program\detectron2\projects\PointRend"
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
return cfg
def main(args):
register_datasets()
cfg = setup(args)
if args.eval_only:
model = Trainer.build_model(cfg)
DetectionCheckpointer(model, save_dir=cfg.OUTPUT_DIR).resume_or_load(cfg.MODEL.WEIGHTS, resume=args.resume)
res = Trainer.test(cfg, model)
if comm.is_main_process():
verify_results(cfg, res)
return res
trainer = Trainer(cfg)
trainer.resume_or_load(resume=args.resume)
trainer.train()
if __name__ == "__main__":
args = default_argument_parser().parse_args()
launch(main, args.num_gpus, args=(args,))
What exact command you run: python train_net.py --config-file configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml
Full logs or other relevant observations:
(detectron_env) D:\python program\detectron2\projects\PointRend>python train_net.py --config-file configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_3x_coco.yaml
Traceback (most recent call last):
File "train_net.py", line 2, in <module>
import detectron2.utils.comm as comm
ModuleNotFoundError: No module named 'detectron2'
Instructions To Reproduce the Issue:
Expected behavior:
Hope the program runs normally
Environment:
The relevant programs within the projects will all report the same error message.Others can operate normally
The text was updated successfully, but these errors were encountered: