akagtag commited on
Commit
37eb3a1
·
1 Parent(s): 969e16d

Lazy load SSTGNN optional dependencies

Browse files
Files changed (1) hide show
  1. modules/m3_sstgnn.py +6 -4
modules/m3_sstgnn.py CHANGED
@@ -2,10 +2,6 @@ from __future__ import annotations
2
 
3
  import torch
4
  from huggingface_hub import hf_hub_download
5
- from torch_geometric.data import Batch
6
-
7
- from modules.sstgnn_model import SSTGNN
8
- from utils.graph import video_to_graph
9
 
10
 
11
  class SSTGNNModule:
@@ -19,6 +15,8 @@ class SSTGNNModule:
19
  filename="sstgnn_best.pt",
20
  cache_dir=cache_dir,
21
  )
 
 
22
  self.model = SSTGNN(patch_feat_dim=8, hidden_dim=128, num_frames=32)
23
  self.model.load_state_dict(torch.load(ckpt_path, map_location="cpu"))
24
  self.model.eval()
@@ -45,6 +43,10 @@ class SSTGNNModule:
45
  if not self.available:
46
  return {"s3": 0.5, "vram_mb": 0, "note": f"module_unavailable: {self.load_error}"}
47
 
 
 
 
 
48
  graph = video_to_graph(video_path, patch_size=16, max_frames=32)
49
  batch = Batch.from_data_list([graph.to(self.device)])
50
  logits = self.model(batch)
 
2
 
3
  import torch
4
  from huggingface_hub import hf_hub_download
 
 
 
 
5
 
6
 
7
  class SSTGNNModule:
 
15
  filename="sstgnn_best.pt",
16
  cache_dir=cache_dir,
17
  )
18
+ from modules.sstgnn_model import SSTGNN
19
+
20
  self.model = SSTGNN(patch_feat_dim=8, hidden_dim=128, num_frames=32)
21
  self.model.load_state_dict(torch.load(ckpt_path, map_location="cpu"))
22
  self.model.eval()
 
43
  if not self.available:
44
  return {"s3": 0.5, "vram_mb": 0, "note": f"module_unavailable: {self.load_error}"}
45
 
46
+ from torch_geometric.data import Batch
47
+
48
+ from utils.graph import video_to_graph
49
+
50
  graph = video_to_graph(video_path, patch_size=16, max_frames=32)
51
  batch = Batch.from_data_list([graph.to(self.device)])
52
  logits = self.model(batch)