Upload README.md with huggingface_hub
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182---license: mitlibrary_name: pytorchdatasets: - structlearning/isonetpp-benchmarktags: - graphs - subgraph-matching - graph-retrievaltask_categories: - graph-ml---
# ISONeT++ Model: gmn_embed on mutag
Trained on the **large** split.
## Usage
```python import torch import json from utils.tooling import make_read_only from subgraph_matching.model_handler import get_model from subgraph_matching.test import evaluate_model
from huggingface_hub import hf_hub_download
model_name = "gmn_embed" dataset_name = "mutag" REPO_ID = "structlearning/isonetpp-benchmark" # change if you fork/rename
def _load_module_from_hub(repo_id, filename, repo_type="dataset", module_name=None): path = hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type) name = module_name or filename.rsplit(".", 1)[0] spec = importlib.util.spec_from_file_location(name, path) mod = importlib.util.module_from_spec(spec) sys.modules[name] = mod spec.loader.exec_module(mod) return mod
dataset_mod = _load_module_from_hub(REPO_ID, "subiso_dataset.py", repo_type="dataset", module_name="subiso_dataset") loader = _load_module_from_hub(REPO_ID, "isonetpp_loader.py", repo_type="dataset", module_name="isonetpp_loader")
ds_test = loader.load_isonetpp_benchmark( repo_id=REPO_ID, mode="test", # "train" | "val" | "test" dataset_name="mutag" )
repo_id = f"structlearning/isonetpp-gmn_embed-mutag-large"
# Load config config = json.load(open(hf_hub_download(repo_id, "config.json"))) config = make_read_only(config)
# Load weights weights = hf_hub_download(repo_id, "pytorch_model.bin") state = torch.load(weights, weights_only=False)
# Load dataset ds_test = loader.load_isonetpp_benchmark(dataset_name="mutag", mode="test")
model = get_model( model_name=config.name, config=config.model_config, max_node_set_size=ds_test.max_node_set_size, max_edge_set_size=ds_test.max_edge_set_size, device="cuda" ) model.load_state_dict(state) model.to("cuda")
_, map_val = evaluate_model(model, ds_test) print(map_val)
``` README.mdAdded+82