yangxue0827 / RotationDetection

This is a tensorflow-based rotation detection benchmark, also called AlphaRotate.
https://rotationdetection.readthedocs.io/
Apache License 2.0
1.07k stars 181 forks source link

"ValueError: too many values to unpack" RotationDetection/alpharotate/libs/models/detectors/scrdet/build_whole_network.py 147Line #102

Closed sangheonEN closed 2 years ago

sangheonEN commented 2 years ago

Problem path: RotationDetection/alpharotate/libs/models/detectors/scrdet/build_whole_network.py

147 Line. feature, pa_mask = self.build_backbone(input_img_batch)

Since only one variable is returned, why store it in two variables?

It is error that "ValueError: too many values to unpack"

what is pa_mask parameter's mean and rule?

yangxue0827 commented 2 years ago

https://github.com/yangxue0827/RotationDetection/blob/a2d50f4a92bbc29b074f6205d439a761f661ce8d/configs/DOTA/scrdet/cfgs_res50_dota_v1.py#L28-L29

https://github.com/yangxue0827/RotationDetection/blob/a2d50f4a92bbc29b074f6205d439a761f661ce8d/alpharotate/libs/models/backbones/build_backbone_p2top6.py#L28-L29

https://github.com/yangxue0827/RotationDetection/blob/a2d50f4a92bbc29b074f6205d439a761f661ce8d/alpharotate/libs/models/necks/scrdet_neck.py#L161-L164

https://github.com/yangxue0827/RotationDetection/blob/a2d50f4a92bbc29b074f6205d439a761f661ce8d/alpharotate/libs/models/backbones/build_backbone_p2top6.py#L74

https://github.com/yangxue0827/RotationDetection/blob/a2d50f4a92bbc29b074f6205d439a761f661ce8d/alpharotate/libs/models/detectors/scrdet/build_whole_network.py#L147

yangxue0827 commented 2 years ago

It seems that there is no problem, you can compare it with the above.

sangheonEN commented 2 years ago

Thanks you. and one more question.

There is no background label in the dataset I have, but when adding DATASET information in label_dict.py, can I do it in the form below?

Can it be executed even if there is no label at the 0th index?

"back_ground = 0"

image

When I run it, draw_box_in_img.py throws an error txt = self.label_name_map[label] + ':' + str(round(score, 2)) KeyError: 5 .

yangxue0827 commented 2 years ago

"back_ground = 0" is required

sangheonEN commented 2 years ago

If there is no background label in the annotation data, can it not be executed?

yangxue0827 commented 2 years ago

I am not sure.

sangheonEN commented 2 years ago

I get the same error even after adding.

yangxue0827 commented 2 years ago

Check your DTASET_NAME, and make sure the code is looking for this name_label_map.

yangxue0827 commented 2 years ago

May be there is another dataset name startwith LEE before this one.

sangheonEN commented 2 years ago

Even though I set DATASET_NAME = "LEE" in cfgs.py, it is strange; Where can I find the data set to start with?

And don't you load the input data with the data converted to tfrecord?

sangheonEN commented 2 years ago

Total Error comment below:

Traceback (most recent call last): File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.UnknownError: KeyError: 5 Traceback (most recent call last):

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 249, in draw_boxes_with_label_and_scores self.draw_label_with_scores(draw_obj, box, a_label, a_score, color='White')

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 163, in draw_label_with_scores txt = self.label_name_map[label] + ':' + str(round(score, 2))

