unload method
Unload the currently-loaded diffusion model.
Implementation
Future<void> unload() async {
_ensureInitialized();
final modelId = currentModelId ??
(await RunAnywhereModelLifecycle.shared.current(
model_pb.CurrentModelRequest(category: _diffusionCategory),
))
.modelId;
if (modelId.isEmpty) return;
final result = await RunAnywhereModelLifecycle.shared.unload(
model_pb.ModelUnloadRequest(
modelId: modelId,
category: _diffusionCategory,
),
);
if (!result.success) {
throw SDKException.invalidState(
result.errorMessage.isNotEmpty
? result.errorMessage
: 'Diffusion lifecycle unload failed',
);
}
}