Spaces:
Sleeping
Sleeping
github-actions[bot]
commited on
Commit
·
200bf40
1
Parent(s):
206874e
Auto-sync from demo at Tue Jan 27 11:49:37 UTC 2026
Browse files
graphgen/models/generator/vqa_generator.py
CHANGED
|
@@ -106,7 +106,7 @@ class VQAGenerator(BaseGenerator):
|
|
| 106 |
{"text": v["question"], "image": v.get("img_path", "")}
|
| 107 |
],
|
| 108 |
},
|
| 109 |
-
{"from": "gpt", "value": v["answer"]},
|
| 110 |
]
|
| 111 |
}
|
| 112 |
for item in results
|
|
@@ -122,7 +122,10 @@ class VQAGenerator(BaseGenerator):
|
|
| 122 |
{"text": v["question"], "image": v.get("img_path", "")}
|
| 123 |
],
|
| 124 |
},
|
| 125 |
-
{
|
|
|
|
|
|
|
|
|
|
| 126 |
]
|
| 127 |
}
|
| 128 |
for item in results
|
|
|
|
| 106 |
{"text": v["question"], "image": v.get("img_path", "")}
|
| 107 |
],
|
| 108 |
},
|
| 109 |
+
{"from": "gpt", "value": [{"text": v["answer"]}]},
|
| 110 |
]
|
| 111 |
}
|
| 112 |
for item in results
|
|
|
|
| 122 |
{"text": v["question"], "image": v.get("img_path", "")}
|
| 123 |
],
|
| 124 |
},
|
| 125 |
+
{
|
| 126 |
+
"role": "assistant",
|
| 127 |
+
"content": [{"type": "text", "text": v["answer"]}],
|
| 128 |
+
},
|
| 129 |
]
|
| 130 |
}
|
| 131 |
for item in results
|
graphgen/models/partitioner/anchor_bfs_partitioner.py
CHANGED
|
@@ -37,9 +37,6 @@ class AnchorBFSPartitioner(BFSPartitioner):
|
|
| 37 |
**kwargs: Any,
|
| 38 |
) -> Iterable[Community]:
|
| 39 |
nodes = g.get_all_nodes() # List[tuple[id, meta]]
|
| 40 |
-
edges = g.get_all_edges() # List[tuple[u, v, meta]]
|
| 41 |
-
|
| 42 |
-
adj, _ = self._build_adjacency_list(nodes, edges)
|
| 43 |
|
| 44 |
anchors: Set[str] = self._pick_anchor_ids(nodes)
|
| 45 |
if not anchors:
|
|
@@ -55,7 +52,7 @@ class AnchorBFSPartitioner(BFSPartitioner):
|
|
| 55 |
if seed_node in used_n:
|
| 56 |
continue
|
| 57 |
comm_n, comm_e = self._grow_community(
|
| 58 |
-
seed_node,
|
| 59 |
)
|
| 60 |
if comm_n or comm_e:
|
| 61 |
yield Community(id=seed_node, nodes=comm_n, edges=comm_e)
|
|
@@ -77,7 +74,7 @@ class AnchorBFSPartitioner(BFSPartitioner):
|
|
| 77 |
@staticmethod
|
| 78 |
def _grow_community(
|
| 79 |
seed: str,
|
| 80 |
-
|
| 81 |
max_units: int,
|
| 82 |
used_n: set[str],
|
| 83 |
used_e: set[frozenset[str]],
|
|
@@ -85,7 +82,7 @@ class AnchorBFSPartitioner(BFSPartitioner):
|
|
| 85 |
"""
|
| 86 |
Grow a community from the seed node using BFS.
|
| 87 |
:param seed: seed node id
|
| 88 |
-
:param
|
| 89 |
:param max_units: maximum number of units (nodes + edges) in the community
|
| 90 |
:param used_n: set of used node ids
|
| 91 |
:param used_e: set of used edge keys
|
|
@@ -105,7 +102,7 @@ class AnchorBFSPartitioner(BFSPartitioner):
|
|
| 105 |
used_n.add(it)
|
| 106 |
comm_n.append(it)
|
| 107 |
cnt += 1
|
| 108 |
-
for nei in
|
| 109 |
e_key = frozenset((it, nei))
|
| 110 |
if e_key not in used_e:
|
| 111 |
queue.append((EDGE_UNIT, e_key))
|
|
|
|
| 37 |
**kwargs: Any,
|
| 38 |
) -> Iterable[Community]:
|
| 39 |
nodes = g.get_all_nodes() # List[tuple[id, meta]]
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
anchors: Set[str] = self._pick_anchor_ids(nodes)
|
| 42 |
if not anchors:
|
|
|
|
| 52 |
if seed_node in used_n:
|
| 53 |
continue
|
| 54 |
comm_n, comm_e = self._grow_community(
|
| 55 |
+
seed_node, g, max_units_per_community, used_n, used_e
|
| 56 |
)
|
| 57 |
if comm_n or comm_e:
|
| 58 |
yield Community(id=seed_node, nodes=comm_n, edges=comm_e)
|
|
|
|
| 74 |
@staticmethod
|
| 75 |
def _grow_community(
|
| 76 |
seed: str,
|
| 77 |
+
g: BaseGraphStorage,
|
| 78 |
max_units: int,
|
| 79 |
used_n: set[str],
|
| 80 |
used_e: set[frozenset[str]],
|
|
|
|
| 82 |
"""
|
| 83 |
Grow a community from the seed node using BFS.
|
| 84 |
:param seed: seed node id
|
| 85 |
+
:param g: graph storage
|
| 86 |
:param max_units: maximum number of units (nodes + edges) in the community
|
| 87 |
:param used_n: set of used node ids
|
| 88 |
:param used_e: set of used edge keys
|
|
|
|
| 102 |
used_n.add(it)
|
| 103 |
comm_n.append(it)
|
| 104 |
cnt += 1
|
| 105 |
+
for nei in g.get_neighbors(it):
|
| 106 |
e_key = frozenset((it, nei))
|
| 107 |
if e_key not in used_e:
|
| 108 |
queue.append((EDGE_UNIT, e_key))
|