Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import snapshot_download
|
| 2 |
+
import importlib.util, sys, os, torch
|
| 3 |
+
|
| 4 |
+
# pull everything from your model repo
|
| 5 |
+
local_dir = snapshot_download(repo_id="c1tr0n75/VoxelPathFinder")
|
| 6 |
+
|
| 7 |
+
# import your model code dynamically
|
| 8 |
+
py_path = os.path.join(local_dir, "pathfinding_nn.py")
|
| 9 |
+
spec = importlib.util.spec_from_file_location("pathfinding_nn", py_path)
|
| 10 |
+
mod = importlib.util.module_from_spec(spec); spec.loader.exec_module(mod)
|
| 11 |
+
PathfindingNetwork = mod.PathfindingNetwork
|
| 12 |
+
|
| 13 |
+
# load weights
|
| 14 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 15 |
+
model = PathfindingNetwork().to(device).eval()
|
| 16 |
+
ckpt = torch.load(os.path.join(local_dir, "final_model.pth"), map_location=device)
|
| 17 |
+
state = ckpt.get("model_state_dict", ckpt)
|
| 18 |
+
model.load_state_dict(state)
|