KeyError: 5

 [[{{node tower_0/PyFunc_1}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 164, in trainer.main() File "train.py", line 159, in main self.log_printer(retinanet, optimizer, global_step, tower_grads, total_loss_dict, num_gpu, graph) File "../../tools/train_base.py", line 252, in logprinter , global_stepnp, summary_str = sess.run([train_op, global_step, summary_op]) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.UnknownError: KeyError: 5 Traceback (most recent call last):

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 249, in draw_boxes_with_label_and_scores self.draw_label_with_scores(draw_obj, box, a_label, a_score, color='White')

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 163, in draw_label_with_scores txt = self.label_name_map[label] + ':' + str(round(score, 2))

KeyError: 5

 [[node tower_0/PyFunc_1 (defined at /home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/show_box_in_tensor.py:66) ]]

Caused by op 'tower_0/PyFunc_1', defined at: File "train.py", line 164, in trainer.main() File "train.py", line 126, in main method=0) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/show_box_in_tensor.py", line 66, in draw_boxes_with_categories Tout=[tf.uint8]) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func return func(*args, *kwargs) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 468, in py_func func=func, inp=inp, Tout=Tout, stateful=stateful, eager=False, name=name) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 282, in _internal_py_func input=inp, token=token, Tout=Tout, name=name) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/gen_script_ops.py", line 151, in py_func "PyFunc", input=input, token=token, Tout=Tout, name=name) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(args, **kwargs) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1801, in init self._traceback = tf_stack.extract_stack()

UnknownError (see above for traceback): KeyError: 5 Traceback (most recent call last):

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 249, in draw_boxes_with_label_and_scores self.draw_label_with_scores(draw_obj, box, a_label, a_score, color='White')

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 163, in draw_label_with_scores txt = self.label_name_map[label] + ':' + str(round(score, 2))

KeyError: 5

yangxue0827 commented 2 years ago

paste your label_dict.py here.

sangheonEN commented 2 years ago
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import

class_names = [
        'back_ground', 'person', 'bicycle', 'car', 'motorcycle',
        'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
        'fire hydrant', 'stop sign', 'parking meter', 'bench',
        'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant',
        'bear', 'zebra', 'giraffe', 'backpack', 'umbrella',
        'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard',
        'sports ball', 'kite', 'baseball bat', 'baseball glove',
        'skateboard', 'surfboard', 'tennis racket', 'bottle',
        'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
        'banana', 'apple', 'sandwich', 'orange', 'broccoli',
        'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair',
        'couch', 'potted plant', 'bed', 'dining table', 'toilet',
        'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
        'microwave', 'oven', 'toaster', 'sink', 'refrigerator',
        'book', 'clock', 'vase', 'scissors', 'teddy bear',
        'hair drier', 'toothbrush']

classes_originID = {
    'person': 1, 'bicycle': 2, 'car': 3, 'motorcycle': 4,
    'airplane': 5, 'bus': 6, 'train': 7, 'truck': 8, 'boat': 9,
    'traffic light': 10, 'fire hydrant': 11, 'stop sign': 13,
    'parking meter': 14, 'bench': 15, 'bird': 16, 'cat': 17,
    'dog': 18, 'horse': 19, 'sheep': 20, 'cow': 21, 'elephant': 22,
    'bear': 23, 'zebra': 24, 'giraffe': 25, 'backpack': 27,
    'umbrella': 28, 'handbag': 31, 'tie': 32, 'suitcase': 33,
    'frisbee': 34, 'skis': 35, 'snowboard': 36, 'sports ball': 37,
    'kite': 38, 'baseball bat': 39, 'baseball glove': 40,
    'skateboard': 41, 'surfboard': 42, 'tennis racket': 43,
    'bottle': 44, 'wine glass': 46, 'cup': 47, 'fork': 48,
    'knife': 49, 'spoon': 50, 'bowl': 51, 'banana': 52, 'apple': 53,
    'sandwich': 54, 'orange': 55, 'broccoli': 56, 'carrot': 57,
    'hot dog': 58, 'pizza': 59, 'donut': 60, 'cake': 61,
    'chair': 62, 'couch': 63, 'potted plant': 64, 'bed': 65,
    'dining table': 67, 'toilet': 70, 'tv': 72, 'laptop': 73,
    'mouse': 74, 'remote': 75, 'keyboard': 76, 'cell phone': 77,
    'microwave': 78, 'oven': 79, 'toaster': 80, 'sink': 81,
    'refrigerator': 82, 'book': 84, 'clock': 85, 'vase': 86,
    'scissors': 87, 'teddy bear': 88, 'hair drier': 89,
    'toothbrush': 90}

class LabelMap(object):

    def __init__(self, cfgs):
        self.cfgs = cfgs

    def coco_name2abel(self):
        # originID_classes = {item: key for key, item in classes_originID.items()}
        name_label_map = dict(zip(class_names, range(len(class_names))))
        return name_label_map

    def name2label(self):

        if self.cfgs.DATASET_NAME in ['WIDER', 'FDDB']:
            name_label_map = {
                'back_ground': 0,
                'face': 1
            }
        elif self.cfgs.DATASET_NAME in ['ICDAR2015', 'MSRA-TD500', 'MLT', 'Total_Text']:
            name_label_map = {
                'back_ground': 0,
                'text': 1
            }
        elif self.cfgs.DATASET_NAME in ['HRSC2016', 'HRSID']:
            name_label_map = {
                'back_ground': 0,
                'ship': 1
            }
        elif self.cfgs.DATASET_NAME.startswith('OHD-SJTU-ALL'):
            name_label_map = {
                'back_ground': 0,
                'small-vehicle': 1,
                'ship': 2,
                'plane': 3,
                'large-vehicle': 4,
                'helicopter': 5,
                'harbor': 6,
            }
        elif self.cfgs.DATASET_NAME.startswith('OHD-SJTU'):
            name_label_map = {
                'back_ground': 0,
                'ship': 1,
                'plane': 2
            }
        elif self.cfgs.DATASET_NAME.startswith('SSDD++'):
            name_label_map = {
                'back_ground': 0,
                'ship': 1
            }
        elif self.cfgs.DATASET_NAME.startswith('SKU110K-R'):
            name_label_map = {
                'back_ground': 0,
                'commodity': 1
            }
        elif self.cfgs.DATASET_NAME.startswith('UCAS-AOD'):
            name_label_map = {
                'back_ground': 0,
                'car': 1,
                'plane': 2
            }
        elif self.cfgs.DATASET_NAME.startswith('DOTA'):
            name_label_map = {
                'back_ground': 0,
                'roundabout': 1,
                'tennis-court': 2,
                'swimming-pool': 3,
                'storage-tank': 4,
                'soccer-ball-field': 5,
                'small-vehicle': 6,
                'ship': 7,
                'plane': 8,
                'large-vehicle': 9,
                'helicopter': 10,
                'harbor': 11,
                'ground-track-field': 12,
                'bridge': 13,
                'basketball-court': 14,
                'baseball-diamond': 15
            }
            if self.cfgs.DATASET_NAME == 'DOTA1.5':
                name_label_map['container-crane'] = 16
            if self.cfgs.DATASET_NAME == 'DOTA2.0':
                name_label_map['container-crane'] = 16
                name_label_map['airport'] = 17
                name_label_map['helipad'] = 18

        elif self.cfgs.DATASET_NAME == 'coco':
            name_label_map = self.coco_name2abel()
        elif self.cfgs.DATASET_NAME == 'pascal':
            name_label_map = {
                'back_ground': 0,
                'aeroplane': 1,
                'bicycle': 2,
                'bird': 3,
                'boat': 4,
                'bottle': 5,
                'bus': 6,
                'car': 7,
                'cat': 8,
                'chair': 9,
                'cow': 10,
                'diningtable': 11,
                'dog': 12,
                'horse': 13,
                'motorbike': 14,
                'person': 15,
                'pottedplant': 16,
                'sheep': 17,
                'sofa': 18,
                'train': 19,
                'tvmonitor': 20
            }
        elif self.cfgs.DATASET_NAME.startswith('DIOR'):
            name_label_map = {
                'back_ground': 0,
                'airplane': 1,
                'airport': 2,
                'baseballfield': 3,
                'basketballcourt': 4,
                'bridge': 5,
                'chimney': 6,
                'dam': 7,
                'Expressway-Service-area': 8,
                'Expressway-toll-station': 9,
                'golffield': 10,
                'groundtrackfield': 11,
                'harbor': 12,
                'overpass': 13,
                'ship': 14,
                'stadium': 15,
                'storagetank': 16,
                'tenniscourt': 17,
                'trainstation': 18,
                'vehicle': 19,
                'windmill': 20,
                # 'swimmingpool': 21,
                # 'soccerballfield': 22,
                # 'volleyballcourt': 23,
                # 'roundabout': 24,
                # 'container-crane': 25,
                # 'helipad': 26,
                # 'rugbyfield': 27
            }
        elif self.cfgs.DATASET_NAME == 'bdd100k':
            name_label_map = {
                'back_ground': 0,
                'bus': 1,
                'traffic light': 2,
                'traffic sign': 3,
                'person': 4,
                'bike': 5,
                'truck': 6,
                'motor': 7,
                'car': 8,
                'train': 9,
                'rider': 10
            }
        elif self.cfgs.DATASET_NAME == 'LEE':
            name_label_map = {
                'back_ground': 0,
                'container': 1,
                'oil-tanker': 2,
                'aircraft-carrier': 3,
                'maritime-vessels': 4,
                'war-ship': 5
            }
        else:
            name_label_map = {}
            assert 'please set label dict!'
        return name_label_map

    def label2name(self):
        label_name_map = {}
        for name, label in self.name2label().items():
            label_name_map[label] = name
        return label_name_map
yangxue0827 commented 2 years ago

Also paste your cfgs.py here.

sangheonEN commented 2 years ago
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import

import numpy as np

from configs._base_.models.retinanet_r50_fpn import *
# from configs._base_.datasets.dota_detection import *
from configs._base_.datasets.lee_detection import *
from configs._base_.schedules.schedule_1x import *
from alpharotate.utils.pretrain_zoo import PretrainModelZoo

# schedule
BATCH_SIZE = 1
GPU_GROUP = "0"
NUM_GPU = len(GPU_GROUP.strip().split(','))
SAVE_WEIGHTS_INTE = 20673
DECAY_STEP = np.array(DECAY_EPOCH, np.int32) * SAVE_WEIGHTS_INTE
MAX_ITERATION = SAVE_WEIGHTS_INTE * MAX_EPOCH
WARM_SETP = int(WARM_EPOCH * SAVE_WEIGHTS_INTE)

# dataset
DATASET_NAME = 'LEE'

# model
# backbone
pretrain_zoo = PretrainModelZoo()
PRETRAINED_CKPT = pretrain_zoo.pretrain_weight_path(NET_NAME, ROOT_PATH)
TRAINED_CKPT = os.path.join(ROOT_PATH, 'output/trained_weights')

# bbox head
METHOD = 'R'
ANCHOR_RATIOS = [1, 1 / 3., 3.]

# loss
CLS_WEIGHT = 1.0
REG_WEIGHT = 1.0 / 5.0
REG_LOSS_MODE = None

VERSION = 'RetinaNet_DOTA_1x_20210617'

"""
RetinaNet-R + 90
FLOPs: 512292484;    Trainable params: 34524216

AP50:95: [0.6500133314849993, 0.6221115492957145, 0.5783876659070408, 0.5151213008971589, 0.43878296014912604,
          0.3368465304363474, 0.22462667183919535, 0.11392563249065944, 0.03363650833577883, 0.002065178825137116]
mmAP: 0.35155173296611575
++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--
{'0.95': {'bridge': 0.004132231404958678, 'small-vehicle': 9.587038324185702e-05, 'roundabout': 0.0010822510822510823, 'tennis-court': 0.0213903743315508, 'ground-track-field': 0.0, 'basketball-court': 0.0, 'mAP': 0.002065178825137116, 'ship': 0.00033732501264968796, 'large-vehicle': 0.0002361275088547816, 'plane': 0.0008340283569641369, 'helicopter': 0.0, 'harbor': 9.362419249133976e-05, 'baseball-diamond': 0.0, 'storage-tank': 0.002775850104094379, 'swimming-pool': 0.0, 'soccer-ball-field': 0.0}, '0.6': {'bridge': 0.2180613029626103, 'small-vehicle': 0.48955296733750253, 'roundabout': 0.5743715824779693, 'tennis-court': 0.8988701575269984, 'ground-track-field': 0.499228771859173, 'basketball-court': 0.5809814425549822, 'mAP': 0.5783876659070408, 'ship': 0.7601302692501211, 'large-vehicle': 0.7307283640874089, 'plane': 0.8942021611064075, 'helicopter': 0.3072975896469221, 'harbor': 0.3269043269672149, 'baseball-diamond': 0.6129045619299885, 'storage-tank': 0.734913760456796, 'swimming-pool': 0.4140610594981138, 'soccer-ball-field': 0.6336066709434047}, '0.8': {'bridge': 0.09090909090909091, 'small-vehicle': 0.11325009395748946, 'roundabout': 0.21515151515151515, 'tennis-court': 0.7921941866364417, 'ground-track-field': 0.2096861471861472, 'basketball-court': 0.24332649806334017, 'mAP': 0.22462667183919535, 'ship': 0.26291307136684317, 'large-vehicle': 0.18348068300629328, 'plane': 0.40802398035426435, 'helicopter': 0.0303030303030303, 'harbor': 0.03896103896103896, 'baseball-diamond': 0.14207792207792208, 'storage-tank': 0.3159039855551453, 'swimming-pool': 0.014925373134328358, 'soccer-ball-field': 0.3082934609250399}, '0.75': {'bridge': 0.10214211076280041, 'small-vehicle': 0.19545376634203668, 'roundabout': 0.28496697538050925, 'tennis-court': 0.8550385251444838, 'ground-track-field': 0.31532093174321907, 'basketball-court': 0.4440063904349619, 'mAP': 0.3368465304363474, 'ship': 0.47083599337171966, 'large-vehicle': 0.3676002962555352, 'plane': 0.6242575391640972, 'helicopter': 0.04145169898594556, 'harbor': 0.09856749311294766, 'baseball-diamond': 0.2940265227697746, 'storage-tank': 0.4576325952192638, 'swimming-pool': 0.11452184179456906, 'soccer-ball-field': 0.3868752760633457}, '0.65': {'bridge': 0.1715728715728716, 'small-vehicle': 0.38714087806405156, 'roundabout': 0.48752732344925004, 'tennis-court': 0.8963243210004948, 'ground-track-field': 0.46565355697662375, 'basketball-court': 0.55128536051835, 'mAP': 0.5151213008971589, 'ship': 0.730472420280297, 'large-vehicle': 0.6571471502556688, 'plane': 0.8841534431766825, 'helicopter': 0.24147205105658032, 'harbor': 0.23720190635365604, 'baseball-diamond': 0.49210312524188676, 'storage-tank': 0.6753273086899294, 'swimming-pool': 0.30443298751756787, 'soccer-ball-field': 0.5450048093034745}, '0.5': {'bridge': 0.2812488756837439, 'small-vehicle': 0.6122705620423831, 'roundabout': 0.6293850696709108, 'tennis-court': 0.9013591967565613, 'ground-track-field': 0.5750856173584699, 'basketball-court': 0.6068251479708417, 'mAP': 0.6500133314849993, 'ship': 0.8601726316408385, 'large-vehicle': 0.7834049829446229, 'plane': 0.8961770992768222, 'helicopter': 0.3507698724777362, 'harbor': 0.5232626569936892, 'baseball-diamond': 0.6772717890839638, 'storage-tank': 0.7775776682818869, 'swimming-pool': 0.5425412825833318, 'soccer-ball-field': 0.7328475195091895}, '0.7': {'bridge': 0.12460815047021945, 'small-vehicle': 0.2845134660892606, 'roundabout': 0.3834644013719063, 'tennis-court': 0.8925703337005814, 'ground-track-field': 0.38178255494732427, 'basketball-court': 0.5012620086155817, 'mAP': 0.43878296014912604, 'ship': 0.6196205362182818, 'large-vehicle': 0.5254475720737497, 'plane': 0.7717130392038616, 'helicopter': 0.21916545239320936, 'harbor': 0.148302763837693, 'baseball-diamond': 0.394255080184464, 'storage-tank': 0.5963860132836875, 'swimming-pool': 0.22030141020234578, 'soccer-ball-field': 0.5183516196447231}, '0.55': {'bridge': 0.2446933360819818, 'small-vehicle': 0.5572753205907381, 'roundabout': 0.6127007450546773, 'tennis-court': 0.9013591967565613, 'ground-track-field': 0.5460695154831853, 'basketball-court': 0.598903178921024, 'mAP': 0.6221115492957145, 'ship': 0.8395840401868254, 'large-vehicle': 0.747613676166832, 'plane': 0.895943123347051, 'helicopter': 0.3439557489426765, 'harbor': 0.4312764134413297, 'baseball-diamond': 0.6530921050594436, 'storage-tank': 0.7668861840981078, 'swimming-pool': 0.4949977385816317, 'soccer-ball-field': 0.6973229167236527}, '0.9': {'bridge': 0.004132231404958678, 'small-vehicle': 0.003952569169960474, 'roundabout': 0.012396694214876032, 'tennis-court': 0.2869467055233188, 'ground-track-field': 0.045454545454545456, 'basketball-court': 0.012121212121212121, 'mAP': 0.03363650833577883, 'ship': 0.0303030303030303, 'large-vehicle': 0.00306894905544568, 'plane': 0.024475524475524476, 'helicopter': 0.0, 'harbor': 0.00267379679144385, 'baseball-diamond': 0.012987012987012986, 'storage-tank': 0.0202020202020202, 'swimming-pool': 0.0003787878787878788, 'soccer-ball-field': 0.045454545454545456}, '0.85': {'bridge': 0.025974025974025972, 'small-vehicle': 0.0303030303030303, 'roundabout': 0.11091872433199819, 'tennis-court': 0.6556119429916903, 'ground-track-field': 0.08181818181818182, 'basketball-court': 0.1098124098124098, 'mAP': 0.11392563249065944, 'ship': 0.11035613870665417, 'large-vehicle': 0.028601992732106313, 'plane': 0.16961143393022934, 'helicopter': 0.006493506493506493, 'harbor': 0.012987012987012986, 'baseball-diamond': 0.06296914095079233, 'storage-tank': 0.14633945289682992, 'swimming-pool': 0.0036784025223331584, 'soccer-ball-field': 0.1534090909090909}, 'mmAP': 0.35155173296611575}
"""
sangheonEN commented 2 years ago

lee_detection.py

# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import

DATASET_NAME = 'LEE'
CLASS_NUM = 6
PIXEL_MEAN = [123.68, 116.779, 103.939]  # R, G, B. In tf, channel is RGB. In openCV, channel is BGR
PIXEL_MEAN_ = [0.485, 0.456, 0.406] # resnet mean
PIXEL_STD = [0.229, 0.224, 0.225]
IMG_SHORT_SIDE_LEN = 800
IMG_MAX_LENGTH = 800

# data augmentation
IMG_ROTATE = False
RGB2GRAY = False
VERTICAL_FLIP = False
HORIZONTAL_FLIP = True
IMAGE_PYRAMID = False
sangheonEN commented 2 years ago

One thing to consider is that the back_ground label is not defined in the dataset I have created. In actual annotation label data, only labels 1 to 5 exist.

yangxue0827 commented 2 years ago

back_ground represents the background area, which is included in all images. It doesn't require you to annotate.

yangxue0827 commented 2 years ago

CLASS_NUM = 6 --> CLASS_NUM = 5

sangheonEN commented 2 years ago

CLASS_NUM = 6 --> CLASS_NUM = 5

same error

sangheonEN commented 2 years ago

txt = self.label_name_map[label] + ':' + str(round(score, 2))

score is 0.xx? so, 0.1, 0.2, 0.3, 0.4 ...

Not 1, 2, 3, 4

yangxue0827 commented 2 years ago

the error is caused by label. You may need to print the DATASET_NAME to ensure which name_label_map and label_name_map are used.

sangheonEN commented 2 years ago
            'motor': 7,
            'car': 8,
            'train': 9,
            'rider': 10
        }
    elif self.cfgs.DATASET_NAME == 'LEE':
        name_label_map = {
            'back_ground': 0,
            'container': 1,
            'oil-tanker': 2,
            'aircraft-carrier': 3,
            'maritime-vessels': 4,
            'war-ship': 5
        }
    else:
        name_label_map = {}
        assert 'please set label dict!'

    while(1):
        print(name_label_map)

    return name_label_map

