Commit 0c847dde authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Removed deprecated pysptools implementation of SAM classifier.

parent 12da92c4
Pipeline #3243 failed with stage
in 17 minutes and 5 seconds
......@@ -11,7 +11,6 @@ from multiprocessing import Pool
from tqdm import tqdm
from sklearn.neighbors import KNeighborsClassifier, NearestCentroid
from sklearn.preprocessing import MaxAbsScaler
from pysptools.classification import SAM
from geoarray import GeoArray
......@@ -87,36 +86,6 @@ class kNN_Classifier(_ImageClassifier):
return tilepos, self.clf.predict(spectra).reshape(*tileimdata.shape[:2])
class SAM_Classifier_OLD(_ImageClassifier):
def __init__(self, train_spectra, threshold=0.1, CPUs=1):
# type: (np.ndarray, Union[np.ndarray, List[int]], Union[int, None]) -> None
super(SAM_Classifier_OLD, self).__init__(train_spectra, np.array(range(train_spectra.shape[0])), CPUs=CPUs)
self.clf = SAM()
self.threshold = threshold
def _predict(self, tilepos, tileimdata):
return tilepos, self.clf.classify(tileimdata, self.train_spectra, self.threshold)
def classify(self, image_cube, nodataVal=None, tiledims=(1000, 1000), mask=None):
image_cube_gA = GeoArray(image_cube, nodata=nodataVal)
# avoid "RuntimeWarning: invalid value encountered in less" during SAM.classify()
if mask:
image_cube_gA[mask] = np.max(image_cube_gA)
elif nodataVal is not None:
image_cube_gA[image_cube_gA[:] == nodataVal] = np.max(image_cube_gA)
else:
image_cube_gA[image_cube_gA.mask_nodata.astype(np.int8) == 0] = np.max(image_cube_gA)
cmap = super(SAM_Classifier_OLD, self).classify(image_cube_gA, nodataVal=nodataVal, tiledims=tiledims)
if mask:
cmap[mask] = -9999
return cmap
class SAM_Classifier(_ImageClassifier):
def __init__(self, train_spectra, CPUs=1):
# type: (np.ndarray, Union[int, None]) -> None
......
......@@ -21,4 +21,3 @@ redis
retools
redis-semaphore
psutil
pysptools
......@@ -19,7 +19,7 @@ requirements = [
'matplotlib', 'numpy', 'scikit-learn', 'scipy', 'gdal', 'pyproj', 'shapely', 'ephem', 'pyorbital', 'dill', 'pytz',
'pandas', 'numba', 'spectral>=0.16', 'geopandas', 'iso8601', 'pyinstrument', 'geoalchemy2', 'sqlalchemy',
'psycopg2', 'py_tools_ds>=0.12.4', 'geoarray>=0.8.0', 'arosics>=0.8.7', 'six', 'tqdm', 'jsmin', 'cerberus',
'nested_dict', 'openpyxl', 'timeout_decorator', 'redis', 'retools', 'redis-semaphore', 'psutil', 'pysptools'
'nested_dict', 'openpyxl', 'timeout_decorator', 'redis', 'retools', 'redis-semaphore', 'psutil',
# spectral<0.16 has some problems with writing signed integer 8bit data
# fmask # conda install -c conda-forge python-fmask
# 'pyhdf', # conda install --yes -c conda-forge pyhdf
......
......@@ -79,7 +79,6 @@ dependencies:
- retools
- redis-semaphore
- psutil
- pysptools
- py_tools_ds>=0.12.4
- geoarray>=0.8.0
- arosics>=0.8.7
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment