MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __call__

Method __call__

monai/apps/deepgrow/interaction.py:57–90  ·  view source on GitHub ↗
(self, engine: SupervisedTrainer | SupervisedEvaluator, batchdata: dict[str, torch.Tensor])

Source from the content-addressed store, hash-verified

55 self.key_probability = key_probability
56
57 def __call__(self, engine: SupervisedTrainer | SupervisedEvaluator, batchdata: dict[str, torch.Tensor]) -> dict:
58 if batchdata is None:
59 raise ValueError("Must provide batch data for current iteration.")
60
61 for j in range(self.max_interactions):
62 inputs, _ = engine.prepare_batch(batchdata)
63 inputs = inputs.to(engine.state.device)
64
65 engine.fire_event(IterationEvents.INNER_ITERATION_STARTED)
66
67 engine.network.eval()
68 with torch.no_grad():
69 if engine.amp:
70 with torch.autocast("cuda"):
71 predictions = engine.inferer(inputs, engine.network)
72 else:
73 predictions = engine.inferer(inputs, engine.network)
74
75 engine.fire_event(IterationEvents.INNER_ITERATION_COMPLETED)
76
77 batchdata.update({CommonKeys.PRED: predictions})
78
79 # decollate batch data to execute click transforms
80 batchdata_list = decollate_batch(batchdata, detach=True)
81 for i in range(len(batchdata_list)):
82 batchdata_list[i][self.key_probability] = (
83 (1.0 - ((1.0 / self.max_interactions) * j)) if self.train else 1.0
84 )
85 batchdata_list[i] = self.transforms(batchdata_list[i])
86
87 # collate list into a batch for next round interaction
88 batchdata = list_data_collate(batchdata_list)
89
90 return engine._iteration(engine, batchdata) # type: ignore[arg-type]

Callers

nothing calls this directly

Calls 5

decollate_batchFunction · 0.90
list_data_collateFunction · 0.90
transformsMethod · 0.80
updateMethod · 0.45
_iterationMethod · 0.45

Tested by

no test coverage detected