ニューラルネットで何でもできちゃう!? Unity Barracudaで遊ぼう を見たので、
さっそく style-transfer 動かしてみました。
左下のサムネイルで、動画にエフェクトがかかるものです。
概略
ポストエフェクトみたいな感じなので、インプットの値をゴリゴリ調整することもなく、
git clone して静止画を動画に変えればすぐに試せます。
前提
- Windows 10 home
- Unity 2019.4.10f1
- 注意:GitHub のバージョンは 2019.4.1f1 なので、そちらのほうが無難です
手順
- こちら から git clone してください。
- Unity で開きます。
- 開いたところでエラー(※1)がかなり出ていましたが、無視して clear します。
- Unity で実行します。
- マウスの左でエフェクトの On/Off
- マウスの右でエフェクトのイメージ切り替え
- GitHub のコードは静止画+カプセルオブジェクトなので、この辺を参考に動画に切り替えると、上記 gif のようなことができます。
※1 エラー
無視したやつです。
Unexpected error while evaluating model output StyleNetwork/residual_block1/residual_block1_conv1/convolution_residual_block1_conv1/instance_normalisation/get_normalization/alpha. System.NotImplementedException: Layer type 40 needs to be explicitly handled
at Unity.Barracuda.ModelAnalyzer.ListTemporaryTensorShapes (Unity.Barracuda.Model model, System.Collections.Generic.IDictionary`2[TKey,TValue] inputShapes, System.Collections.Generic.IDictionary`2[System.String,System.Nullable`1[Unity.Barracuda.TensorShape]]& shapesByName) [0x01259] in D:\10_unity\barracuda-style-transfer\Library\PackageCache\com.unity.barracuda@1.2.1-preview\Barracuda\Runtime\Core\Backends\ModelAnalyzer.cs:517
at Unity.Barracuda.ModelAnalyzer.TryGetOutputTensorShape (Unity.Barracuda.Model model, System.Collections.Generic.IDictionary`2[TKey,TValue] inputShapes, System.String output, Unity.Barracuda.TensorShape& shape) [0x00008] in D:\10_unity\barracuda-style-transfer\Library\PackageCache\com.unity.barracuda@1.2.1-preview\Barracuda\Runtime\Core\Backends\ModelAnalyzer.cs:532
at Unity.Barracuda.Editor.NNModelEditor+<>c__DisplayClass26_0.<OnEnable>b__2 (System.String i) [0x00008] in D:\10_unity\barracuda-style-transfer\Library\PackageCache\com.unity.barracuda@1.2.1-preview\Barracuda\Editor\ONNXModelImporterEditor.cs:142
UnityEngine.Debug:LogError(Object)
Unity.Barracuda.D:LogError(Object) (at Library/PackageCache/com.unity.barracuda@1.2.1-preview/Barracuda/Runtime/Core/Internals/Debug.cs:131)
Unity.Barracuda.Editor.<>c__DisplayClass26_0:<OnEnable>b__2(String) (at Library/PackageCache/com.unity.barracuda@1.2.1-preview/Barracuda/Editor/ONNXModelImporterEditor.cs:147)
System.Linq.Enumerable:ToList(IEnumerable`1)
Unity.Barracuda.Editor.NNModelEditor:OnEnable() (at Library/PackageCache/com.unity.barracuda@1.2.1-preview/Barracuda/Editor/ONNXModelImporterEditor.cs:137)
UnityEditor.AssetPreviewUpdater:CreatePreviewForAsset(Object, Object[], String)