print name_label_map in loop

however, not print name_label_map

yangxue0827 commented 2 years ago

print at def __init__(self, cfgs):

yangxue0827 commented 2 years ago

print(self.cfgs.DATASET_NAME)

sangheonEN commented 2 years ago

print at def __init__(self, cfgs):

i don't know this method. def init(self, cfgs): build? any .py code?

yangxue0827 commented 2 years ago
class LabelMap(object):

    def __init__(self, cfgs):
        self.cfgs = cfgs
        print(self.cfgs.DATASET_NAME)
sangheonEN commented 2 years ago
# -*- coding:utf-8 -*-
# Author: Xue Yang <yangxue-2019-sjtu@sjtu.edu.cn>, <yangxue0827@126.com>
# License: Apache-2.0 license
# Copyright (c) SJTU. ALL rights reserved.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os
import sys

import numpy as np
import tensorflow as tf
import tensorflow.contrib.slim as slim

sys.path.append("../../")

from tools.train_base import Train
from configs import cfgs
from alpharotate.libs.models.detectors.retinanet import build_whole_network
from alpharotate.libs.utils.coordinate_convert import backward_convert, get_horizen_minAreaRectangle
from alpharotate.utils.pretrain_zoo import PretrainModelZoo
os.environ["CUDA_VISIBLE_DEVICES"] = cfgs.GPU_GROUP

