diff --git a/minigpt4/configs/datasets/mvtec/default.yaml b/minigpt4/configs/datasets/mvtec/default.yaml index 2fbb16b..68c63a5 100755 --- a/minigpt4/configs/datasets/mvtec/default.yaml +++ b/minigpt4/configs/datasets/mvtec/default.yaml @@ -3,4 +3,4 @@ datasets: data_type: images build_info: image_path: ./MVTEC_det/images - ann_path: ./MVTEC_det/mvtech_ad_data_for_regression.json + ann_path: ./MVTEC_det/train_data.json diff --git a/minigpt4/datasets/datasets/mvtec_dataset.py b/minigpt4/datasets/datasets/mvtec_dataset.py index 2586232..287f09b 100644 --- a/minigpt4/datasets/datasets/mvtec_dataset.py +++ b/minigpt4/datasets/datasets/mvtec_dataset.py @@ -29,15 +29,17 @@ class MVTecDataset(Dataset): def __getitem__(self, index): info = self.ann[index] gt_bbox = info["bbox"] + ans_cls = info["class"] image_path = os.path.join(self.vis_root, info['image_path']) image = Image.open(image_path).convert("RGB") image = self.vis_processor(image) - input = "detect defect or non-defect and return the bounding box" + input = "detect a defect or not-defect object and return the bounding boxes and its label. If not, bound around the object." - ans_cls = "defect" if info["is_broken"] == True else "non-defect" - answer = f"{ans_cls}<{gt_bbox[0]}><{gt_bbox[1]}><{gt_bbox[2]}><{gt_bbox[3]}>" + ans_defect = "defect" if info["is_broken"] == True else "non-defect" + ans_para = f"

{ans_cls}-{ans_defect}

" + answer = f"{ans_para}<{gt_bbox[0]}> <{gt_bbox[1]}><{gt_bbox[2]}><{gt_bbox[3]}>" instruction = random.choice(self.instruction_pool).format(input) instruction = " {} ".format(instruction) diff --git a/train_configs/minigptv2_finetune_mvtec.yaml b/train_configs/minigptv2_finetune_mvtec.yaml index 83cab0c..2a1c09d 100644 --- a/train_configs/minigptv2_finetune_mvtec.yaml +++ b/train_configs/minigptv2_finetune_mvtec.yaml @@ -32,10 +32,10 @@ run: warmup_lr: 1e-6 weight_decay: 0.05 - max_epoch: 10 + max_epoch: 5 num_workers: 6 warmup_steps: 1000 - iters_per_epoch: 1000 + iters_per_epoch: 2000 seed: 42 output_dir: "mvtec_outputs" @@ -51,5 +51,5 @@ run: dist_url: "env://" distributed: True - wandb_log: True + wandb_log: False job_name: minigptv2_finetune