IndradyumnaRoy commited on
Commit
7e503b5
·
verified ·
1 Parent(s): c2451fc

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +82 -0
README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: pytorch
4
+ datasets:
5
+ - structlearning/isonetpp-benchmark
6
+ tags:
7
+ - graphs
8
+ - subgraph-matching
9
+ - graph-retrieval
10
+ task_categories:
11
+ - graph-ml
12
+ ---
13
+
14
+
15
+ # ISONeT++ Model: isonetpp_node on aids
16
+
17
+ Trained on the **large** split.
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ import torch
23
+ import json
24
+ from utils.tooling import make_read_only
25
+ from subgraph_matching.model_handler import get_model
26
+ from subgraph_matching.test import evaluate_model
27
+
28
+
29
+ from huggingface_hub import hf_hub_download
30
+
31
+ model_name = "isonetpp_node"
32
+ dataset_name = "aids"
33
+
34
+ REPO_ID = "structlearning/isonetpp-benchmark" # change if you fork/rename
35
+
36
+ def _load_module_from_hub(repo_id, filename, repo_type="dataset", module_name=None):
37
+ path = hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type)
38
+ name = module_name or filename.rsplit(".", 1)[0]
39
+ spec = importlib.util.spec_from_file_location(name, path)
40
+ mod = importlib.util.module_from_spec(spec)
41
+ sys.modules[name] = mod
42
+ spec.loader.exec_module(mod)
43
+ return mod
44
+
45
+ dataset_mod = _load_module_from_hub(REPO_ID, "subiso_dataset.py", repo_type="dataset", module_name="subiso_dataset")
46
+ loader = _load_module_from_hub(REPO_ID, "isonetpp_loader.py", repo_type="dataset", module_name="isonetpp_loader")
47
+
48
+
49
+ ds_test = loader.load_isonetpp_benchmark(
50
+ repo_id=REPO_ID,
51
+ mode="test", # "train" | "val" | "test"
52
+ dataset_name="aids"
53
+ )
54
+
55
+ repo_id = f"structlearning/isonetpp-isonetpp_node-aids-large"
56
+
57
+ # Load config
58
+ config = json.load(open(hf_hub_download(repo_id, "config.json")))
59
+ config = make_read_only(config)
60
+
61
+ # Load weights
62
+ weights = hf_hub_download(repo_id, "pytorch_model.bin")
63
+ state = torch.load(weights, weights_only=False)
64
+
65
+ # Load dataset
66
+ ds_test = loader.load_isonetpp_benchmark(dataset_name="aids", mode="test")
67
+
68
+ model = get_model(
69
+ model_name=config.name,
70
+ config=config.model_config,
71
+ max_node_set_size=ds_test.max_node_set_size,
72
+ max_edge_set_size=ds_test.max_edge_set_size,
73
+ device="cuda"
74
+ )
75
+ model.load_state_dict(state)
76
+ model.to("cuda")
77
+
78
+ _, map_val = evaluate_model(model, ds_test)
79
+ print(map_val)
80
+
81
+ ```
82
+