-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_all.py
More file actions
29 lines (22 loc) · 907 Bytes
/
convert_all.py
File metadata and controls
29 lines (22 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# FitLayout - Python GNN Demo
# (c) 2026 Radek Burget <burgetr@fit.vut.cz>
# This script demonstrates how to use the FitLayout client library to create graph representations.
# It just creates graph representations for all AreaTree objects in a repository and saves them locally
# in pytorch format.
import os
import torch
from torch_geometric.data import Data
from flclient import default_prefix_string, R, SEGM
from graph.creator import AreaGraphCreator, ChunkGraphCreator
from graph.dataset import RemoteDataset
from config import fl, relations, tags
# Create the graph creator
gc = AreaGraphCreator(fl, relations, tags)
# Examine the dataset
dataset = RemoteDataset(gc, limit=None)
# Create data/graphs directory if it does not exist
if not os.path.exists("data/graphs"):
os.makedirs("data/graphs")
for i, data in enumerate(dataset):
print(i)
torch.save(data, f"data/graphs/g{i}.pt")