forked from Kotlin/kotlindl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add api to create OnnxInferenceModel from Byte array representing an …
…ONNX model (Kotlin#415)
- Loading branch information
1 parent
4c934df
commit c17a650
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
examples/src/test/kotlin/examples/onnx/ModelLoadingTestSuite.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package examples.onnx | ||
|
||
import examples.transferlearning.getFileFromResource | ||
import org.jetbrains.kotlinx.dl.api.inference.onnx.OnnxInferenceModel | ||
import org.jetbrains.kotlinx.dl.api.inference.onnx.executionproviders.ExecutionProvider.CPU | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertDoesNotThrow | ||
import java.io.File | ||
|
||
class ModelLoadingTestSuite { | ||
@Test | ||
fun testLoadingModelFromBytes() { | ||
val lgbmModel: File = getFileFromResource("models/onnx/lgbmSequenceOutput.onnx") | ||
val bytes = lgbmModel.readBytes() | ||
|
||
assertDoesNotThrow { | ||
val model = OnnxInferenceModel(bytes) | ||
model.initializeWith(CPU()) | ||
model.close() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters