rmaphoh / RETFound_MAE

RETFound - A foundation model for retinal image
Other
311 stars 63 forks source link

evaluate problem #29

Closed dyccyber closed 6 days ago

dyccyber commented 3 weeks ago

code: class Config:

Parameters based on provided command line

eval = True
batch_size = 16
model = 'vit_large_patch16'
epochs = 50
blr = 5e-3
layer_decay = 0.65
weight_decay = 0.05
drop_path = 0.2
nb_classes = 5
data_path = './IDRiD_data/'
task = './internal_IDRiD/'
resume = './finetune_task/checkpoint-best.pth'
input_size = 224
output_dir = './output_dir'
device = 'cuda'
seed = 0
num_workers = 10
pin_mem = True

def main(cfg): print('Job directory:', os.path.dirname(os.path.realpath(file))) print("Configuration:", vars(cfg))

device = torch.device(cfg.device)

# Fix the seed for reproducibility
seed = cfg.seed
torch.manual_seed(seed)
np.random.seed(seed)

cudnn.benchmark = True

dataset_test = build_dataset(is_train='test', args=cfg)

data_loader_test = torch.utils.data.DataLoader(
    dataset_test,
    batch_size=cfg.batch_size,
    num_workers=cfg.num_workers,
    pin_memory=cfg.pin_mem,
    drop_last=False
)

model = models_vit.__dict__[cfg.model](
    img_size=cfg.input_size,
    num_classes=cfg.nb_classes,
    drop_path_rate=cfg.drop_path,
    global_pool=True,
)
model.to(device)

misc.load_model(args=cfg, model_without_ddp=model, optimizer=None, loss_scaler=None)
print(model)
test_stats, auc_roc = evaluate(data_loader_test, model, device, cfg.task, epoch=0, mode='test', num_class=cfg.nb_classes)
print(f"Test Stats: {test_stats}, AUC-ROC: {auc_roc}")

i want to test evaluate and use the given checkpoint and data(idrid) but when i run the code ,get: 屏幕截图 2024-06-12 112608

hao203 commented 1 week ago

I have the same problem.

dyccyber commented 6 days ago

image code version