묻고 답해요
130만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
CityscapeDataset으로 변경 시 오류
선생님 안녕하세요 저는 현재 cityscape dataset을 바탕으로 kaggle mask_rcnn_nucleus 코드를 활용하여 segmentation을 해보려고 하고 있습니다.차량으로 활영한 스트릿뷰에서 나무와 도로를 분리해내어 온도 차이를 보고자 해당 작업을 진행 중인데요,이에 cityscape에 맞는 config 파일과 pretrained model, Cityscapedataset을 활용하려고 하고 있는데, 기존 Nucleusdataset을 Cityscapedataset으로 대체해서 코드를 돌리니 config와 계속 충돌이 있어 train을 할수가 없어 어느 부분을 수정해야할지 모르겠어서 질문드립니다.활용한 config, checkpoint 파일# config_file (/content/mmdetection/configs/cityscapes/mask_rcnn_r50_fpn_1x_cityscapes.py 활용) mask_rcnn_r50_fpn_1x_cityscapes.py # checkpoint_file (cityscape웹에서 다운로드) mask_rcnn_r50_fpn_1x_cityscapes_20201211_133733-d2858245.pth https://download.openmmlab.com/mmdetection/v2.0/cityscapes/mask_rcnn_r50_fpn_1x_cityscapes/mask_rcnn_r50_fpn_1x_cityscapes_20201211_133733-d2858245.pth1차 수정한 dataset 코드# 기존 dataset 코드 from mmdet.datasets.builder import DATASETS from mmdet.datasets.coco import CocoDataset @DATASETS.register_module(force=True) class NucleusDataset(CocoDataset): CLASSES = ['nucleus'] # 변경한 dataset 코드 # Copyright (c) OpenMMLab. All rights reserved. # Modified from https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/datasets/cityscapes.py # noqa # and https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/evaluation/evalInstanceLevelSemanticLabeling.py # noqa from mmdet.datasets.builder import DATASETS from mmdet.datasets.coco import CocoDataset from typing import List @DATASETS.register_module() class Cityscape_Dataset_2(CocoDataset): """Dataset for Cityscapes.""" METAINFO = { 'classes': ('road', 'vegetation', 'sidewalk', 'car', 'building', 'person', 'sky', 'bicycle'), 'palette': [(128,64,128), (107,142,35), (152,251,152), (0,0,142), (70,70,70), (255,0,0), (70,130,180), (119,11,32)] } def filter_data(self) -> List[dict]: """Filter annotations according to filter_cfg. Returns: List[dict]: Filtered results. """ if self.test_mode: return self.data_list if self.filter_cfg is None: return self.data_list filter_empty_gt = self.filter_cfg.get('filter_empty_gt', False) min_size = self.filter_cfg.get('min_size', 0) # obtain images that contain annotation ids_with_ann = set(data_info['img_id'] for data_info in self.data_list) # obtain images that contain annotations of the required categories ids_in_cat = set() for i, class_id in enumerate(self.cat_ids): ids_in_cat |= set(self.cat_img_map[class_id]) # merge the image id sets of the two conditions and use the merged set # to filter out images if self.filter_empty_gt=True ids_in_cat &= ids_with_ann valid_data_infos = [] for i, data_info in enumerate(self.data_list): img_id = data_info['img_id'] width = data_info['width'] height = data_info['height'] all_is_crowd = all([ instance['ignore_flag'] == 1 for instance in data_info['instances'] ]) if filter_empty_gt and (img_id not in ids_in_cat or all_is_crowd): continue if min(width, height) >= min_size: valid_data_infos.append(data_info) return valid_data_infos1차 수정한 코드로 시도한 train 시 오류from mmdet.datasets import build_dataset from mmdet.models import build_detector from mmdet.apis import train_detector # train, valid 용 Dataset 생성. datasets_train = [build_dataset(cfg.data.train)] datasets_val = [build_dataset(cfg.data.val)] --------- TypeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/mmcv/utils/registry.py in build_from_cfg(cfg, registry, default_args) 68 try: ---> 69 return obj_cls(**args) 70 except Exception as e: TypeError: CustomDataset.__init__() got an unexpected keyword argument 'times' During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) 2 frames /usr/local/lib/python3.10/dist-packages/mmcv/utils/registry.py in build_from_cfg(cfg, registry, default_args) 70 except Exception as e: 71 # Normal TypeError does not print class name. ---> 72 raise type(e)(f'{obj_cls.__name__}: {e}') 73 74 TypeError: Cityscape_Dataset_2: CustomDataset.__init__() got an unexpected keyword argument 'times'2차 수정한 코드 (chatGPT의 도움)도 또 다른 오류 뜸@DATASETS.register_module() class Cityscape_Dataset_times(CocoDataset): """Dataset for Cityscapes.""" METAINFO = { 'classes': ('road', 'vegetation', 'sidewalk', 'car', 'building', 'person', 'sky', 'bicycle'), 'palette': [(128,64,128), (107,142,35), (152,251,152), (0,0,142), (70,70,70), (255,0,0), (70,130,180), (119,11,32)] } def __init__(self, *args, times=1, **kwargs): self.times = times super().__init__(*args, **kwargs) def __getitem__(self, idx): # Get the real index by considering the 'times' argument. idx = idx % len(self.data_list) return super().__getitem__(idx) def __len__(self): # The length is the original length times the 'times' argument. return len(self.data_list) * self.times ..이하 동일from mmdet.datasets import build_dataset from mmdet.models import build_detector from mmdet.apis import train_detector # train, valid 용 Dataset 생성. datasets_train = [build_dataset(cfg.data.train)] datasets_val = [build_dataset(cfg.data.val)] --------- TypeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/mmcv/utils/registry.py in build_from_cfg(cfg, registry, default_args) 68 try: ---> 69 return obj_cls(**args) 70 except Exception as e: 3 frames TypeError: CustomDataset.__init__() got an unexpected keyword argument 'dataset' During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/mmcv/utils/registry.py in build_from_cfg(cfg, registry, default_args) 70 except Exception as e: 71 # Normal TypeError does not print class name. ---> 72 raise type(e)(f'{obj_cls.__name__}: {e}') 73 74 TypeError: Cityscape_Dataset_times: CustomDataset.__init__() got an unexpected keyword argument 'dataset'dataset 코드 자체를 전반적으로 수정해야하는 걸까요 아니면 config 파일을 수정해야하는 건지 알 수 있을까요?아니면 cocodataset의 class를 'road'와 'vegetation'으로 두는 방식으로 가능할까요? (cocodataset에는 도로나 나무를 분류하는 카테고리가 딱히 없어 보여서 가능한지 모르겠어서 cityscapedataset 코드를 따로 들고 온거긴 합니다.)졸업이 달려 있는 과제이다보니 마음이 급해지는데 너무 막막해서 도움을 청합니다. 감사합니다.
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
mask_rcnn활용, 데이터 coco 포맷 변환 오류
선생님 안녕하세요 저는 현재 cityscape dataset을 바탕으로 kaggle mask_rcnn_nucleus 코드를 활용하여 segmentation을 해보려고 하고 있습니다.그에 따라 cityscape 데이터를 nulceus 데이터와 동일한 구조의 디렉토리로 정리하였는데요,이를 coco 포맷으로 변환하려고 하니, 아래 오류가 떠서 문의드립니다.파일 경로는 모두 맞게 입력한 것 같은데, 이미지를 못 읽고 있는 것 같습니다.. 'convert_nucleus_to_coco' 함수를 수정하거나 하지 않았는데 왜 이미지를 못읽는 걸까요?(파일 경로)(오류 메세지)convert_nucleus_to_coco('/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/03_masks/aachen', train_ids, '/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/coco_output/train_coco.json') convert_nucleus_to_coco('/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/03_masks/aachen', val_ids, '/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/coco_output/val_coco.json') _____아래 오류 메세지_____ /content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/03_masks/aachen/aachen_000033_000019_gtFine_color/image/aachen_000033_000019_gtFine_color.png --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-63-d95f91ecbcb7> in <cell line: 1>() ----> 1 convert_nucleus_to_coco('/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/03_masks/aachen', train_ids, '/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/coco_output/train_coco.json') 2 convert_nucleus_to_coco('/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/03_masks/aachen', val_ids, '/content/drive/MyDrive/vision/DLCV_New-main/kaggle/train_data_jskim/coco_output/val_coco.json') <ipython-input-61-6f0ad3172ae3> in convert_nucleus_to_coco(data_root_dir, image_ids, out_file) 15 16 print(image_path) ---> 17 height, width = cv2.imread(image_path).shape[0:2] 18 # 개별 image의 dict 정보 생성 19 image_info = dict(file_name=file_name, AttributeError: 'NoneType' object has no attribute 'shape'
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
Graph execution error: 에러
선생님 안녕하세요. 다른 데이터셋으로 alexnet 모델훈련 후 test데이터 셋으로 성능 평가 중 해당에러가 발생하는데 버전문제일까요? 캐글노트북에서 진행하고 있습니다.UnknownError: Graph execution error:
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
kenel_size부분 질문이요!
input_tensor = Input(shape = (IMAGE_SIZE, IMAGE_SIZE, 3)) x = Conv2D(filters = 32, kernel_size = (3, 3), padding = 'same', activation = 'relu', kernel_initializer = 'he_normal')(input_tensor)이 부분에서 입력데이터가 3차원으로 들어오잖아요.저번 강의에서 개별 커널의 차원은 3차원이라고 하셨던거 같은데,그럼 이 코드에선 한개의 커널이 rgb, 총 3개의 채널을 가진 (3 x 3 x 3)가 되는 것인가요?위에 전제가 맞다면, 2번째 줄 kernel_size가 (3, 3)인 이유는 케라스 내부에서 알아서 3개의 채널을 만들어주기 때문인가요??
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
섹션3-RCNN의 이해 02-> F.E에서 IoU 0.5이하로 fine tuning 했는데 SVM에서 IoU 0.3이하로 다시 fine tuning이 필요한가요?
안녕하세요-섹션 3 RCNN의 이해 02 강의에서 강의노트 중RCNN Training - Classification 제목의 강의안에서 질문드립니다. F.E에서 Ground Truth와 SS Predicted된 영역 IOU가 0.5 이상인 경우만 해당 클래스로, 나머지는 back ground로 fine-tuning했는데 SVM Classifier에서 Ground Truth로만 학습하되 0.3 IOU이하는 Background로 설정하는 방식을 병행하는 이유가 있는지 궁금합니다! 처음부터 F.E에서 IOU를 0.3으로 설정하는 방법도 있었을텐데.. 2단계로 나눠서 순차적으로 IOU를 낮추는 게 어떤 차이가 있는지 궁금합니다!F.E에서 IOU가 0.5 이상인 이미지만 filtering했는데 SVM에서 0.3 이하인 image가 남아 있을 수 있는 건 지, 제가 이해를 잘 못한 건지도 여쭤봅니다!
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
안녕하세요 교수님 model.fit()부분 batch_size관련해서 질문있습니다.
앞에서 mini-batch유형때 전체 학습 데이터의 순차적인 mini_batch가 딥러닝 프레임워크에 주로 사용한다고 말씀하셨지만 헷갈려서 질문드립니다!여기서 batch_size = 32라고 되어있는데, 이것은 전체 학습 데이터의 순차적인 mini_batch라고 생각하면 될까요?그래서 epoch1번당 batch_size * 1875 = 60000이 되는것을 알수가 있는거같아서요 혹시 맞을까요?
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
코드부분 질문있습니다.
show_images함수에서 22 * 6크기의 사진이 들어가고 행의 크기 : 1, 열의 크기 : 8로 각각의 axs(이미지)를 ncols만큼 출력하는것은 알겠습니다.근데 axs[i].set_title(class_names[labels[i]]) 부분이 이해가 되지 않습니다.train_images랑 train_labels를 정확하게 매핑시켜주신거라고 생각하면 될까요?제가 번호로된 MNIST를 해봐서 헷갈려서 질문드립니다.감사합니다
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
back propagation의 weight를 뒤에서부터 업데이트 하는 공식?은 없나요?
안녕하세요~! 좋은 강의 정말 감사드립니다...!!강의와 강의 질문중 대답해주신걸 바탕으로 이리저리 고민해봣는데backpropagation은 뒤에서부터 weight를 순차적으로 업데이트(gradient descent 알고리즘을 이용해서) 한다고 설명 되어 있는데...현재까지 강의에서는 체인룰에 좀 집중이 되어있는것 같고 최종 미분하는 것이 입력층에서 제일 가까운 weight로 보여집니다 그럼 한가지 궁금한것이체인룰을 실제로 사용할때 출력층과 제일 가까운 weight를 gradient descent를 이용해서 업데이트(앞쪽 강의의 단일퍼셉트론에서 한것과 같이) 한 다음 그업데이트 된 값에 대해서 다시 체인룰을 적용하는 것인가요!?다시한번 좋은강의 감사드립니다 성생님!^^
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
squeeze() 부분 질문입니다
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 강의 내용을 질문할 경우 몇분 몇초의 내용에 대한 것인지 반드시 기재 부탁드립니다. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.train_labels = train_labels.squeeze() test_labels = test_labels.squeeze()이 부분에서 np.reshape(-1)형식으로 차원을 변경해도 상관이 없나요??
-
해결됨[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
mmcv 설치 오류
안녕하세요, 선생님kaggle에서 mm_mask_rcnn_train_nucleus.ipynb 시도하려고 하니,버전 충돌의 문제인지 아래와 같이 계속 오류가 발생해서 코드를 실행하지 못하고 있습니다. 버전 문제라는 답변을 참고하여 torch버전을 낮춰서 다운로드 받아도 동일한 현상이 반복되어서, 어떻게 하면 될지 문의드립니다..오류 메시지입니다.No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda' /usr/local/lib/python3.10/dist-packages/mmcv/__init__.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details. warnings.warn( --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-1-43071be0880a> in <cell line: 2>() 1 # 런타임->런타임 다시 시작 후 아래 수행. ----> 2 from mmdet.apis import init_detector, inference_detector 3 import mmcv /usr/local/lib/python3.10/dist-packages/mmdet/__init__.py in <module> 1 # Copyright (c) OpenMMLab. All rights reserved. 2 import mmcv ----> 3 import mmengine 4 from mmengine.utils import digit_version 5 ModuleNotFoundError: No module named 'mmengine' --------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below. ---------------------------------------------------------------------------
-
해결됨딥러닝 CNN 완벽 가이드 - Fundamental 편
back propagation 관해 질문있습니다.
안녕하세요 교수님개념이 헷갈리는거 같아서 확인차 질문글에 남깁니다!퍼셉트론과 심층망에서 경사하강법을 통해 weight값을 갱신하는데 퍼셉트론은 hidden layer가 없어 손실함수에서의 parameter값의 편미분을 쉽게 할수있지만,hidden layer가 있는 심층망에서는 parameter에 대한 미분이 쉽지 않아, chain rule을 이용한 backpropagation으로 각 layer마다 전해지는 weight값의 편미분 값을 경사하강법 공식에 대입하여 weight값을 update하는게 맞을까요??제가 남들보다 이해력이 좋지않아서 죄송합니다.. ㅎㅎ..
-
해결됨딥러닝 CNN 완벽 가이드 - Fundamental 편
안녕하세요 교수님 GD랑 미니배치 질문있습니다.
GD는 만약 features들의 값이 매우 많아진다면 weighted sum과 activation function을 거치면서 예측값이 나오는데 굉장히 오래걸릴거같습니다.반면 미니배치는 전체 features들의 값을 일정하게 분할하여 계산의 효율성을 증가시키고 메모리 효율성을 높이는데에 있다고 생각합니다.그래서 미니배치가 더욱 더 딥러닝 FrameWork에 채택되는것이 맞을까요??
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
회귀개요와 RSE,MSE 강좌에서 질문있습니다.
Y = W1*X1 + W0를 2차원 좌표상에서 나타냈을때, 예측함수에 실제값을 더하면 실제함수가 나온다고 하셨는데 혹시 왜그런지 알수있을까요?만약 2개의 ERROR값이 Y = W1*X + W0를 중심으로 대칭이동을 하게되면 ERROR값은 0이 나온다고 생각합니다. 답변 부탁드립니다 !
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
plt.plot부분 질문이요!!
plt.plot(history.history['accuracy'], label='train')plt.plot(history.history['val_accuracy'], label='valid')plt.legend()부분에서 x축은 epochs의 수이고 y축이 정확도인거죠??plt.plot에서 파라미터가 history.history['accuracy']만 있어서 헷갈리네요 ㅠㅠplt.plot()메소드에 파라미터로 x축과 y축 둘 다 넣어줘야 되는거 아닌가요???
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
Mask RCNN에서 백그라운드 클래스의 지정 유무
안녕하세요 권철민 선생님 선생님 강의로 많은 도움을 받고 있습니다항상 감사드립니다 오늘은 질문이 있어서 글을 올립니다 Mask RCNN에서 세그멘테이션을 할때 선생님 코드를 보면 인식하고 싶은object수 만큼만 클래스를 잡아주시던데 백그라운드는 따로 클래스로 지정할 필요가 없나요? 어떤 자료들을 보면 클래스 수가 object수+1이라면서 0번째 클래스를 background로 설정하던데요 VOC dataset 으로 실습하실때도클래스 수는 20으로 설정하셔서요 저는 제가 인식하고 싶은 물체가 5개인데백그라운드도 클래스로 넣어야하는건가라는 생각이 들었습니다class MyDataset(CocoDataset): CLASSES = ('Object01', 'Object02', 'Object03', 'Object04', 'Object05' )cfg.model.roi_head.bbox_head.num_classes = 5 cfg.model.roi_head.mask_head.num_classes = 5 백그라운드까지 넣으면 이렇게 6으로 설정하는걸까요?class MyDataset(CocoDataset): CLASSES = ('background', 'Object01', 'Object02', 'Object03', 'Object04', 'Object05' )cfg.model.roi_head.bbox_head.num_classes = 6 cfg.model.roi_head.mask_head.num_classes = 6
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
import boston set 질문
안녕하세요 이전에 질문드렸던 내용과 중복 되지만 문의드립니다.첨부된 사진과 같이 버전이 이전으로 downgrade하였지만 kaggle 에서 restart를 하여도 여전히 막혀있습니다. 해당 내용 확인 가능하실까요?
-
해결됨딥러닝 CNN 완벽 가이드 - Fundamental 편
안녕하세요 교수님
혹시 vscode를 사용해도 될까요?만약 kaggle을 사용해야한다면 jupyternotebook을 깔아야하나요?
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
Mask RCNN 성능지표
안녕하세요, 강사님!Mask RCNN 성능지표 관련해서 질문이 있습니다. 보통 classification 논문에서는 성능지표를 confusion matrix, accuracy, precision, recall, f1 score로 많이 쓰던데 semantic segmentation 논문에서는 mAP, mIoU, pixel accuracy를 많이 쓰나요? 논문마다 쓰는 지표가 다른 것 같아서 보편적으로 쓰는 성능 지표가 궁금합니다. 강의에서는 segmentation 성능지표 코드가 없어서 detection 강의 쪽 코드를 보면서 조합해보고 있는데 커스텀 데이터셋을 config나 registry에 등록해주는 과정이 필요한가요?
-
미해결딥러닝 CNN 완벽 가이드 - Fundamental 편
새로운 데이터셋에 훈련된 가중치 적용
선생님 안녕하세요. 항상 좋은 강의 잘 듣고 있습니다.두가지 질문이 있습니다.선생님께서 18:21에 좋은 성능을 보여준 이유로 imagenet의 가중치를 사용해서라고 말씀 하셨는데, imagenet의 훈련된 가중치는 애초에 cat and dog와 완전히 다른(imagenet에 많은 강아지와 고양이 이미지가 있다고 하더라도) 데이터로 만들어진 결과인데, cat and dog 데이터 셋에 적용해도 높은 정확도가 나오는 이유가 궁금합니다.그리고, 개인적으로 인도 새 25종을 분류하는 모델을 만들고 있는데그렇다면 강의와 같이 imagenet의 가중치를 가져와서 훈련하는 것이 아무것도 없는? 가중치로 훈련하는 것보다 좋은 성능 만들어 낼까요?
-
미해결[개정판] 딥러닝 컴퓨터 비전 완벽 가이드
maskRCNN dataset class 할당 문제
안녕하세요 선생님외부 데이터를 가지고 교안 코드를 돌려보는 중인데요 데이터를 자꾸 background로 잡아버려서 학습이 불가합니다... 클래스 개수는 하나이고, coco json 파일에 할당도 아주 잘 되었는데 사진과 같이 모듈에서 배경으로 분류를 해 버립니다..ㅠㅠ 이런 경우 어떻게 해결해야 할런지요