code / schemas.py
MSheng-Lee's picture
Upload folder using huggingface_hub
f20b100 verified
initial_schema = {
"type" : "object",
"properties":{
"objects_in_room" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"object_id": {
"type": "string",
"description" : "The id of the object, e.g. chair_1, table_1, bed_1, etc."
},
"style" : {
"type" : "string",
"description" : "Architectural Style of the object"
},
"material" : {
"type" : "string",
"description" : "The material that this object is made of"
},
"functionality" : {
"type" : "string",
"description" : "The functionality of the object"
},
"color" : {
"type" : "string",
"description" : "The color of the object"
},
"size_in_meters" : {
"type": "object",
"properties": {
"length": {
"type": "number"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
}
},
"required" : ["length", "width", "height"]
},
"is_on_the_floor" : {
"type" : "boolean",
"description" : "Whether the this object is touching the floor"
},
"facing" : {
"type" : "string",
"description" : "The id of the object is this object facing, this has to be an object_id! Ex. west_wall, bookshelf_1, desk_1..."
},
"placement" : {
"type" : "object",
"description" : "The placement of the object in the room as a scene graph",
"properties" : {
"room_layout_elements" : {
"type" : "array",
"description" : "Scene Graph with the room layout elements such as walls, floor or ceiling. Ex. The desk is centered on the south wall, the chair is in the south-west corner...",
"items" : {
"type" : "object",
"properties" : {
"layout_element_id" : {
"type" : "string",
"description" : "The id of the layout element that this object is connected to, ex. south_wall, west_wall, ceiling...",
"enum" : ["south_wall", "north_wall", "west_wall", "east_wall", "ceiling", "middle of the room"]
},
"preposition" : {
"type" : "string",
"description" : "The preposition that connects this object and the layout element, ex. on the west wall, in the corner...",
"enum" : ["on", "in the corner"]
}
},
"required" : ["layout_element_id", "preposition"]
}
},
"objects_in_room" : {
"type" : "array",
"description" : "Scene Graph with the other placed objects in the room. Ex. The chair is in front of the desk, the plant is right of the bookshelf...",
"items" : {
"type" : "object",
"properties" : {
"object_id" : {
"type" : "string",
"description" : "The id of the object that this object is connected to, ex. bookshelf_1, plant_1..."
},
"preposition" : {
"type" : "string",
"description" : "The preposition that connects this object and the connected object. 'new_object_id' is 'preposition' 'object_id' . Ex. lamp_1 is left of desk_1, table_1 is behind the bed_1, rug_1 is under desk_1, light_1 is above the table_1 (a rug is never 'on' or 'above' another object)...",
"enum" : ["on", "left of", "right of", "in front", "behind", "under", "above"]
},
"is_adjacent" : {
"type" : "boolean",
"description" : "Whether this object and the connected object are adjacent to each other, ex. an object on the desk is adjacent to the desk."
}
}
}
}
},
"required" : ["room_layout_elements", "objects_in_room"]
}
},
"required" : ["new_object_id", "style", "material", "functionality", "color", "size_in_meters", "is_on_the_floor", "facing", "placement"]
}
}
},
"required" : ["objects_in_room"]
}
# interior_designer_schema = """
# {
# "Objects" : {
# "type" : "array",
# "items" : {
# "type" : "object",
# },
# "required" : ["Objects"]
# }
# """
interior_designer_schema = """
{
"chain_of_thought": {
"type": "array",
"items": {
"type": "string"
}
},
"objects" : {
"type" : "array",
"items" : {
"type" : "object"
}
},
"required" : ["chain_of_thought", "objects"]
}
"""
# interior_architect_schema = """
# {
# "Reason": {
# "type": "array",
# "items": {
# "type": "string"
# }
# },
# "Placements" : {
# "type" : "array",
# "items" : {
# "type" : "object",
# }
# }
# }
# """
scene_graph_schema = """
{
"chain_of_thought": {
"type": "string",
"description": "The reasoning should strictly follow the format with three specific sections: \n<REASON> Provide a chain-of-thought, logical explanation of the placement. This should outline step-by-step reasoning for why the object is placed in that location. </REASON>\n<CHECK> Ensure the placement of the new object satisfies all four principles (1. no spatial conflicts between objects, 2. aligns with user input preferences, 3. adheres to design principles, 4. meets functionality/aesthetic considerations.). If any of these are not satisfied, propose adjustments and revisit the REASON process. </CHECK>\n<CONCLUSION> Summarize the final placement of the new object, including its relative position to other objects in the scene, its orientation, and any relevant considerations. </CONCLUSION>"
},
"objects_in_room": {
"type" : "array",
"items" : {
"new_object_id": {
"type": "string",
"description": "The lower-case id of the object, e.g. chair_1, table_1, bed_1, etc."
},
"style": {
"type": "string",
"description": "Architectural Style of the object"
},
"material": {
"type": "string",
"description": "The material that this object is made of"
},
"functionality": {
"type": "string",
"description": "The functionality of the object"
},
"color": {
"type": "string",
"description": "The color of the object"
},
"size_in_meters": {
"type": "object",
"properties": {
"length": {
"type": "number"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
}
},
"required": ["length", "width", "height"]
},
"is_on_the_floor": {
"type": "boolean",
"description": "Whether the object is touching the floor"
},
"facing": {
"type": "string",
"description": "Which wall (west_wall/east_wall/north_wall/south_wall) this object should be facing and explicitly state this! E.g. west_wall, south_wall..."
},
"placement": {
"type": "object",
"description": "The placement of the object in the room as a scene graph. If the object has multiple relative positions with other objects, both the 'room_layout_elements' and 'objects_in_room' arrays should reflect that.",
"properties": {
"room_layout_elements": {
"type": "array",
"description": "Scene Graph with the room layout elements such as walls, floor, or ceiling. Ex. The desk is on the south wall, the chair is in the south-west corner...",
"items": {
"layout_element_id": {
"type": "string",
"description": "The id of the layout element that this object is connected to, e.g. south_wall, north_wall, ceiling... . Only the following layout_element_id ["south_wall", "north_wall", "west_wall", "east_wall", "ceiling", "middle of the room"] are allowed.",
"enum": ["south_wall", "north_wall", "west_wall", "east_wall", "ceiling", "middle of the room"]
},
"preposition": {
"type": "string",
"description": "The preposition that connects this object and the layout element, e.g. on the west wall, in the south-west corner... For corners, both walls are included. Only the following prepositions ["on", "in the corner"] are allowed.",
"enum": ["on", "in the corner"]
}
},
"required": ["layout_element_id", "preposition"]
},
"objects_in_room": {
"type": "array",
"description": "Scene Graph with the other placed objects in the room. Ex. The chair is in front of the desk, the plant is right of the bookshelf...",
"items": {
"object_id": {
"type": "string",
"description": "The id of the object that this object is connected to, e.g. bookshelf_1, plant_1..."
},
"preposition": {
"type": "string",
"description": "The preposition that connects the new_object_id and object_id objects in the following format: "new_object_id" is "preposition" "object_id". Ex. lamp_1 is left of desk_1, table_1 is behind the bed_1, rug_1 is under desk_1, light_1 is above table_1...",
"enum": ["on", "left of", "right of", "in front", "behind", "under", "above"]
},
"is_adjacent": {
"type": "boolean",
"description": "1. Adjacent : The object is physically contacting the other object and it is supported by the other object and they are touching each other. 2. Not Adjacent: The object is not physically contacting the other object or it is distant from the other object."
}
}
}
},
"required": ["room_layout_elements", "objects_in_room"]
},
"required": ["new_object_id", "style", "material", "functionality", "color", "size_in_meters", "is_on_the_floor", "facing", "placement"]
}
},
"required": ["chain_of_thought", "objects_in_room"]
}
"""
# scene_graph_schema = """
# {
# "reason": {
# "type": "str",
# "description" : "The reason for the placement of the object"
# },
# "objects_in_room" : {
# "type" : "array",
# "items" : {
# "type" : "object",
# "properties" : {
# "object_id": {
# "type": "string",
# "description" : "The lower-case id of the object, e.g. chair_1, table_1, bed_1, etc."
# },
# "style" : {
# "type" : "string",
# "description" : "Architectural Style of the object"
# },
# "material" : {
# "type" : "string",
# "description" : "The material that this object is made of"
# },
# "functionality" : {
# "type" : "string",
# "description" : "The functionality of the object"
# },
# "color" : {
# "type" : "string",
# "description" : "The color of the object"
# },
# "size_in_meters" : {
# "type": "object",
# "properties": {
# "length": {
# "type": "number"
# },
# "width": {
# "type": "number"
# },
# "height": {
# "type": "number"
# }
# },
# "required" : ["length", "width", "height"]
# },
# "reason" : {
# "type" : "array",
# "description" : "Please perform step-by-step reasoning based on the Interior Architect's related reasoning steps and common principles of interior design, following a clear chain-of-thought structure to answer whether the this object is touching the floor and its facing object.
# For example, consider the Interior Architect's reasoning step: [... The pendant light should be directly above the pool table to provide optimal lighting for the play area. It will be centered over the pool table, hanging from the ceiling ...].
# Based on'hanging from the ceiling,' and common design logic the pendant light should be attached to the ceiling rather than the floor. Therefore, the pendant light is not touching the floor.
# Additionally, since it is 'above the pool table to provide optimal lighting for the play area', the facing direction should be set to the floor."
# },
# "is_on_the_floor" : {
# "type" : "boolean",
# "description" : "Whether the this object is touching the floor"
# },
# "facing" : {
# "type" : "string",
# "description" : "The id of the object is this object facing, this has to be an object_id! Ex. west_wall, bookshelf_1, desk_1..."
# },
# "placement" : {
# "type" : "object",
# "description" : "The placement of the object in the room as a scene graph",
# "properties" : {
# "room_layout_elements" : {
# "type" : "array",
# "description" : "Scene Graph with the room layout elements such as walls, floor or ceiling. Ex. The desk is on the south wall, the chair is in the south-west corner...",
# "items" : {
# "type" : "object",
# "properties" : {
# "reason" : {
# "type" : "array",
# "description": "The rationale for answering the layout_element_id and preposition to ensure accurate object placement. For example: Objects to be placed in the room (in triple backquotes):‘’‘
# 'Object Name': 'Pendant Light'
# 'Placement': 'above the Pool Table',
# 'Proximity': 'Adjacent',
# 'Facing': 'one is facing the floor'
# ``` Consider the Interior Architect's related reasoning step: [... The pendant light should be directly above the pool table to provide optimal lighting for the play area. It will be centered over the pool table, hanging from the ceiling ...].
# Furthermore, the layout_element_id must be selected from the predefined enum options [south_wall, north_wall, west_wall, east_wall, ceiling, middle of the room], and the preposition must be selected from the predefined enum options [on, in the corner].
# Therefore, the layout_element_id should be updated to ceiling instead of pool_table and the preposition should be corrected to under due to hanging from.
# Please perform step-by-step reasoning before answering the layout_element_id and preposition."
# },
# "layout_element_id" : {
# "type" : "string",
# "description" : "The id of the layout element that this object is connected to, ex. south_wall, west_wall, ceiling...",
# "enum" : ["south_wall", "north_wall", "west_wall", "east_wall", "ceiling", "middle of the room"]
# },
# "preposition" : {
# "type" : "string",
# "description" : "The preposition that connects this object and the layout element, ex. on the west wall, in the south-west corner... For corners, both walls are included!",
# "enum" : ["on", "in the corner"]
# },
# },
# "required" : ["reason", "layout_element_id", "preposition"]
# }
# },
# "objects_in_room" : {
# "type" : "array",
# "description" : "Scene Graph with the other placed objects in the room. Ex. The chair is in front of the desk, the plant is right of the bookshelf...",
# "items" : {
# "type" : "object",
# "properties" : {
# "reason" : {
# "type" : "array",
# "description": "The rationale for reasoning the object_id, preposition and is_adjacent of other placed objects to build scene graph in the room.
# Consider the Interior Architect's related reasoning step. For example: [... The cue stick wall rack needs to be easily accessible but also out of the way of the gameplay. It will be mounted on the north wall, right of the pool table,...]
# Therefore, {'object_id': 'pool_table_1', 'preposition': 'right of', 'is_adjacent': True}
# Please perform step-by-step reasoning before answering preposition and is_adjacent."
# },
# "object_id" : {
# "type" : "string",
# "description" : "The id of the object that this object is connected to, ex. bookshelf_1, plant_1..."
# },
# "preposition" : {
# "type" : "string",
# "description" : "The preposition that connects the new_object_id and object_id objects in the following format: "new_object_id" is "preposition" "object_id". Ex. lamp_1 is left of desk_1, table_1 is behind the bed_1, rug_1 is under desk_1...",
# "enum" : ["on", "left of", "right of", "in front", "behind", "under"]
# },
# "is_adjacent" : {
# "type" : "boolean",
# "description" : "Whether this object and the connected object are adjacent to each other, ex. an object on the desk is adjacent to the desk."
# }
# }
# },
# "required" : ["reason", "object_id", "preposition", "is_adjacent"]
# }
# },
# "required" : ["room_layout_elements", "objects_in_room"]
# }
# },
# "required" : ["new_object_id", "style", "material", "functionality", "color", "size_in_meters", "is_on_the_floor", "facing", "placement"]
# }
# }
# },
# "required" : ["objects_in_room"]
# }
# """
layout_corrector_schema = {
"corrected_object" : {
"type" : "object",
"properties" : {
"new_object_id": {
"type": "string",
"description" : "The id of the object, e.g. chair_1, table_1, bed_1, etc."
},
"is_on_the_floor" : {
"type" : "boolean",
"description" : "Whether the this object is touching the floor"
},
"facing" : {
"type" : "string",
"description" : "The id of the object is this object facing, this has to be an object_id! Ex. west_wall, bookshelf_1, desk_1..."
},
"placement" : {
"type" : "object",
"description" : "The placement of the object in the room as a scene graph",
"properties" : {
"room_layout_elements" : {
"type" : "array",
"description" : "Scene Graph with the room layout elements such as walls, floor or ceiling. Ex. The desk is centered on the south wall, the chair is in the south-west corner...",
"items" : {
"type" : "object",
"properties" : {
"layout_element_id" : {
"type" : "string",
"description" : "The id of the layout element that this object is connected to, ex. south_wall, west_wall, ceiling...",
"enum" : ["south_wall", "north_wall", "west_wall", "east_wall", "ceiling", "middle of the room"]
},
"preposition" : {
"type" : "string",
"description" : "The preposition that connects this object and the layout element, ex. on the west wall, in the corner...",
"enum" : ["on", "in the corner"]
}
},
"required" : ["layout_element_id", "preposition"]
}
},
"objects_in_room" : {
"type" : "array",
"description" : "Scene Graph with the other placed objects in the room. Ex. The chair is in front of the desk, the plant is right of the bookshelf...",
"items" : {
"type" : "object",
"properties" : {
"object_id" : {
"type" : "string",
"description" : "The id of the object that this object is connected to, ex. bookshelf_1, plant_1..."
},
"preposition" : {
"type" : "string",
"description" : "The preposition that connects this object and the connected object, ex. left of the desk, behind the plant, the rug is under the desk...",
"enum" : ["on", "left of", "right of", "in front", "behind", "under", "above"]
},
"is_adjacent" : {
"type" : "boolean",
"description" : "Whether this object and the connected object are adjacent to each other, ex. an object on the desk is adjacent to the desk."
}
}
}
}
},
"required" : ["room_layout_elements", "objects_in_room"]
}
}
}
}
deletion_schema = {
"object_to_delete" : "desk_1"
}
layout_refiner_schema = {
"type" : "object",
"properties":{
"children_objects" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"name_id" : {
"type" : "string"
},
"placement" : {
"type" : "object",
"properties" : {
"children_objects" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"name_id" : {
"type" : "string",
"description" : "The name_id of the other child object"
},
"preposition" : {
"type" : "string",
"description" : "The preposition that connects this object and the connected object, ex. left of the desk, behind the plant, the rug is under the desk...",
"enum" : ["on", "left of", "right of", "in front", "behind", "under", "above"]
},
"is_adjacent" : {
"type" : "boolean",
"description" : "Whether this object and the connected object are adjacent to each other, ex. an object on the desk is adjacent to the desk."
}
},
"required" : ["name_id", "preposition", "is_adjacent"]
}
}
},
"required" : ["children_objects"]
}
},
"required" : ["name_id", "placement"]
}
},
},
"required" : ["children_objects"]
}