donahowe/AutoStudio

请问作者,这个报错什么原因怎么解决呢?ImportError: cannot import name '_C' from 'groundingdino'

Closed this issue · 3 comments

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/run.py:32 in │
│ │
│ 29 │
│ 30 from model.unet_2d_condition import UNet2DConditionModel │
│ 31 from model.utils import show_boxes, show_image, get_global_prompt │
│ ❱ 32 from model.autostudio import AUTOSTUDIO, AUTOSTUDIOPlus, AUTOSTUDIOXL, AUTOSTUDIOXLPlus │
│ 33 │
│ 34 from detectSam import EFFICIENT_SAM_MODEL, GROUNDING_DINO_MODEL │
│ 35 │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/model/autostudio.py:16 in │
│ │
│ 13 │
│ 14 from PIL import Image │
│ 15 from typing import List │
│ ❱ 16 from detectSam import process_image │
│ 17 from diffusers.pipelines.controlnet import MultiControlNetModel │
│ 18 from safetensors import safe_open │
│ 19 from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/DETECT_SAM/detectSam.py:22 in │
│ │
│ 19 import supervision as sv │
│ 20 import torch │
│ 21 │
│ ❱ 22 from groundingdino.util.inference import Model, load_image │
│ 23 │
│ 24 #from mmengine.runner import Runner │
│ 25 #from mmengine.config import Config │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/util/inference.py:20 in │
│ │
│ │
│ 17 sys.path.append(f"{ppath}/") │
│ 18 │
│ 19 import groundingdino.datasets.transforms as T │
│ ❱ 20 from groundingdino.models import build_model │
│ 21 from groundingdino.util.misc import clean_state_dict │
│ 22 from groundingdino.util.slconfig import SLConfig │
│ 23 from groundingdino.util.utils import get_phrases_from_posmap │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/models/init.py:8 in │
│ │
│ │
│ 5 # Licensed under the Apache License, Version 2.0 [see LICENSE for details] │
│ 6 # ------------------------------------------------------------------------ │
│ 7 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved │
│ ❱ 8 from .GroundingDINO import build_groundingdino │
│ 9 │
│ 10 │
│ 11 def build_model(args): │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/models/GroundingDINO/init.p │
│ y:15 in │
│ │
│ 12 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. │
│ 13 # ------------------------------------------------------------------------ │
│ 14 │
│ ❱ 15 from .groundingdino import build_groundingdino │
│ 16 │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/models/GroundingDINO/groundingd │
│ ino.py:54 in │
│ │
│ 51 │ generate_masks_with_special_tokens, │
│ 52 │ generate_masks_with_special_tokens_and_transfer_map, │
│ 53 ) │
│ ❱ 54 from .transformer import build_transformer │
│ 55 from .utils import MLP, ContrastiveEmbed, sigmoid_focal_loss │
│ 56 │
│ 57 │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/models/GroundingDINO/transforme │
│ r.py:36 in │
│ │
│ 33 from groundingdino.util.misc import inverse_sigmoid │
│ 34 │
│ 35 from .fuse_modules import BiAttentionBlock │
│ ❱ 36 from .ms_deform_attn import MultiScaleDeformableAttention as MSDeformAttn │
│ 37 from .transformer_vanilla import TransformerEncoderLayer │
│ 38 from .utils import ( │
│ 39 │ MLP, │
│ │
│ /shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/models/GroundingDINO/ms_deform_ │
│ attn.py:28 in │
│ │
│ 25 from torch.autograd.function import once_differentiable │
│ 26 from torch.nn.init import constant_, xavier_uniform_ │
│ 27 │
│ ❱ 28 from groundingdino import _C │
│ 29 try: │
│ 30 │ from groundingdino import _C │
│ 31 except: │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: cannot import name '_C' from 'groundingdino' (/shared/jiayu_ti/git_project/backing_up/AutoStudio/groundingdino/init.py)

这个是groundingdino常见的错误,CSDN上有解决方案

删掉DETECT_SAM\Grounding-DINO目录下的build和dist文件夹和.egg-info,在Grounding-DINO目录下pip install -e .重新编译安装groundingdino 这个模块

好的,谢谢二位,我试试