class TrainRetinaNet(Train):

    def get_gtboxes_and_label(self, gtboxes_and_label_h, gtboxes_and_label_r, num_objects):
        return gtboxes_and_label_h[:int(num_objects), :].astype(np.float32), \
               gtboxes_and_label_r[:int(num_objects), :].astype(np.float32)

    def main(self):
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        print(self.cfgs.DATASET_NAME)
        with tf.Graph().as_default() as graph, tf.device('/cpu:0'):

d; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
/home/jeongseunghyun/Rotation_Detector/RotationDetection-main
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
LEE
sangheonEN commented 2 years ago

I Train retinanet. where use name_label_map and label_name_map??

yangxue0827 commented 2 years ago

print your name_label_map and label_name_map at label_dict.py.

sangheonEN commented 2 years ago
        name_label_map = {
            'back_ground': 0,
            'bus': 1,
            'traffic light': 2,
            'traffic sign': 3,
            'person': 4,
            'bike': 5,
            'truck': 6,
            'motor': 7,
            'car': 8,
            'train': 9,
            'rider': 10
        }
    elif self.cfgs.DATASET_NAME == 'LEE':
        name_label_map = {
            'back_ground': 0,
            'container': 1,
            'oil-tanker': 2,
            'aircraft-carrier': 3,
            'maritime-vessels': 4,
            'war-ship': 5
        }
    else:
        name_label_map = {}
        assert 'please set label dict!'

    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())
    print(name_label_map.keys())

    return name_label_map

