From 063a10e57fdd1dc02875f3ddd9c1094fbd5e9be7 Mon Sep 17 00:00:00 2001
From: zinsmatt <zins.matthieu@gmail.com>
Date: Mon, 19 Apr 2021 23:49:51 +0200
Subject: [PATCH] Update scene file architecture and doc

---
 README.md                      | 35 ++++++++++++++++++++--------------
 data/7-Scenes_Chess_scene.json | 22 ++++++++++-----------
 scene_loader.py                |  2 +-
 3 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index fd398fe..a39fc61 100644
--- a/README.md
+++ b/README.md
@@ -61,18 +61,25 @@ You can easily apply the method on your own dataset. There are only two required
 The localization method is based on a scene model in the form of an ellipsoid cloud. We adopted a simple JSON format this scene model, describing the ellipoids with some semantic information (i.e the object category).
 
 ```jsonc
-[
-    {
-        "category_id": 3,
-        "object_id": 7,
-        "ellipse": {
-            "axes": [0.1, 0.2, 0.3],
-            "R": [], // 3x3 rotation matrix
-            "center": [0.2, 0.2, 0.4],
-        }
+{
+    "category_id_to_label": {
+        "0": "tv",
+        "1": "chair",
+        // ...
     },
-    // ...
-]
+    "objects": [
+        {
+            "category_id": 3,
+            "object_id": 7,
+            "ellipsoid": {
+                "axes": [0.1, 0.2, 0.3],
+                "R": [], // 3x3 rotation matrix
+                "center": [0.2, 0.2, 0.4],
+            }
+        },
+        // ...
+    ]
+}
 ```
 
  We provide a scene model for the Chess scene of the 7-Scene dataset, composed of 11 objects (from 7 cateories) on the Chess scene of the 7-Scenes dataset.
@@ -139,12 +146,12 @@ Pre-trained weights for the ellipse prediction part on the Chess scene can be do
 To train the ellipse prediction network for each object of you scene, run:
 
 ```
-python train_ellipse_prediction.py scene.json 7-Scenes_Chess_dataset_train_with_obj_annot.json 7-Scenes_Chess_dataset_test_with_obj_annot.json ellipses_checkpoints [--nb_epochs 300]
+python train_ellipse_prediction.py data/7-Scenes_Chess_scene.json 7-Scenes_Chess_dataset_train_with_obj_annot.json 7-Scenes_Chess_dataset_test_with_obj_annot.json ellipses_checkpoints [--nb_epochs 300]
 ```
 
 ### Evaluation
 ```
-python eval_ellipse_prediction.py scene.json 7-Scenes_Chess_dataset_test_with_obj_annot.json ellipses_checkpoints [--output_images out_folder]
+python eval_ellipse_prediction.py data/7-Scenes_Chess_scene.json 7-Scenes_Chess_dataset_test_with_obj_annot.json ellipses_checkpoints [--output_images out_folder]
 ```
 
 
@@ -174,7 +181,7 @@ The `config.py` file contains parameters that can be changed. Especially, it def
 Run the following command:
 
  ```
- python run.py scene.json  7-Scenes_Chess_dataset_test.json detector_checkpoint/final.pth ellipses_checkpoints --visualize [--output_images output_folder --skip_frames 50 --output_predictions predictions.json --output_errors errors]
+ python run.py data/7-Scenes_Chess_scene.json  7-Scenes_Chess_dataset_test.json detector_checkpoint/final.pth ellipses_checkpoints --visualize [--output_images output_folder --skip_frames 50 --output_predictions predictions.json --output_errors errors]
 ```
 
 
diff --git a/data/7-Scenes_Chess_scene.json b/data/7-Scenes_Chess_scene.json
index e581ce7..29370a0 100644
--- a/data/7-Scenes_Chess_scene.json
+++ b/data/7-Scenes_Chess_scene.json
@@ -12,7 +12,7 @@
         {
             "category_id": 0,
             "object_id": 0,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.17790342378298427,
                     0.4196947342281149,
@@ -45,7 +45,7 @@
         {
             "category_id": 0,
             "object_id": 1,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.4433777080322151,
                     0.343021362184948,
@@ -78,7 +78,7 @@
         {
             "category_id": 1,
             "object_id": 2,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.2845037494354427,
                     0.18057472335963232,
@@ -111,7 +111,7 @@
         {
             "category_id": 1,
             "object_id": 3,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.2364234654295947,
                     0.1746075948167475,
@@ -144,7 +144,7 @@
         {
             "category_id": 2,
             "object_id": 4,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.2130813372990089,
                     0.15798663400711946,
@@ -177,7 +177,7 @@
         {
             "category_id": 2,
             "object_id": 5,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.24055877935769834,
                     0.1439650208931686,
@@ -210,7 +210,7 @@
         {
             "category_id": 2,
             "object_id": 6,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.11021662375625348,
                     0.25072606804543834,
@@ -243,7 +243,7 @@
         {
             "category_id": 3,
             "object_id": 7,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.11144366319435015,
                     0.05186568254044441,
@@ -276,7 +276,7 @@
         {
             "category_id": 4,
             "object_id": 8,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.176306186807118,
                     0.09696996280232797,
@@ -309,7 +309,7 @@
         {
             "category_id": 5,
             "object_id": 9,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.025678840931716667,
                     0.06426116845378854,
@@ -342,7 +342,7 @@
         {
             "category_id": 6,
             "object_id": 10,
-            "ellipse": {
+            "ellipsoid": {
                 "axes": [
                     0.08824363472966783,
                     0.06515494036182076,
diff --git a/scene_loader.py b/scene_loader.py
index 82fcb5f..0855c60 100644
--- a/scene_loader.py
+++ b/scene_loader.py
@@ -18,7 +18,7 @@ class Scene_loader:
             obj_data = {
                 "category_id": obj["category_id"],
                 "object_id": obj["object_id"],
-                "ellipsoid": Ellipsoid.from_dict(obj["ellipse"])
+                "ellipsoid": Ellipsoid.from_dict(obj["ellipsoid"])
             }
             self.object_id_map[obj["object_id"]] = len(self.objects)
             self.objects.append(obj_data)
-- 
GitLab