Spaces:
Sleeping
Sleeping
fixes to paths
Browse files- inference.py +6 -3
inference.py
CHANGED
|
@@ -163,14 +163,17 @@ def preprocess_image(image_path: str, meta: dict) -> torch.Tensor:
|
|
| 163 |
|
| 164 |
|
| 165 |
# βββ Model Loader (singleton) ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 166 |
-
|
|
|
|
|
|
|
| 167 |
_model_cache = {}
|
| 168 |
|
| 169 |
-
def load_model(weights_path
|
| 170 |
if weights_path in _model_cache:
|
| 171 |
return _model_cache[weights_path]
|
| 172 |
|
| 173 |
-
meta_path
|
|
|
|
| 174 |
with open(meta_path) as f:
|
| 175 |
meta = json.load(f)
|
| 176 |
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
# βββ Model Loader (singleton) ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 166 |
+
weights_path = 'trainedmodels/Model.pth'
|
| 167 |
+
meta_path = 'trainedmodels/Model.json'
|
| 168 |
+
device = 'cpu'
|
| 169 |
_model_cache = {}
|
| 170 |
|
| 171 |
+
def load_model(weights_path, device, meta_path) -> tuple:
|
| 172 |
if weights_path in _model_cache:
|
| 173 |
return _model_cache[weights_path]
|
| 174 |
|
| 175 |
+
if meta_path is None:
|
| 176 |
+
meta_path = Path(weights_path).with_suffix(".json")
|
| 177 |
with open(meta_path) as f:
|
| 178 |
meta = json.load(f)
|
| 179 |
|