semantic-segmentation-editor icon indicating copy to clipboard operation
semantic-segmentation-editor copied to clipboard

Add a JSON import feature

Open ghost opened this issue 6 years ago • 6 comments

Thank you for good tool. I would like to load auto-annotated json files. Is it possible?

ghost avatar Sep 01 '18 03:09 ghost

No it's not possible for now. Let's create a feature request.

dmandrioli avatar Sep 01 '18 07:09 dmandrioli

Has anyone worked on this?

brappazzo avatar Feb 27 '19 23:02 brappazzo

Hello @brappazzo, nothing new on this feature, feel free to provide a PR. Thanks.

dmandrioli avatar Feb 28 '19 07:02 dmandrioli

I am trying to work on this, any suggestions on the best approach?

brappazzo avatar May 10 '19 17:05 brappazzo

First draw some polygons then look at the content of the mongo database, the goal is to inject data with the same format. Then you will need a server-side service to inject the JSON into mongo, you can take inspiration from server/files.js or server/api.js. The transfered data could be a regular file or directly the JSON content.

I hope this helps, I will be happy to review your pull request if you plan to submit one.

dmandrioli avatar May 10 '19 18:05 dmandrioli

You can inject json into mongo using below code:

from pymongo import MongoClient


class SseHelper:

    def __init__(self):
    ¦   client = MongoClient('127.0.0.1:3001')
    ¦   db = client.meteor
    ¦   self.SseSamples = db.SseSamples

    def get_anno(self, filename: str):
    ¦   url = "/" + filename.replace("/", "%2F")
    ¦   anno = self.SseSamples.find_one({"url": url})
    ¦   return anno

    def set_anno(self, filename: str, anno: dict):
    ¦   url = "/" + filename.replace("/", "%2F")
    ¦   self.SseSamples.update_one({"url": url}, {"$set": anno})

    def add_anno(self, anno: dict):
    ¦   ret = self.SseSamples.insert_one(anno)


if __name__ == "__main__":
    sse = SseHelper()
    query = "/test/1.png"
    anno = sse.get_anno(query)
    # load your anno from json file
    anno["objects"].pop(0)
    sse.set_anno("/test/1.png", anno)
    # sse.add_anno(new_anno)

DuinoDu avatar Apr 13 '23 15:04 DuinoDu