Skip to content

Commit

Permalink
[Example] Style transfer inference ONNX model using ml-service API.
Browse files Browse the repository at this point in the history
Add appsrc-pipeline based conf file for onnx-example.

Signed-off-by: Suyeon Kim <[email protected]>
  • Loading branch information
yeonykim2 authored and jaeyun-jung committed May 27, 2024
1 parent 085d20f commit 4efdd5b
Show file tree
Hide file tree
Showing 15 changed files with 1,265 additions and 0 deletions.
700 changes: 700 additions & 0 deletions Tizen.native/OnnxStyleTransferPipeline/.cproject

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Tizen.native/OnnxStyleTransferPipeline/.exportMap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
global: main;
_IO_*;
local: *;
};
46 changes: 46 additions & 0 deletions Tizen.native/OnnxStyleTransferPipeline/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OnnxStyleTransferPipeline</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<filteredResources>
<filter>
<id>1716767357612</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
</matcher>
</filter>
<filter>
<id>1716767357614</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-project_def.prop</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
12 changes: 12 additions & 0 deletions Tizen.native/OnnxStyleTransferPipeline/.tproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tproject xmlns="http://www.tizen.org/tproject">
<platforms>
<platform>
<name>tizen-8.0</name>
</platform>
</platforms>
<package>
<blacklist/>
<resFallback autoGen="true"/>
</package>
</tproject>
17 changes: 17 additions & 0 deletions Tizen.native/OnnxStyleTransferPipeline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Style Transfer Onnx
...

# Style Transfer Onnx Sample App with NNStreamer Pipeline C-API
Tizen Native App with NNStreamer Piepeline API

## Description
* This is a sample application of Tizen Native.
* If you want to run it on your device, Tizen 9.0 or higher is required.
* If you want to run it on Tizen 8.0 devices, you need to install the latest packages of nnstreamer-onnxruntime and machine-learning-service.
* About details of NNStreamer, please check [this page](https://docs.tizen.org/application/native/guides/machine-learning/machine-learning-inference).
* The applied ONNX model file from [here](https://github.com/onnx/models/blob/main/validated/vision/style_transfer/fast_neural_style/README.md).

## Result
<img src="./before.png" width="320"> <img src="./after.png" width="320">

Binary file added Tizen.native/OnnxStyleTransferPipeline/after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @file onnxstyletransferpipeline.h
* @date 27 May 2024
* @brief TIZEN Native Example App with NNStreamer/C-API.
* @see https://github.com/nnstreamer/nnstreamer
* @author Suyeon Kim <[email protected]>
* @bug No known bugs except for NYI items
*/

#ifndef __onnxstyletransferpipeline_H__
#define __onnxstyletransferpipeline_H__

#include <app.h>
#include <Elementary.h>
#include <system_settings.h>
#include <efl_extension.h>
#include <dlog.h>

#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "onnxstyletransferpipeline"

#if !defined(PACKAGE)
#define PACKAGE "org.example.onnxstyletransferpipeline"
#endif

#endif /* __onnxstyletransferpipeline_H__ */
11 changes: 11 additions & 0 deletions Tizen.native/OnnxStyleTransferPipeline/project_def.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
APPNAME = onnxstyletransferpipeline

type = app
profile = tizen-8.0

USER_SRCS = src/onnxstyletransferpipeline.c
USER_DEFS =
USER_INC_DIRS = inc
USER_OBJS =
USER_LIBS =
USER_EDCS =
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pipeline" :
{
"description" : "appsrc name=appsrc caps=other/tensor,type=uint8,dimension=3:720:720:1,framerate=0/1 !
tensor_transform mode=transpose option=1:2:0:3 !
tensor_transform mode=arithmetic option=typecast:float32,add:0.0 !
tensor_filter framework=onnxruntime model=/opt/usr/globalapps/org.example.onnxstyletransferpipeline/res/candy.onnx !
tensor_converter ! tensor_transform mode=transpose option=2:0:1:3 !
tensor_transform mode=arithmetic option=mul:1.0,add:0.0 !
tensor_transform mode=clamp option=0:255 !
other/tensor,type=float32,dimension=3:720:720:1,framerate=0/1 !
tensor_transform mode=typecast option=uint8 !
other/tensor,type=uint8,dimension=3:720:720:1,framerate=0/1 !
tensor_decoder mode=direct_video ! videoconvert ! video/x-raw,width=720,height=720,format=BGRA,framerate=0/1 !
tensor_converter ! tensor_sink name=tensor_sink ",
"input_node" : [
{
"name" : "appsrc",
"info" : [
{
"type" : "uint8",
"dimension" : "3:720:720:1"
}
]
}
],
"output_node" : [
{
"name" : "tensor_sink",
"info" : [

{
"type" : "uint8",
"dimension" : "3:720:720:1"
}
]
}
]
}
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4efdd5b

Please sign in to comment.