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.12k stars 7.42k forks source link

No object named 'DensePoseROIHeads' found in 'ROI_HEADS' registry! #5170

Open FurkanGozukara opened 10 months ago

FurkanGozukara commented 10 months ago

I have installed and working. But there is literally 0 documentation and examples.

in the same folder densepose_rcnn_R_101_FPN_DL_s1x.yaml located in the same folder Base-DensePose-RCNN-FPN.yaml located in the same folder model_final_844d15.pkl located in the same folder R-101.pkl located

my aim is giving a video and generating DensePose video like below

https://github.com/facebookresearch/detectron2/assets/19240467/6feb80f7-9513-4e53-be12-5cd218f0c1c5

my script is as below

import cv2
import torch
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
from detectron2.utils.visualizer import Visualizer
from detectron2.data import MetadataCatalog
from config import add_densepose_config
from detectron2.modeling import ROI_HEADS_REGISTRY

def setup_cfg():
    cfg = get_cfg()
    add_densepose_config(cfg)
    cfg.merge_from_file("densepose_rcnn_R_101_FPN_DL_s1x.yaml")
    cfg.MODEL.WEIGHTS = "model_final_844d15.pkl"
    cfg.MODEL.DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
    return cfg

def process_video(input_video_path, output_video_path, cfg):
    video = cv2.VideoCapture(input_video_path)
    width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
    fps = video.get(cv2.CAP_PROP_FPS)

    output_video = cv2.VideoWriter(output_video_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (width, height))

    predictor = DefaultPredictor(cfg)

    while True:
        ret, frame = video.read()
        if not ret:
            break

        outputs = predictor(frame)
        v = Visualizer(frame[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
        output = v.draw_instance_predictions(outputs["instances"].to("cpu"))
        output_frame = output.get_image()[:, :, ::-1]

        output_video.write(output_frame)

    video.release()
    output_video.release()

cfg = setup_cfg()

process_video("ex1.mp4", "pose1.mp4", cfg)

the error i get is like below

Traceback (most recent call last):
  File "G:\magic_animate\compose_densepose\pose_maker.py", line 46, in <module>
    process_video("ex1.mp4", "pose1.mp4", cfg)
  File "G:\magic_animate\compose_densepose\pose_maker.py", line 27, in process_video
    predictor = DefaultPredictor(cfg)
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\detectron2\engine\defaults.py", line 282, in __init__
    self.model = build_model(self.cfg)
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\detectron2\modeling\meta_arch\build.py", line 22, in build_model
    model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\detectron2\config\config.py", line 189, in wrapped
    explicit_args = _get_args_from_config(from_config_func, *args, **kwargs)
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\detectron2\config\config.py", line 245, in _get_args_from_config
    ret = from_config_func(*args, **kwargs)
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\detectron2\modeling\meta_arch\rcnn.py", line 77, in from_config
    "roi_heads": build_roi_heads(cfg, backbone.output_shape()),
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\detectron2\modeling\roi_heads\roi_heads.py", line 43, in build_roi_heads
    return ROI_HEADS_REGISTRY.get(name)(cfg, input_shape)
  File "G:\magic_animate\compose_densepose\detectron2\venv\lib\site-packages\fvcore\common\registry.py", line 71, in get
    raise KeyError(
KeyError: "No object named 'DensePoseROIHeads' found in 'ROI_HEADS' registry!"
Press any key to continue . . .
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";

FurkanGozukara commented 10 months ago

I hope you can help me and I am so sorry for pinging you.

@ppwwyyxx @vkhalidov @MarcSzafraniec @wat3rBro @alexander-kirillov @lyttonhao @wenliangzhao2018 @bowenc0221 @patricklabatut @chenbohua3 @shashimalcse @DomiSchmauser @TysonLinger @cool-xuan @rbgirshick @SuperIRabbit @MrParosk @angelayi @HannaMao

malleng commented 10 months ago

you can follow this tutorial : https://github.com/sangyun884/HR-VITON/issues/45

Hope this helps :)

FurkanGozukara commented 10 months ago

you can follow this tutorial : https://github.com/sangyun884/HR-VITON/issues/45

Hope this helps :)

it returns nothing i mean the url

malleng commented 10 months ago

you can follow this tutorial : https://github.com/sangyun884/HR-VITON/issues/45 Hope this helps :)

it returns nothing i mean the url

Yes sorry, is it better ? :

https://github.com/sangyun884/HR-VITON/issues/45