Spaces:
Paused
Paused
Update inference.py
Browse files- inference.py +17 -1
inference.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
-
import torch
|
| 4 |
import joblib
|
| 5 |
import argparse
|
| 6 |
import os
|
|
@@ -8,6 +8,22 @@ import glob
|
|
| 8 |
from sklearn.multioutput import MultiOutputRegressor
|
| 9 |
from tabpfn_extensions.post_hoc_ensembles.sklearn_interface import AutoTabPFNRegressor
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
class TabPFNEnsemblePredictor:
|
| 12 |
"""
|
| 13 |
A class to load an ensemble of TabPFN models and generate averaged predictions.
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import numpy as np
|
| 3 |
+
# import torch
|
| 4 |
import joblib
|
| 5 |
import argparse
|
| 6 |
import os
|
|
|
|
| 8 |
from sklearn.multioutput import MultiOutputRegressor
|
| 9 |
from tabpfn_extensions.post_hoc_ensembles.sklearn_interface import AutoTabPFNRegressor
|
| 10 |
|
| 11 |
+
import torch
|
| 12 |
+
|
| 13 |
+
# Give torch.classes a benign __path__ so Streamlit won't trigger __getattr__.
|
| 14 |
+
try:
|
| 15 |
+
setattr(torch.classes, "__path__", [])
|
| 16 |
+
except Exception:
|
| 17 |
+
# Fallback wrapper if direct setattr isn't allowed in your build
|
| 18 |
+
class _TorchClassesWrapper:
|
| 19 |
+
def __init__(self, obj):
|
| 20 |
+
self._obj = obj
|
| 21 |
+
self.__path__ = []
|
| 22 |
+
def __getattr__(self, name):
|
| 23 |
+
return getattr(self._obj, name)
|
| 24 |
+
torch.classes = _TorchClassesWrapper(torch.classes)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
class TabPFNEnsemblePredictor:
|
| 28 |
"""
|
| 29 |
A class to load an ensemble of TabPFN models and generate averaged predictions.
|