def test_produce_when_inference_model_moco(): test_frame = load_frame() rsp = RemoteSensingPretrainedPrimitive( hyperparams=rs_hp( rs_hp.defaults(), inference_model = 'moco', use_columns = [1], ), volumes = {'amdim_weights': amdim_path, 'moco_weights': moco_path}, ) global feature_df feature_df = rsp.produce(inputs=test_frame).value _test_output_df(test_frame, feature_df, 2048)
def test_produce_when_inference_model_moco_decompress(): test_frame = load_frame(compress_data = True) rsp = RemoteSensingPretrainedPrimitive( hyperparams=rs_hp( rs_hp.defaults(), inference_model = 'moco', use_columns = [1], decompress_data = True, ), volumes = {'amdim_weights': amdim_path, 'moco_weights': moco_path}, ) decompress_feature_df = rsp.produce(inputs=test_frame).value _test_output_df(test_frame, decompress_feature_df, 2048) assert decompress_feature_df.equals(feature_df)
def test_big_earthnet(): train_inputs, labels = load_big_earthnet() featurizer = RemoteSensingPretrainedPrimitive(hyperparams=rs_hp( rs_hp.defaults(), inference_model='moco', use_columns=[0], ), volumes={ 'amdim_weights': amdim_path, 'moco_weights': moco_path }) features = featurizer.produce(inputs=train_inputs).value features.to_pickle("dummy.pkl") # features = pd.read_pickle("dummy.pkl") iterative_labeling(features, labels)
def load_inputs(): fnames = sorted(glob('/test_data/bigearth-100-single/*/*.tif')) imnames = sorted(list(set(['_'.join(f.split('_')[:-1]) for f in fnames]))) imgs = [load_patch(img_path).astype(np.float32) for img_path in imnames] imgs_df = pd.DataFrame({'image_col': imgs, 'dummy_idx': range(len(imgs))}) y = [i.split('/')[3] for i in imnames] tgts_df = pd.DataFrame({'target': y}) return (d3m_DataFrame(imgs_df), d3m_DataFrame(tgts_df)) train_inputs, labels = load_inputs() featurizer = RemoteSensingPretrainedPrimitive(hyperparams=rs_hp( rs_hp.defaults(), inference_model='moco', use_columns=[0], pool_features=False), volumes={ 'amdim_weights': amdim_path, 'moco_weights': moco_path }) features = featurizer.produce(inputs=train_inputs).value features = features.drop(columns='dummy_idx') # features.to_pickle("dummy.pkl") # labels.to_pickle("labels.pkl") # features = pd.read_pickle("dummy.pkl") # labels = pd.read_pickle("labels.pkl") def test_fit():