Code and dataset for CubiGraph5K: Organizational Graph Generation for Structured Architectural Floor Plan Dataset (CAADRIA 2021)
This dataset is a collection of graph representations generated by the proposed algorithms, using the floor plans in the popular CubiCasa5K dataset as inputs. The aim of this contribution is to provide a matching dataset that could be used to train neural networks on enhanced floor plan parsing, analysis and generation in future research.
- Python3
- BeautifulSoup
- Shapely
- Calculate room relations and generate graph
# Folder to store SVG model, provided in CubiCasa5K as well
file_path = '/high_quality_architectural/41/'.strip('/')
# Folder of CubiCasa5K data
input_location = 'cubicasa5k'
with open(os.path.join(input_location, file_path, 'model.svg')) as f:
content = f.read()
soup = BeautifulSoup(content, 'lxml')
# Create a Plan instance using SVG
plan = Plan(soup.find('svg'))
# Calculate room relation
plan.generate_room_relation()
# See graph as adjacency list
# 0 - Not-connect, 1 - Adjacent, 2 - Door-connect
print(plan.get_adjacency_list())
- Generate graph diagram as SVG
# Folder where you want to store the output graph diagram
output_location = 'cubigraph5k'
with open(os.path.join(output_location, 'svg', 'graph.svg'), 'w') as output:
output.write(str(plan.generate_relation_svg()))
- View all room instances as list
print(list(plan.name2room.keys()))
# Output: ['Kitchen_1', 'Dining_1', 'Entry_1', 'LivingRoom_1', 'Bedroom_1', 'Garage_1', 'Bedroom_2', 'Bedroom_3', 'Bath_1', 'Storage_1', 'Storage_2', 'Other_1', 'Bath_2', 'Entry_2']
- Calculate shortest path between two rooms
print(plan.shortest_paths_between_two_rooms(start='Entry_2', end='Bath_1'))
# Output: [['Entry_2', 'Entry_1', 'LivingRoom_1', 'Bedroom_3', 'Bath_1']]
You can download original CubiCasa5K dataset from here and extract the .zip file to /cubicasa5k
folder.
The corresponding CubiGraph5K dataset is in /dataset/data.json
.
Example: Plan 41
{
"41": { # plan id, same as CubiCasa5K
"file_path": "/high_quality_architectural/41/", # file path in CubiCasa5K
"room_type_count": { # number of instances
"Kitchen": 1,
"Dining": 1,
"Entry": 2,
"LivingRoom": 1,
"Bedroom": 3,
"Garage": 1,
"Bath": 2,
"Storage": 2,
"Other": 1
},
"graph": { # graph as adjacency list, 1 - adjacent, 2 - door-connect
"Kitchen_1": {"Dining_1": 1, "Storage_2": 2},
"Dining_1": {"Kitchen_1": 1, "Entry_1": 1, "LivingRoom_1": 1},
"Entry_1": {"Dining_1": 1, "LivingRoom_1": 1, "Bedroom_1": 2,
"Bedroom_2": 2, "Bath_2": 2, "Entry_2": 2},
"LivingRoom_1": {"Dining_1": 1, "Entry_1": 1, "Bedroom_3": 2},
"Bedroom_1": {"Entry_1": 2},
"Garage_1": {},
"Bedroom_2": {"Entry_1": 2, "Bath_2": 2},
"Bedroom_3": {"LivingRoom_1": 2, "Bath_1": 2, "Storage_1": 2},
"Bath_1": {"Bedroom_3": 2, "Storage_2": 2, "Other_1": 2},
"Storage_1": {"Bedroom_3": 2},
"Storage_2": {"Kitchen_1": 2, "Bath_1": 2},
"Other_1": {"Bath_1": 2},
"Bath_2": {"Entry_1": 2, "Bedroom_2": 2},
"Entry_2": {"Entry_1": 2}
},
"diameter": 5 # other attributes
},
...
}
The file paths of floor plans with invalid Shapely geomety or multiple stories are listed in /dataset/invalid.txt
and dataset/multistory.txt
for reference.