question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

load_hrsc loads all objects as ship, arguments classes is no use

See original GitHub issue
def load_hrsc(img_dir, ann_dir, classes=None, img_keys=dict(), obj_keys=dict(), nproc=10):
    if classes is not None:
        print('load_hrsc loads all objects as ship, arguments classes is no use')

加载hrsc数据集,所有的图片的类名都是 ”ship“,这个怎么弄啊?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wang11weicommented, Nov 15, 2021

请问如果我需要检测并验证其它的类别,不仅仅是ship类,我应该怎么更改参数呢?我尝试更改BboxToolkit/BboxToolkit/datasets/misc.py中的dataset_classes类别,将’HRSC’: (‘ship’, ),更改为’HRSC’: (‘submarine’,‘merchant ship’,‘ship’, ),但是好像并没起作用。请问其它还有地方需要更改吗?比如类别数目等?

还有 hrscio.py 里面加载标签的部分需要修改: 根据需要加载你自己的标签,我是直接加载它自带的分类的

def _load_hrsc_xml(xmlfile, img_keys=dict(), obj_keys=dict()):
    hbboxes, bboxes, diffs, class_id = list(), list(), list(), list()
    content = {k: None for k in img_keys}
    ann = {k: [] for k in obj_keys}
    if xmlfile is None:
        pass
    elif not osp.isfile(xmlfile):
        print(f"Can't find {xmlfile}, treated as empty xmlfile")
    else:
        tree = ET.parse(xmlfile)
        root = tree.getroot()

        content['width'] = int(root.find('Img_SizeWidth').text)
        content['height'] = int(root.find('Img_SizeHeight').text)
        for k, xml_k in img_keys.items():
            node = root.find(xml_k)
            value = None if node is None else node.text
            content[k] = value

        objects = root.find('HRSC_Objects')
        for obj in objects.findall('HRSC_Object'):
            hbboxes.append([
                float(obj.find('box_xmin').text),
                float(obj.find('box_ymin').text),
                float(obj.find('box_xmax').text),
                float(obj.find('box_ymax').text)
            ])
            bboxes.append([
                float(obj.find('mbox_cx').text),
                float(obj.find('mbox_cy').text),
                float(obj.find('mbox_w').text),
                float(obj.find('mbox_h').text),
                -float(obj.find('mbox_ang').text)
            ])
            diffs.append(int(obj.find('difficult').text))
            class_id.append(int(obj.find('Class_ID').text[2:])-1)

            for k, xml_k in obj_keys.items():
                node = obj.find(xml_k)
                value = None if node is None else node.text
                ann[k].append(value)

    hbboxes = np.array(hbboxes, dtype=np.float32) if hbboxes \
        else np.zeros((0, 4), dtype=np.float32)
    bboxes = np.array(bboxes, dtype=np.float32) if bboxes \
        else np.zeros((0, 5), dtype=np.float32)
    diffs = np.array(diffs, dtype=np.int64) if diffs \
        else np.zeros((0,), dtype=np.int64)
    labels = np.array(class_id, dtype=np.int64) if class_id \
        else np.zeros((0,), dtype=np.int64)
    # labels = np.zeros((bboxes.shape[0],), dtype=np.int64)

    ann['hbboxes'] = hbboxes
    ann['bboxes'] = bboxes
    ann['diffs'] = diffs
    ann['labels'] = labels
    content['ann'] = ann
    return content
0reactions
Superfly12138commented, Nov 17, 2021

从上边的测试结果看出,由于测试的数据并没包含全部类。我针对性的选取了gt数较多的7个类,使用oriented-rcnn算法训练36个epoch,效果看起来还不错。 image

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - when to create a class with object as an argument ...
If you are maintaining Python 2 code, the rule is simple: always inherit from object if there is no other type to inherit...
Read more >
Initialize Objects When Loading - MATLAB & Simulink
Ensure that MATLAB can call the class constructor with no arguments without generating an error. Attributes set on superclasses are not inherited by...
Read more >
Passing Information to a Method or a Constructor
Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must...
Read more >
Python Classes and Objects
Python is an object-oriented language and its constructs are usually classes and objects. This introduces Python Classes and their objects.
Read more >
Python Class Constructors: Control Your Object Instantiation
__init__() with an appropriate set of arguments. After this call, your Point object is properly initialized, with all its attributes set up. A ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found