Skip to content

Commit

Permalink
fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaAndroid committed Nov 6, 2023
1 parent 0971a81 commit 0399808
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,9 @@
metric='bbox')

# ---------------------8 ChessPieces---------------------#
# TODO: check class name
# The office name of the first class is ' ', but it is represented as "bishop" in the JSON.
# black bishop -> black-bishop
class_name = ('bishop', 'black-bishop', 'black-king', 'black-knight', 'black-pawn',
'black-queen', 'black-rook', 'white-bishop', 'white-king',
'white-knight', 'white-pawn', 'white-queen', 'white-rook')
class_name = (' ', 'black bishop', 'black king', 'black knight', 'black pawn',
'black queen', 'black rook', 'white bishop', 'white king',
'white knight', 'white pawn', 'white queen', 'white rook')
metainfo = dict(classes=class_name)
_data_root = data_root + 'ChessPieces/Chess Pieces.v23-raw.coco/'
dataset_ChessPieces = dict(
Expand Down
96 changes: 96 additions & 0 deletions configs/odinw/override_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright (c) OpenMMLab. All rights reserved.
import argparse

import mmengine


def parse_args():
parser = argparse.ArgumentParser(description='Override Category')
parser.add_argument('data_root')
return parser.parse_args()


def main():
args = parse_args()

ChessPieces = [{
'id': 1,
'name': ' ',
'supercategory': 'pieces'
}, {
'id': 2,
'name': 'black bishop',
'supercategory': 'pieces'
}, {
'id': 3,
'name': 'black king',
'supercategory': 'pieces'
}, {
'id': 4,
'name': 'black knight',
'supercategory': 'pieces'
}, {
'id': 5,
'name': 'black pawn',
'supercategory': 'pieces'
}, {
'id': 6,
'name': 'black queen',
'supercategory': 'pieces'
}, {
'id': 7,
'name': 'black rook',
'supercategory': 'pieces'
}, {
'id': 8,
'name': 'white bishop',
'supercategory': 'pieces'
}, {
'id': 9,
'name': 'white king',
'supercategory': 'pieces'
}, {
'id': 10,
'name': 'white knight',
'supercategory': 'pieces'
}, {
'id': 11,
'name': 'white pawn',
'supercategory': 'pieces'
}, {
'id': 12,
'name': 'white queen',
'supercategory': 'pieces'
}, {
'id': 13,
'name': 'white rook',
'supercategory': 'pieces'
}]

_data_root = args.data_root + 'ChessPieces/Chess Pieces.v23-raw.coco/'
json_data = mmengine.load(_data_root +
'valid/annotations_without_background.json')
json_data['categories'] = ChessPieces
mmengine.dump(json_data,
_data_root + 'valid/annotations_without_background.json')

NorthAmericaMushrooms = [{
'id': 1,
'name': 'flat mushroom',
'supercategory': 'mushroom'
}, {
'id': 2,
'name': 'yellow mushroom',
'supercategory': 'mushroom'
}]

_data_root = args.data_root + 'NorthAmericaMushrooms/North American Mushrooms.v1-416x416.coco/' # noqa
json_data = mmengine.load(_data_root +
'valid/annotations_without_background.json')
json_data['categories'] = NorthAmericaMushrooms
mmengine.dump(json_data,
_data_root + 'valid/annotations_without_background.json')


if __name__ == '__main__':
main()

0 comments on commit 0399808

Please sign in to comment.