def label2name(self):
    label_name_map = {}
    for name, label in self.name2label().items():
        label_name_map[label] = name

    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())
    print(label_name_map.key())

    return label_name_map

but it is not print label_both name_map and name_label_map.

i think the code doesn't seem to run to that part.

yangxue0827 commented 2 years ago

it's really weird

sangheonEN commented 2 years ago

it's really weird

i think so.. it's late today and next day i will try again... and then i will comment here. thank you. please not close the issue. I must address this problem. hmm. If you are develop env is anaconda? my env is anaconda.

yangxue0827 commented 2 years ago

OK. This problem should have little to do with the development environment.

sangheonEN commented 2 years ago

UnknownError (see above for traceback): KeyError: 5 Traceback (most recent call last):

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 249, in draw_boxes_with_label_and_scores self.draw_label_with_scores(draw_obj, box, a_label, a_score, color='White')

File "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py", line 163, in draw_label_with_scores txt = self.label_name_map[label] + ':' + str(round(score, 2))

This problem path is "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/utils/draw_box_in_img.py"

**so, I aproach that path. and then i find the path that "/home/jeongseunghyun/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/libs/label_name_dict/label_dict.py"

In conclusion, i went ahead and made only changes to the label_dict.py code stored in the local path. However, when i installed alpharotate, I installed it with the pip install alpharotate command in the anaconda virtual env, so i had to change the alpharotate label_dict.py that exists in the anaconda env path.**

yangxue0827 commented 2 years ago

try pip uninstall alpharotate

to use the local alpharotate folder

sangheonEN commented 2 years ago

try pip uninstall alpharotate

to use the local alpharotate folder

I solve the error using below solution

I installed it with the pip install alpharotate command in the anaconda virtual env, so i had to change the alpharotate label_dict.py that exists in the anaconda env path.

and, first issue's solution is same thing.

147 Line. feature, pa_mask = self.build_backbone(input_img_batch)

If i change the code and tools, I must use the code that below path. "/anaconda3/envs/rotation_detector_2/lib/python3.6/site-packages/alpharotate/"

yangxue0827 commented 2 years ago

pip install alpharotate is not suitable for dev.