{"id":13640419,"url":"https://github.com/charlescao460/MapleStoryDetectionSampleGenerator","last_synced_at":"2025-04-20T02:33:31.668Z","repository":{"id":37675637,"uuid":"272241566","full_name":"charlescao460/MapleStoryDetectionSampleGenerator","owner":"charlescao460","description":"Generate object detection samples from MapleStory in different formats (COCO, TFRecord, darknet...)","archived":false,"fork":false,"pushed_at":"2025-01-20T19:15:30.000Z","size":5492,"stargazers_count":26,"open_issues_count":1,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-18T21:47:54.738Z","etag":null,"topics":["annotation-tool","coco","darknet","machine-learning","maplestory","object-detection","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charlescao460.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-06-14T16:34:11.000Z","updated_at":"2025-03-24T07:02:35.000Z","dependencies_parsed_at":"2024-04-12T23:38:16.621Z","dependency_job_id":null,"html_url":"https://github.com/charlescao460/MapleStoryDetectionSampleGenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlescao460%2FMapleStoryDetectionSampleGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlescao460%2FMapleStoryDetectionSampleGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlescao460%2FMapleStoryDetectionSampleGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlescao460%2FMapleStoryDetectionSampleGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charlescao460","download_url":"https://codeload.github.com/charlescao460/MapleStoryDetectionSampleGenerator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249840695,"owners_count":21332925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotation-tool","coco","darknet","machine-learning","maplestory","object-detection","tensorflow"],"created_at":"2024-08-02T01:01:10.981Z","updated_at":"2025-04-20T02:33:31.270Z","avatar_url":"https://github.com/charlescao460.png","language":"C#","funding_links":[],"categories":["Cheat"],"sub_categories":[],"readme":"# MapleStoryDetectionSampleGenerator\nGenerate Machine Learning Samples Object Detection In MapleStory\n![](https://github.com/charlescao460/MapleStoryDetectionSampleGenerator/blob/main/pictures/result.png)\n\n\n\n# Performance\nThis generator can generate arbitrarily many annotated samples. All bounding boxes are precisely annotated based on rendering coordinates.\n\nWith [YOLOv4](https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov4-custom.cfg) and ~5000 samples, it can achieve 99.8%mAP in test set.\n\n\n![](https://github.com/charlescao460/MapleStoryDetectionSampleGenerator/blob/main/pictures/chart_yolov4-custom.png)\n\n# Requirement\n* Visual Studio 2022 v17.8 or above, with .NET workload installed\n* .NET 8.0 SDK (8.0.0 or above)\n\n# Build\n1. Clone this repository with submodules by \u003c/br\u003e `git clone --recursive git@github.com:charlescao460/MapleStoryDetectionSampleGenerator.git`. \u003c/br\u003eNote that `--recursive` is necessary.\n2. Build `WzComparerR2/WzComparerR2.sln` (submodule MUST be built first)\n3. Build `MapleStoryDetectionSampleGenerator.sln`\n4. Run `MapleStory.MachineLearningSampleGenerator\\bin\\Release\\net8.0-windows7.0\\WzComparerR2.exe`. Running `WzComparerR2.exe` will generate `Setting.config`, which is required for our MapRender.\n\n# Run\n(Assuming assemblies are built with `Release` configuration. `Debug` configuration is similar)\n1. Cd into executable directory: `cd MapleStory.MachineLearningSampleGenerator\\bin\\Release\\net8.0-windows7.0`\n2. Use `WzComparerR2.exe` to find the desired map you want to sample. Assuming `993134200.img` is the map you want in Limina.\n3. Prepare your player PNGs in a directory. \u003c/br\u003eSince WzComparerR2 does not have Avatar supported inside MapRender, we have to draw player images in our post-processing steps. Player images should be transparent PNGs with only the player's appearance. You can get these PNGs by Photoshop or save from WzComparerR2's Avatar plugin. Assuming `.\\players` is the directory containing all images\n4. Run ```.\\MapleStory.MachineLearningSampleGenerator.exe -m 993134200 -x 5 -y 5 -f coco -o \".\\output\" --post --players \".\\players\"```\u003c/br\u003e\nThis means run the sampler in map 993134200.img with every 5 pixels in X and every 5 pixels in Y, outputing COCO format, and drawing players in post processor. \u003c/br\u003e\nYou can run `.\\MapleStory.MachineLearningSampleGenerator.exe --help` for usage hint. Also you can take a look of the entrypoint [Program.cs](https://github.com/charlescao460/MapleStoryDetectionSampleGenerator/blob/main/MapleStory.MachineLearningSampleGenerator/Program.cs)\n\n# Note\n* Since NPCs look like players, including them without annotation could result a negative effect on our model. If you want to hide all NPCs from generated samples, simply change [WzComparerR2.MapRender/MapData.cs](https://github.com/Kagamia/WzComparerR2/blob/main/WzComparerR2.MapRender/MapData.cs) to prevent any NPC data loaded into map render. \n\n# Output Formats\n## Tensorflow TFRecord\nAccording to Tensorflow [official document](https://www.tensorflow.org/tutorials/load_data/tfrecord#tfrecords_format_details), the output .tfrecord contains multiple [tf.train.Example](https://www.tensorflow.org/api_docs/python/tf/train/Example) in single file. With each example store in the following formats:\n\n```\nuint64 length\nuint32 masked_crc32_of_length\nbyte   data[length]\nuint32 masked_crc32_of_data\n```\nAnd\n```\nmasked_crc = ((crc \u003e\u003e 15) | (crc \u003c\u003c 17)) + 0xa282ead8ul\n```\nEach `tf.train.Example` is generated by [protobuf-net](https://github.com/protobuf-net/protobuf-net) according to Tensorflow [example.proto](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto)\n\n## Darknet\nOutput directory structure:\n```\ndata/\n|---obj/\n|   |---1.jpg\n|   |---1.txt\n|   |---......\n|---obj.data\n|---obj.names\n|---test.txt\n|---train.txt\n```\n`obj.data` contains \n```\nclasses=2\ntrain=data/train.txt\nvalid=data/test.txt\nnames=data/obj.names\nbackup = backup/\n```\nAnd `obj.names` contains the class name for object. `test.txt` and `train.txt` contains samples for testing/training with ratio of 5:95 (5% of images in `obj/` are used for testing).\n\n## COCO\nOutput directory structure:\n```\ncoco/\n|---train2017/\n|   |---1.jpg\n|   |---2.jpg\n|   |---......\n|---val2017/\n|   |---1000.jpg\n|   |---1001.jpg\n|   |---......\n|---annotations/\n|   |---instances_train2017.json\n|   |---instances_val2017.json\n```\nThe COCO json is defined as following:\n```json\n{\n  \"info\": {\n    \"description\": \"MapleStory 993134100.img Object Detection Samples - Training\",\n    \"url\": \"https://github.com/charlescao460/MapleStoryDetectionSampleGenerator\",\n    \"version\": \"1.0\",\n    \"year\": 2021,\n    \"contributor\": \"CSR\"\n  },\n  \"licenses\": [\n    {\n      \"url\": \"https://github.com/charlescao460/MapleStoryDetectionSampleGenerator/blob/main/LICENSE\",\n      \"id\": 1,\n      \"name\": \"MIT License\"\n    }\n  ],\n  \"images\": [\n    {\n      \"license\": 1,\n      \"file_name\": \"30a892e1-7f3d-4c65-bdd1-9d28f1ae5187.jpg\",\n      \"coco_url\": \"\",\n      \"height\": 768,\n      \"width\": 1366,\n      \"flickr_url\": \"\",\n      \"id\": 1\n    },\n    ...],\n  \"categories\": [\n    {\n      \"supercategory\": \"element\",\n      \"id\": 1,\n      \"name\": \"Mob\"\n    },\n    {\n      \"supercategory\": \"element\",\n      \"id\": 2,\n      \"name\": \"Player\"\n    }\n  ],\n  \"annotations\": [\n    {\n      \"segmentation\": [\n        [\n          524,\n          429,\n          664,\n          429,\n          664,\n          578,\n          524,\n          578\n        ]\n      ],\n      \"area\": 20860,\n      \"iscrowd\": 0,\n      \"image_id\": 1,\n      \"bbox\": [\n        524,\n        429,\n        140,\n        149\n      ],\n      \"category_id\": 1,\n      \"id\": 1\n    },\n    ...]\n```\nNote that `segmentation` covers the area as the same as `bbox` does. No segmentation or masked implemented .\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlescao460%2FMapleStoryDetectionSampleGenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlescao460%2FMapleStoryDetectionSampleGenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlescao460%2FMapleStoryDetectionSampleGenerator/lists"}