UNet

internal class UNet(val deviceNNAPIFlagProvider: DeviceNNAPIFlagProvider, val ortEnvironmentProvider: OrtEnvironmentProvider, val fileProviderDescriptor: FileProviderDescriptor, val localModelIdProvider: LocalModelIdProvider, val preferenceManager: PreferenceManager)(source)

Coordinates UNet behavior in the SDAI ONNX local diffusion feature layer.

Author

Dmitriy Moroz

Constructors

Link copied to clipboard
constructor(deviceNNAPIFlagProvider: DeviceNNAPIFlagProvider, ortEnvironmentProvider: OrtEnvironmentProvider, fileProviderDescriptor: FileProviderDescriptor, localModelIdProvider: LocalModelIdProvider, preferenceManager: PreferenceManager)

Types

Link copied to clipboard
interface Callback

Defines the Callback contract for the SDAI ONNX local diffusion feature layer.

Properties

Link copied to clipboard
private var callback: UNet.Callback?

Exposes the callback value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private var decoder: VaeDecoder?

Exposes the decoder value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard

Exposes the deviceNNAPIFlagProvider value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard

Exposes the fileProviderDescriptor value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private var height: Int

Exposes the height value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard

Exposes the localModelIdProvider value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard

Exposes the ortEnvironmentProvider value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard

Exposes the preferenceManager value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private val random: Random

Exposes the random value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private var session: OrtSession?

Exposes the session value used by the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private var width: Int

Exposes the width value used by the SDAI ONNX local diffusion feature layer.

Functions

Link copied to clipboard
fun close()

Executes the close step in the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private fun createUNetModelInput(encoderHiddenStates: OnnxTensor, sample: OnnxTensor, timeStep: OnnxTensor): Map<String, OnnxTensor>

Creates the SDAI value produced by createUNetModelInput.

Link copied to clipboard

Executes the decode step in the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private fun generateLatentSample(batchSize: Int, height: Int, width: Int, seed: Long, initNoiseSigma: Float): LocalDiffusionTensor<*>

Executes the generateLatentSample step in the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
fun inference(seedNum: Long, numInferenceSteps: Int, textEmbeddings: OnnxTensor, guidanceScale: Double, batchSize: Int, width: Int, height: Int)

Executes the inference step in the SDAI ONNX local diffusion feature layer.

Link copied to clipboard

Executes the initialize step in the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
private fun performGuidance(noisePrediction: Array3D<FloatArray>, noisePredictionText: Array3D<FloatArray>, guidanceScale: Double)

Executes the performGuidance step in the SDAI ONNX local diffusion feature layer.

Link copied to clipboard
fun setCallback(callback: UNet.Callback?)

Executes the setCallback step in the SDAI ONNX local diffusion feature layer.