Instructions to use bestak/uav-navigation-hasp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use bestak/uav-navigation-hasp with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="bestak/uav-navigation-hasp", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
Upload model 1nt3s4ta (group=exp1.3-dqn_2)
Browse files- README.md +22 -3
- inference.py +16 -0
README.md
CHANGED
|
@@ -31,6 +31,10 @@ and land-use grid environments.
|
|
| 31 |
| **Max steps / episode** | 300 |
|
| 32 |
| **Frame stack** | 4 |
|
| 33 |
| **Seed** | 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
| **Arena size** | 60×60 cells |
|
| 35 |
| **Camera size** | 11×11 cells |
|
| 36 |
|
|
@@ -56,10 +60,10 @@ The following results represent the mean performance over 500 deterministic vali
|
|
| 56 |
|
| 57 |
## Standalone Inference (no information-driven-uav-navigation package required)
|
| 58 |
|
| 59 |
-
Install the minimal deps:
|
| 60 |
|
| 61 |
```bash
|
| 62 |
-
pip install stable-baselines3
|
| 63 |
```
|
| 64 |
|
| 65 |
```python
|
|
@@ -76,10 +80,25 @@ mod = importlib.util.module_from_spec(spec)
|
|
| 76 |
sys.modules["_fe"] = mod
|
| 77 |
spec.loader.exec_module(mod)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# 2. Load the model -- inject the extractor class so cloudpickle can resolve it
|
| 80 |
model = DQN.load(
|
| 81 |
hf_hub_download(REPO_ID, "best_model.zip"),
|
| 82 |
-
custom_objects={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
device="cpu",
|
| 84 |
)
|
| 85 |
|
|
|
|
| 31 |
| **Max steps / episode** | 300 |
|
| 32 |
| **Frame stack** | 4 |
|
| 33 |
| **Seed** | 0 |
|
| 34 |
+
| **Python (training)** | 3.11.14 |
|
| 35 |
+
| **stable-baselines3** | 2.2.1 |
|
| 36 |
+
| **PyTorch** | 2.10.0 |
|
| 37 |
+
| **Gymnasium** | 0.29.1 |
|
| 38 |
| **Arena size** | 60×60 cells |
|
| 39 |
| **Camera size** | 11×11 cells |
|
| 40 |
|
|
|
|
| 60 |
|
| 61 |
## Standalone Inference (no information-driven-uav-navigation package required)
|
| 62 |
|
| 63 |
+
Install the minimal deps (versions match the training environment):
|
| 64 |
|
| 65 |
```bash
|
| 66 |
+
pip install "stable-baselines3==2.2.1" "torch==2.10.0" "gymnasium==0.29.1" huggingface-hub
|
| 67 |
```
|
| 68 |
|
| 69 |
```python
|
|
|
|
| 80 |
sys.modules["_fe"] = mod
|
| 81 |
spec.loader.exec_module(mod)
|
| 82 |
|
| 83 |
+
# 1b. Stub out drone_navigation so cloudpickle can resolve ALL saved class references
|
| 84 |
+
# (lr_schedule, policy_kwargs, etc.) without the package being installed.
|
| 85 |
+
import types as _types
|
| 86 |
+
for _name in ["drone_navigation", "drone_navigation.models",
|
| 87 |
+
"drone_navigation.models.feature_extractor_aerial",
|
| 88 |
+
"drone_navigation.models.feature_extractor_landuse"]:
|
| 89 |
+
sys.modules.setdefault(_name, _types.ModuleType(_name))
|
| 90 |
+
sys.modules["drone_navigation.models.feature_extractor_landuse"].LanduseFeaturesExtractor = mod.LanduseFeaturesExtractor
|
| 91 |
+
|
| 92 |
# 2. Load the model -- inject the extractor class so cloudpickle can resolve it
|
| 93 |
model = DQN.load(
|
| 94 |
hf_hub_download(REPO_ID, "best_model.zip"),
|
| 95 |
+
custom_objects={
|
| 96 |
+
"features_extractor_class": mod.LanduseFeaturesExtractor,
|
| 97 |
+
# schedule lambdas may fail to unpickle across Python versions; supply
|
| 98 |
+
# constant fallbacks (values are irrelevant for inference)
|
| 99 |
+
"lr_schedule": lambda _: 3e-4,
|
| 100 |
+
"clip_range": lambda _: 0.2,
|
| 101 |
+
},
|
| 102 |
device="cpu",
|
| 103 |
)
|
| 104 |
|
inference.py
CHANGED
|
@@ -28,6 +28,7 @@ REPO_ID = "bestak/uav-navigation-hasp"
|
|
| 28 |
|
| 29 |
def _load_feature_extractor(repo_id: str):
|
| 30 |
"""Dynamically load LanduseFeaturesExtractor from the HF repo."""
|
|
|
|
| 31 |
from huggingface_hub import hf_hub_download
|
| 32 |
|
| 33 |
fe_path = hf_hub_download(repo_id, "feature_extractor.py")
|
|
@@ -35,6 +36,21 @@ def _load_feature_extractor(repo_id: str):
|
|
| 35 |
mod = importlib.util.module_from_spec(spec)
|
| 36 |
sys.modules["_drone_nav_fe"] = mod # register so cloudpickle can find it
|
| 37 |
spec.loader.exec_module(mod)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
return mod.LanduseFeaturesExtractor
|
| 39 |
|
| 40 |
|
|
|
|
| 28 |
|
| 29 |
def _load_feature_extractor(repo_id: str):
|
| 30 |
"""Dynamically load LanduseFeaturesExtractor from the HF repo."""
|
| 31 |
+
import types
|
| 32 |
from huggingface_hub import hf_hub_download
|
| 33 |
|
| 34 |
fe_path = hf_hub_download(repo_id, "feature_extractor.py")
|
|
|
|
| 36 |
mod = importlib.util.module_from_spec(spec)
|
| 37 |
sys.modules["_drone_nav_fe"] = mod # register so cloudpickle can find it
|
| 38 |
spec.loader.exec_module(mod)
|
| 39 |
+
|
| 40 |
+
# Stub out drone_navigation so cloudpickle can deserialise ALL objects stored
|
| 41 |
+
# in the zip (lr_schedule, policy_kwargs, etc.) without needing the package.
|
| 42 |
+
for _name in [
|
| 43 |
+
"drone_navigation",
|
| 44 |
+
"drone_navigation.models",
|
| 45 |
+
"drone_navigation.models.feature_extractor_aerial",
|
| 46 |
+
"drone_navigation.models.feature_extractor_landuse",
|
| 47 |
+
]:
|
| 48 |
+
sys.modules.setdefault(_name, types.ModuleType(_name))
|
| 49 |
+
# Wire the loaded class to the original pickle path so cloudpickle resolves it.
|
| 50 |
+
sys.modules["drone_navigation.models.feature_extractor_landuse"].LanduseFeaturesExtractor = (
|
| 51 |
+
mod.LanduseFeaturesExtractor
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
return mod.LanduseFeaturesExtractor
|
| 55 |
|
| 56 |
|