├── .gitattributes ├── .gitignore ├── Imgs ├── 99_0.png ├── image_0009.png ├── img_large.jpg └── model_architecture.png ├── NNPostProcessing ├── Assets │ ├── NNPostProcessing.meta │ ├── NNPostProcessing │ │ ├── DemoScene.meta │ │ ├── DemoScene │ │ │ ├── Arts.meta │ │ │ ├── Arts │ │ │ │ ├── Branches_0.mat │ │ │ │ ├── Branches_0.mat.meta │ │ │ │ ├── BroadleafBark.tga │ │ │ │ ├── BroadleafBark.tga.meta │ │ │ │ ├── BroadleafBark_Normal.tga │ │ │ │ ├── BroadleafBark_Normal.tga.meta │ │ │ │ ├── Broadleaf_Mobile_Atlas.tga │ │ │ │ ├── Broadleaf_Mobile_Atlas.tga.meta │ │ │ │ ├── Broadleaf_Mobile_Atlas_Normal.tga │ │ │ │ ├── Broadleaf_Mobile_Atlas_Normal.tga.meta │ │ │ │ ├── CliffAlbedoSpecular.png │ │ │ │ ├── CliffAlbedoSpecular.png.meta │ │ │ │ ├── GrassFrond01AlbedoAlpha.tga │ │ │ │ ├── GrassFrond01AlbedoAlpha.tga.meta │ │ │ │ ├── GrassHillAlbedo.png │ │ │ │ ├── GrassHillAlbedo.png.meta │ │ │ │ ├── GrassRockyAlbedo.png │ │ │ │ ├── GrassRockyAlbedo.png.meta │ │ │ │ ├── Leaves_1.mat │ │ │ │ ├── Leaves_1.mat.meta │ │ │ │ ├── Skybox.mat │ │ │ │ ├── Skybox.mat.meta │ │ │ │ ├── Tree.mtl │ │ │ │ ├── Tree.mtl.meta │ │ │ │ ├── Tree.obj │ │ │ │ ├── Tree.obj.meta │ │ │ │ ├── Tree.prefab │ │ │ │ ├── Tree.prefab.meta │ │ │ │ ├── layer_CliffAlbedoSpecular3d3aba195e4d26ee.terrainlayer │ │ │ │ ├── layer_CliffAlbedoSpecular3d3aba195e4d26ee.terrainlayer.meta │ │ │ │ ├── layer_GrassHillAlbedo3d3aba195e4d26ee.terrainlayer │ │ │ │ ├── layer_GrassHillAlbedo3d3aba195e4d26ee.terrainlayer.meta │ │ │ │ ├── layer_GrassRockyAlbedo3d3aba195e4d26ee.terrainlayer │ │ │ │ ├── layer_GrassRockyAlbedo3d3aba195e4d26ee.terrainlayer.meta │ │ │ │ ├── terrain.asset │ │ │ │ └── terrain.asset.meta │ │ │ ├── Scene.unity │ │ │ └── Scene.unity.meta │ │ ├── Documentation.pdf │ │ ├── Documentation.pdf.meta │ │ ├── Resources.meta │ │ ├── Resources │ │ │ ├── Model.meta │ │ │ ├── Model │ │ │ │ ├── starry_night.json │ │ │ │ └── starry_night.json.meta │ │ │ ├── NNLayer.compute │ │ │ └── NNLayer.compute.meta │ │ ├── Scripts.meta │ │ └── Scripts │ │ │ ├── NNCompute.cs │ │ │ ├── NNCompute.cs.meta │ │ │ ├── NNLayerBase.cs │ │ │ ├── NNLayerBase.cs.meta │ │ │ ├── NNLayers.meta │ │ │ ├── NNLayers │ │ │ ├── Add.cs │ │ │ ├── Add.cs.meta │ │ │ ├── BatchNormalization.cs │ │ │ ├── BatchNormalization.cs.meta │ │ │ ├── Concatenate.cs │ │ │ ├── Concatenate.cs.meta │ │ │ ├── Conv2D.cs │ │ │ ├── Conv2D.cs.meta │ │ │ ├── InputLayer.cs │ │ │ ├── InputLayer.cs.meta │ │ │ ├── LeakyReLU.cs │ │ │ ├── LeakyReLU.cs.meta │ │ │ ├── OutputLayer.cs │ │ │ ├── OutputLayer.cs.meta │ │ │ ├── ReLU.cs │ │ │ ├── ReLU.cs.meta │ │ │ ├── Tanh.cs │ │ │ ├── Tanh.cs.meta │ │ │ ├── UpSampling2D.cs │ │ │ └── UpSampling2D.cs.meta │ │ │ ├── NNModel.cs │ │ │ ├── NNModel.cs.meta │ │ │ ├── NNModelSerialize.cs │ │ │ ├── NNModelSerialize.cs.meta │ │ │ ├── NNPostProcessingEffect.cs │ │ │ ├── NNPostProcessingEffect.cs.meta │ │ │ ├── SimpleCharacterController.cs │ │ │ └── SimpleCharacterController.cs.meta │ ├── Script.meta │ └── Script │ │ ├── KerasJsonParser.cs │ │ ├── KerasJsonParser.cs.meta │ │ ├── NNLayerExtention.cs │ │ ├── NNLayerExtention.cs.meta │ │ ├── NNRawModelParser.cs │ │ ├── NNRawModelParser.cs.meta │ │ ├── Newtonsoft.Json.dll │ │ ├── Newtonsoft.Json.dll.meta │ │ ├── Trail.meta │ │ ├── Trail │ │ ├── CameraTrail.cs │ │ ├── CameraTrail.cs.meta │ │ ├── TrailPlayer.cs │ │ ├── TrailPlayer.cs.meta │ │ ├── TrailRecorder.cs │ │ └── TrailRecorder.cs.meta │ │ ├── Utils.meta │ │ └── Utils │ │ ├── NNDebug.cs │ │ ├── NNDebug.cs.meta │ │ ├── RenderDepth.cs │ │ ├── RenderDepth.cs.meta │ │ ├── copydepth.shader │ │ ├── copydepth.shader.meta │ │ ├── depth.mat │ │ ├── depth.mat.meta │ │ ├── trail.asset │ │ └── trail.asset.meta ├── Packages │ └── manifest.json └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── PresetManager.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityConnectSettings.asset │ ├── VFXManager.asset │ └── XRSettings.asset ├── NNTrainer ├── README.md ├── datasets │ ├── chicago.jpg │ ├── example_dataset │ │ ├── test │ │ │ └── placeholder.txt │ │ └── train │ │ │ └── placeholder.txt │ └── style │ │ ├── des_glaneuses.jpg │ │ ├── gritty.jpg │ │ ├── la_muse.jpg │ │ ├── mirror.jpg │ │ ├── mosaic.jpg │ │ ├── rain_princess.jpg │ │ ├── shanshui.jpg │ │ ├── sketch.jpg │ │ ├── starry_night.jpg │ │ ├── the_scream.jpg │ │ ├── udnie.jpg │ │ ├── watercolor.jpg │ │ └── wave_crop.jpg ├── debug.cmd ├── debug.py ├── export.cmd ├── exporter.py ├── images │ └── placeholder.txt ├── model │ ├── model_architecture.json │ ├── model_architecture.png │ └── model_weight.h5 ├── requirements.txt ├── src │ ├── img_util.py │ ├── layers.py │ ├── nets.py │ ├── trainer.py │ └── vgg.py ├── train_fst.cmd └── train_fst.py └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | NNPostProcessing/[Ll]ibrary/ 2 | NNPostProcessing/[Tt]emp/ 3 | NNPostProcessing/[Oo]bj/ 4 | NNPostProcessing/[Bb]uild/ 5 | NNPostProcessing/[Bb]uilds/ 6 | NNPostProcessing/Recordings 7 | NNPostProcessing/Assets/Unity Recorder 8 | NNTrainer/__pycache__ 9 | NNTrainer/src/__pycache__ 10 | NNTrainer/debug 11 | NNTrainer/model 12 | NNTrainer/datasets/terrain 13 | NNTrainer/datasets/coco2017 14 | NNTrainer/datasets/output 15 | NNTrainer/datasets/cityscapes 16 | NNTrainer/images/terrain 17 | NNTrainer/trained_test 18 | Assetstore/ 19 | Release 20 | NNPostProcessing/Assets/AssetStoreTools* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Autogenerated VS/MD/Consulo solution and project files 26 | ExportedObj/ 27 | .consulo/ 28 | *.csproj 29 | *.unityproj 30 | *.sln 31 | *.suo 32 | *.tmp 33 | *.user 34 | *.userprefs 35 | *.pidb 36 | *.booproj 37 | *.svd 38 | *.pdb 39 | *.opendb 40 | *.VC.db 41 | 42 | # Unity3D generated meta files 43 | *.pidb.meta 44 | *.pdb.meta 45 | 46 | # Unity3D Generated File On Crash Reports 47 | sysinfo.txt 48 | 49 | # Builds 50 | *.apk 51 | *.unitypackage 52 | 53 | 54 | NNPostProcessing/Assets/NNPostProcessing/Resources/* 55 | NNPostProcessing/Assets/Script/* 56 | -------------------------------------------------------------------------------- /Imgs/99_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/Imgs/99_0.png -------------------------------------------------------------------------------- /Imgs/image_0009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/Imgs/image_0009.png -------------------------------------------------------------------------------- /Imgs/img_large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/Imgs/img_large.jpg -------------------------------------------------------------------------------- /Imgs/model_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/Imgs/model_architecture.png -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34729ebc824f393428d717cea4a2c995 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a547f5c2573077147b27cf9d1071579f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8050364d3f0682749a529dbf3cf5ee2e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Branches_0.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Branches_0 10 | m_Shader: {fileID: 14000, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: EFFECT_BUMP EFFECT_HUE_VARIATION GEOM_TYPE_BRANCH 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 1 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | disabledShaderPasses: [] 17 | m_SavedProperties: 18 | serializedVersion: 3 19 | m_TexEnvs: 20 | - _BumpMap: 21 | m_Texture: {fileID: 2800000, guid: 34f07406286974e4ca236867d8d58b51, type: 3} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | - _DetailTex: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _MainTex: 29 | m_Texture: {fileID: 2800000, guid: 2c1c27ec8c3b75a4c80a795adc9ca788, type: 3} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | m_Floats: 33 | - _Cull: 2 34 | - _Cutoff: 0.33 35 | - _WindQuality: 4 36 | m_Colors: 37 | - _Color: {r: 1, g: 1, b: 1, a: 1} 38 | - _HueVariation: {r: 1, g: 0.5, b: 0, a: 0.1} 39 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Branches_0.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfc1dabf45016eb46b99df1a78054924 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/BroadleafBark.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/BroadleafBark.tga -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/BroadleafBark.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c1c27ec8c3b75a4c80a795adc9ca788 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 0 46 | textureType: -1 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/BroadleafBark_Normal.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/BroadleafBark_Normal.tga -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/BroadleafBark_Normal.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34f07406286974e4ca236867d8d58b51 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 1 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 0 46 | textureType: 1 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Broadleaf_Mobile_Atlas.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Broadleaf_Mobile_Atlas.tga -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Broadleaf_Mobile_Atlas.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c116325e19b8a04d916864cc540ec2d 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 0 46 | textureType: -1 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Broadleaf_Mobile_Atlas_Normal.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Broadleaf_Mobile_Atlas_Normal.tga -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Broadleaf_Mobile_Atlas_Normal.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be053ea3235ccb64a889bf0b15c2764b 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 1 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 0 46 | textureType: 1 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/CliffAlbedoSpecular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/CliffAlbedoSpecular.png -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/CliffAlbedoSpecular.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79a6f5b6ae9a4734b9cbc1440edd5952 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | vertices: [] 80 | indices: 81 | edges: [] 82 | weights: [] 83 | spritePackingTag: 84 | pSDRemoveMatte: 0 85 | pSDShowRemoveMatteOption: 0 86 | userData: 87 | assetBundleName: 88 | assetBundleVariant: 89 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassFrond01AlbedoAlpha.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassFrond01AlbedoAlpha.tga -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassFrond01AlbedoAlpha.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c1b1f914dfec2646991b58e33a82978 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 2048 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 1 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassHillAlbedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassHillAlbedo.png -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassHillAlbedo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 252bca6ee497d5c45a38774e4cb000e1 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | vertices: [] 80 | indices: 81 | edges: [] 82 | weights: [] 83 | spritePackingTag: 84 | pSDRemoveMatte: 0 85 | pSDShowRemoveMatteOption: 0 86 | userData: 87 | assetBundleName: 88 | assetBundleVariant: 89 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassRockyAlbedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassRockyAlbedo.png -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/GrassRockyAlbedo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c26acf27d9382534d9a58bd79aaa14e3 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | vertices: [] 80 | indices: 81 | edges: [] 82 | weights: [] 83 | spritePackingTag: 84 | pSDRemoveMatte: 0 85 | pSDShowRemoveMatteOption: 0 86 | userData: 87 | assetBundleName: 88 | assetBundleVariant: 89 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Leaves_1.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Leaves_1 10 | m_Shader: {fileID: 14000, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: EFFECT_BUMP EFFECT_HUE_VARIATION GEOM_TYPE_LEAF 12 | m_LightmapFlags: 5 13 | m_EnableInstancingVariants: 1 14 | m_CustomRenderQueue: -1 15 | stringTagMap: {} 16 | disabledShaderPasses: [] 17 | m_SavedProperties: 18 | serializedVersion: 3 19 | m_TexEnvs: 20 | - _BumpMap: 21 | m_Texture: {fileID: 2800000, guid: be053ea3235ccb64a889bf0b15c2764b, type: 3} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | - _DetailTex: 25 | m_Texture: {fileID: 0} 26 | m_Scale: {x: 1, y: 1} 27 | m_Offset: {x: 0, y: 0} 28 | - _MainTex: 29 | m_Texture: {fileID: 2800000, guid: 2c116325e19b8a04d916864cc540ec2d, type: 3} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | m_Floats: 33 | - _Cull: 0 34 | - _Cutoff: 0.33 35 | - _WindQuality: 4 36 | m_Colors: 37 | - _Color: {r: 1, g: 1, b: 1, a: 1} 38 | - _HueVariation: {r: 1, g: 0.5, b: 0, a: 0.1} 39 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Leaves_1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c3b3265bf0f7e547a1ada8555f850a5 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Skybox.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Skybox 10 | m_Shader: {fileID: 106, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: _SUNDISK_HIGH_QUALITY 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BackTex: 22 | m_Texture: {fileID: 2800000, guid: e88d0da9f62c13d40904c838a6dd00b8, type: 3} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _BumpMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailAlbedoMap: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailMask: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _DetailNormalMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _DownTex: 42 | m_Texture: {fileID: 2800000, guid: f5c10e8155f7ef2429f4ecfed1e81a7a, type: 3} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _EmissionMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _FrontTex: 50 | m_Texture: {fileID: 2800000, guid: ff763b7d888f8dc449d241f19294106b, type: 3} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _LeftTex: 54 | m_Texture: {fileID: 2800000, guid: 36b1e02dd68d74c40ab47d997320867b, type: 3} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | - _MainTex: 58 | m_Texture: {fileID: 0} 59 | m_Scale: {x: 1, y: 1} 60 | m_Offset: {x: 0, y: 0} 61 | - _MetallicGlossMap: 62 | m_Texture: {fileID: 0} 63 | m_Scale: {x: 1, y: 1} 64 | m_Offset: {x: 0, y: 0} 65 | - _OcclusionMap: 66 | m_Texture: {fileID: 0} 67 | m_Scale: {x: 1, y: 1} 68 | m_Offset: {x: 0, y: 0} 69 | - _ParallaxMap: 70 | m_Texture: {fileID: 0} 71 | m_Scale: {x: 1, y: 1} 72 | m_Offset: {x: 0, y: 0} 73 | - _RightTex: 74 | m_Texture: {fileID: 2800000, guid: 9cec472ff7443044ea6ec18c82bd0923, type: 3} 75 | m_Scale: {x: 1, y: 1} 76 | m_Offset: {x: 0, y: 0} 77 | - _UpTex: 78 | m_Texture: {fileID: 2800000, guid: 43c6d7f45c9cb0247a1eb2a589bfa4df, type: 3} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | m_Floats: 82 | - _AtmosphereThickness: 1.59 83 | - _BumpScale: 1 84 | - _Cutoff: 0.5 85 | - _DetailNormalMapScale: 1 86 | - _DstBlend: 0 87 | - _Exposure: 1 88 | - _GlossMapScale: 1 89 | - _Glossiness: 0.5 90 | - _GlossyReflections: 1 91 | - _Metallic: 0 92 | - _Mode: 0 93 | - _OcclusionStrength: 1 94 | - _Parallax: 0.02 95 | - _Rotation: 0 96 | - _SmoothnessTextureChannel: 0 97 | - _SpecularHighlights: 1 98 | - _SrcBlend: 1 99 | - _SunDisk: 2 100 | - _SunSize: 0.088 101 | - _SunSizeConvergence: 3.54 102 | - _UVSec: 0 103 | - _ZWrite: 1 104 | m_Colors: 105 | - _Color: {r: 1, g: 1, b: 1, a: 1} 106 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 107 | - _GroundColor: {r: 0.369, g: 0.349, b: 0.341, a: 1} 108 | - _SkyTint: {r: 0.5, g: 0.5, b: 0.5, a: 1} 109 | - _Tint: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} 110 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Skybox.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0aacc24912965144b8097a116c89b46d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Tree.mtl: -------------------------------------------------------------------------------- 1 | newmtl Branches_0 2 | Kd 1 1 1 3 | illum 2 4 | 5 | newmtl Leaves_1 6 | Kd 1 1 1 7 | illum 2 8 | 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Tree.mtl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60490fe7a8870b740a06c67e9e6141d7 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Tree.obj.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df0c004f9c083084bbacff558bdb8486 3 | ModelImporter: 4 | serializedVersion: 19301 5 | internalIDToNameTable: [] 6 | externalObjects: {} 7 | materials: 8 | materialImportMode: 0 9 | materialName: 0 10 | materialSearch: 1 11 | materialLocation: 1 12 | animations: 13 | legacyGenerateAnimations: 4 14 | bakeSimulation: 0 15 | resampleCurves: 1 16 | optimizeGameObjects: 0 17 | motionNodeName: 18 | rigImportErrors: 19 | rigImportWarnings: 20 | animationImportErrors: 21 | animationImportWarnings: 22 | animationRetargetingWarnings: 23 | animationDoRetargetingWarnings: 0 24 | importAnimatedCustomProperties: 0 25 | importConstraints: 0 26 | animationCompression: 1 27 | animationRotationError: 0.5 28 | animationPositionError: 0.5 29 | animationScaleError: 0.5 30 | animationWrapMode: 0 31 | extraExposedTransformPaths: [] 32 | extraUserProperties: [] 33 | clipAnimations: [] 34 | isReadable: 0 35 | meshes: 36 | lODScreenPercentages: [] 37 | globalScale: 1 38 | meshCompression: 0 39 | addColliders: 0 40 | useSRGBMaterialColor: 1 41 | sortHierarchyByName: 0 42 | importVisibility: 0 43 | importBlendShapes: 0 44 | importCameras: 0 45 | importLights: 0 46 | fileIdsGeneration: 2 47 | swapUVChannels: 0 48 | generateSecondaryUV: 0 49 | useFileUnits: 1 50 | keepQuads: 0 51 | weldVertices: 1 52 | preserveHierarchy: 0 53 | skinWeightsMode: 0 54 | maxBonesPerVertex: 4 55 | minBoneWeight: 0.001 56 | meshOptimizationFlags: -1 57 | indexFormat: 0 58 | secondaryUVAngleDistortion: 8 59 | secondaryUVAreaDistortion: 15.000001 60 | secondaryUVHardAngle: 88 61 | secondaryUVPackMargin: 4 62 | useFileScale: 1 63 | tangentSpace: 64 | normalSmoothAngle: 60 65 | normalImportMode: 0 66 | tangentImportMode: 3 67 | normalCalculationMode: 4 68 | legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 69 | blendShapeNormalImportMode: 1 70 | normalSmoothingSource: 0 71 | referencedClips: [] 72 | importAnimation: 0 73 | humanDescription: 74 | serializedVersion: 3 75 | human: [] 76 | skeleton: [] 77 | armTwist: 0.5 78 | foreArmTwist: 0.5 79 | upperLegTwist: 0.5 80 | legTwist: 0.5 81 | armStretch: 0.05 82 | legStretch: 0.05 83 | feetSpacing: 0 84 | globalScale: 1 85 | rootMotionBoneName: 86 | hasTranslationDoF: 0 87 | hasExtraRoot: 0 88 | skeletonHasParents: 1 89 | lastHumanDescriptionAvatarSource: {instanceID: 0} 90 | autoGenerateAvatarMappingIfUnspecified: 1 91 | animationType: 0 92 | humanoidOversampling: 1 93 | avatarSetup: 0 94 | additionalBone: 0 95 | userData: 96 | assetBundleName: 97 | assetBundleVariant: 98 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Tree.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1094526053363846972 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 4352593637748566366} 12 | - component: {fileID: 6497093582330760941} 13 | - component: {fileID: 8077774035635329553} 14 | m_Layer: 0 15 | m_Name: Broadleaf_Mobile_LOD1 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &4352593637748566366 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1094526053363846972} 28 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_Children: [] 32 | m_Father: {fileID: 4371580729926282751} 33 | m_RootOrder: 4 34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 35 | --- !u!33 &6497093582330760941 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1094526053363846972} 42 | m_Mesh: {fileID: -8841906869106631973, guid: df0c004f9c083084bbacff558bdb8486, type: 3} 43 | --- !u!23 &8077774035635329553 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1094526053363846972} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RenderingLayerMask: 1 59 | m_RendererPriority: 0 60 | m_Materials: 61 | - {fileID: 2100000, guid: bfc1dabf45016eb46b99df1a78054924, type: 2} 62 | - {fileID: 2100000, guid: 6c3b3265bf0f7e547a1ada8555f850a5, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | --- !u!1 &2138347295756050206 84 | GameObject: 85 | m_ObjectHideFlags: 0 86 | m_CorrespondingSourceObject: {fileID: 0} 87 | m_PrefabInstance: {fileID: 0} 88 | m_PrefabAsset: {fileID: 0} 89 | serializedVersion: 6 90 | m_Component: 91 | - component: {fileID: 5321972603964461030} 92 | - component: {fileID: 8030473773591460673} 93 | - component: {fileID: 2948092422216901565} 94 | m_Layer: 0 95 | m_Name: Broadleaf_Mobile_LOD0 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &5321972603964461030 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 2138347295756050206} 108 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: [] 112 | m_Father: {fileID: 4371580729926282751} 113 | m_RootOrder: 3 114 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 115 | --- !u!33 &8030473773591460673 116 | MeshFilter: 117 | m_ObjectHideFlags: 0 118 | m_CorrespondingSourceObject: {fileID: 0} 119 | m_PrefabInstance: {fileID: 0} 120 | m_PrefabAsset: {fileID: 0} 121 | m_GameObject: {fileID: 2138347295756050206} 122 | m_Mesh: {fileID: -5147659410091287527, guid: df0c004f9c083084bbacff558bdb8486, type: 3} 123 | --- !u!23 &2948092422216901565 124 | MeshRenderer: 125 | m_ObjectHideFlags: 0 126 | m_CorrespondingSourceObject: {fileID: 0} 127 | m_PrefabInstance: {fileID: 0} 128 | m_PrefabAsset: {fileID: 0} 129 | m_GameObject: {fileID: 2138347295756050206} 130 | m_Enabled: 1 131 | m_CastShadows: 1 132 | m_ReceiveShadows: 1 133 | m_DynamicOccludee: 1 134 | m_MotionVectors: 1 135 | m_LightProbeUsage: 1 136 | m_ReflectionProbeUsage: 1 137 | m_RayTracingMode: 2 138 | m_RenderingLayerMask: 1 139 | m_RendererPriority: 0 140 | m_Materials: 141 | - {fileID: 2100000, guid: bfc1dabf45016eb46b99df1a78054924, type: 2} 142 | - {fileID: 2100000, guid: 6c3b3265bf0f7e547a1ada8555f850a5, type: 2} 143 | m_StaticBatchInfo: 144 | firstSubMesh: 0 145 | subMeshCount: 0 146 | m_StaticBatchRoot: {fileID: 0} 147 | m_ProbeAnchor: {fileID: 0} 148 | m_LightProbeVolumeOverride: {fileID: 0} 149 | m_ScaleInLightmap: 1 150 | m_ReceiveGI: 1 151 | m_PreserveUVs: 0 152 | m_IgnoreNormalsForChartDetection: 0 153 | m_ImportantGI: 0 154 | m_StitchLightmapSeams: 1 155 | m_SelectedEditorRenderState: 3 156 | m_MinimumChartSize: 4 157 | m_AutoUVMaxDistance: 0.5 158 | m_AutoUVMaxAngle: 89 159 | m_LightmapParameters: {fileID: 0} 160 | m_SortingLayerID: 0 161 | m_SortingLayer: 0 162 | m_SortingOrder: 0 163 | --- !u!1 &3452799962023950567 164 | GameObject: 165 | m_ObjectHideFlags: 0 166 | m_CorrespondingSourceObject: {fileID: 0} 167 | m_PrefabInstance: {fileID: 0} 168 | m_PrefabAsset: {fileID: 0} 169 | serializedVersion: 6 170 | m_Component: 171 | - component: {fileID: 1571289127538631163} 172 | - component: {fileID: 6186960773496839669} 173 | - component: {fileID: 7539080805507843884} 174 | m_Layer: 0 175 | m_Name: Broadleaf_Mobile_LOD2 176 | m_TagString: Untagged 177 | m_Icon: {fileID: 0} 178 | m_NavMeshLayer: 0 179 | m_StaticEditorFlags: 0 180 | m_IsActive: 1 181 | --- !u!4 &1571289127538631163 182 | Transform: 183 | m_ObjectHideFlags: 0 184 | m_CorrespondingSourceObject: {fileID: 0} 185 | m_PrefabInstance: {fileID: 0} 186 | m_PrefabAsset: {fileID: 0} 187 | m_GameObject: {fileID: 3452799962023950567} 188 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 189 | m_LocalPosition: {x: 0, y: 0, z: 0} 190 | m_LocalScale: {x: 1, y: 1, z: 1} 191 | m_Children: [] 192 | m_Father: {fileID: 4371580729926282751} 193 | m_RootOrder: 5 194 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 195 | --- !u!33 &6186960773496839669 196 | MeshFilter: 197 | m_ObjectHideFlags: 0 198 | m_CorrespondingSourceObject: {fileID: 0} 199 | m_PrefabInstance: {fileID: 0} 200 | m_PrefabAsset: {fileID: 0} 201 | m_GameObject: {fileID: 3452799962023950567} 202 | m_Mesh: {fileID: -5036194427615195811, guid: df0c004f9c083084bbacff558bdb8486, type: 3} 203 | --- !u!23 &7539080805507843884 204 | MeshRenderer: 205 | m_ObjectHideFlags: 0 206 | m_CorrespondingSourceObject: {fileID: 0} 207 | m_PrefabInstance: {fileID: 0} 208 | m_PrefabAsset: {fileID: 0} 209 | m_GameObject: {fileID: 3452799962023950567} 210 | m_Enabled: 1 211 | m_CastShadows: 1 212 | m_ReceiveShadows: 1 213 | m_DynamicOccludee: 1 214 | m_MotionVectors: 1 215 | m_LightProbeUsage: 1 216 | m_ReflectionProbeUsage: 1 217 | m_RayTracingMode: 2 218 | m_RenderingLayerMask: 1 219 | m_RendererPriority: 0 220 | m_Materials: 221 | - {fileID: 2100000, guid: bfc1dabf45016eb46b99df1a78054924, type: 2} 222 | - {fileID: 2100000, guid: 6c3b3265bf0f7e547a1ada8555f850a5, type: 2} 223 | m_StaticBatchInfo: 224 | firstSubMesh: 0 225 | subMeshCount: 0 226 | m_StaticBatchRoot: {fileID: 0} 227 | m_ProbeAnchor: {fileID: 0} 228 | m_LightProbeVolumeOverride: {fileID: 0} 229 | m_ScaleInLightmap: 1 230 | m_ReceiveGI: 1 231 | m_PreserveUVs: 0 232 | m_IgnoreNormalsForChartDetection: 0 233 | m_ImportantGI: 0 234 | m_StitchLightmapSeams: 1 235 | m_SelectedEditorRenderState: 3 236 | m_MinimumChartSize: 4 237 | m_AutoUVMaxDistance: 0.5 238 | m_AutoUVMaxAngle: 89 239 | m_LightmapParameters: {fileID: 0} 240 | m_SortingLayerID: 0 241 | m_SortingLayer: 0 242 | m_SortingOrder: 0 243 | --- !u!1 &3926118966855480344 244 | GameObject: 245 | m_ObjectHideFlags: 0 246 | m_CorrespondingSourceObject: {fileID: 0} 247 | m_PrefabInstance: {fileID: 0} 248 | m_PrefabAsset: {fileID: 0} 249 | serializedVersion: 6 250 | m_Component: 251 | - component: {fileID: 3926118966855968824} 252 | - component: {fileID: 3926118966859418836} 253 | m_Layer: 0 254 | m_Name: CollisionObject1 255 | m_TagString: Untagged 256 | m_Icon: {fileID: 0} 257 | m_NavMeshLayer: 0 258 | m_StaticEditorFlags: 0 259 | m_IsActive: 1 260 | --- !u!4 &3926118966855968824 261 | Transform: 262 | m_ObjectHideFlags: 0 263 | m_CorrespondingSourceObject: {fileID: 0} 264 | m_PrefabInstance: {fileID: 0} 265 | m_PrefabAsset: {fileID: 0} 266 | m_GameObject: {fileID: 3926118966855480344} 267 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 268 | m_LocalPosition: {x: -0.012256893, y: 6.6987724, z: 0.26901618} 269 | m_LocalScale: {x: 1, y: 1, z: 1} 270 | m_Children: [] 271 | m_Father: {fileID: 4371580729926282751} 272 | m_RootOrder: 1 273 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 274 | --- !u!135 &3926118966859418836 275 | SphereCollider: 276 | m_ObjectHideFlags: 0 277 | m_CorrespondingSourceObject: {fileID: 0} 278 | m_PrefabInstance: {fileID: 0} 279 | m_PrefabAsset: {fileID: 0} 280 | m_GameObject: {fileID: 3926118966855480344} 281 | m_Material: {fileID: 0} 282 | m_IsTrigger: 0 283 | m_Enabled: 1 284 | serializedVersion: 2 285 | m_Radius: 4.323558 286 | m_Center: {x: 0, y: 0, z: 0} 287 | --- !u!1 &3926118966855480346 288 | GameObject: 289 | m_ObjectHideFlags: 0 290 | m_CorrespondingSourceObject: {fileID: 0} 291 | m_PrefabInstance: {fileID: 0} 292 | m_PrefabAsset: {fileID: 0} 293 | serializedVersion: 6 294 | m_Component: 295 | - component: {fileID: 3926118966855968826} 296 | - component: {fileID: 3926118966859418838} 297 | m_Layer: 0 298 | m_Name: CollisionObject2 299 | m_TagString: Untagged 300 | m_Icon: {fileID: 0} 301 | m_NavMeshLayer: 0 302 | m_StaticEditorFlags: 0 303 | m_IsActive: 1 304 | --- !u!4 &3926118966855968826 305 | Transform: 306 | m_ObjectHideFlags: 0 307 | m_CorrespondingSourceObject: {fileID: 0} 308 | m_PrefabInstance: {fileID: 0} 309 | m_PrefabAsset: {fileID: 0} 310 | m_GameObject: {fileID: 3926118966855480346} 311 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 312 | m_LocalPosition: {x: -0.054269638, y: 13.150047, z: 0.16480294} 313 | m_LocalScale: {x: 1, y: 1, z: 1} 314 | m_Children: [] 315 | m_Father: {fileID: 4371580729926282751} 316 | m_RootOrder: 2 317 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 318 | --- !u!135 &3926118966859418838 319 | SphereCollider: 320 | m_ObjectHideFlags: 0 321 | m_CorrespondingSourceObject: {fileID: 0} 322 | m_PrefabInstance: {fileID: 0} 323 | m_PrefabAsset: {fileID: 0} 324 | m_GameObject: {fileID: 3926118966855480346} 325 | m_Material: {fileID: 0} 326 | m_IsTrigger: 0 327 | m_Enabled: 1 328 | serializedVersion: 2 329 | m_Radius: 3.1897016 330 | m_Center: {x: 0, y: 0, z: 0} 331 | --- !u!1 &3926118966855480350 332 | GameObject: 333 | m_ObjectHideFlags: 0 334 | m_CorrespondingSourceObject: {fileID: 0} 335 | m_PrefabInstance: {fileID: 0} 336 | m_PrefabAsset: {fileID: 0} 337 | serializedVersion: 6 338 | m_Component: 339 | - component: {fileID: 3926118966855968830} 340 | - component: {fileID: 3926118966859544500} 341 | m_Layer: 0 342 | m_Name: CollisionObject0 343 | m_TagString: Untagged 344 | m_Icon: {fileID: 0} 345 | m_NavMeshLayer: 0 346 | m_StaticEditorFlags: 0 347 | m_IsActive: 1 348 | --- !u!4 &3926118966855968830 349 | Transform: 350 | m_ObjectHideFlags: 0 351 | m_CorrespondingSourceObject: {fileID: 0} 352 | m_PrefabInstance: {fileID: 0} 353 | m_PrefabAsset: {fileID: 0} 354 | m_GameObject: {fileID: 3926118966855480350} 355 | m_LocalRotation: {x: -0, y: -0.012279858, z: 0.7130887, w: 0.70096624} 356 | m_LocalPosition: {x: -0.085042864, y: 4.5666356, z: 0.08466354} 357 | m_LocalScale: {x: 1, y: 1, z: 1} 358 | m_Children: [] 359 | m_Father: {fileID: 4371580729926282751} 360 | m_RootOrder: 0 361 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 362 | --- !u!136 &3926118966859544500 363 | CapsuleCollider: 364 | m_ObjectHideFlags: 0 365 | m_CorrespondingSourceObject: {fileID: 0} 366 | m_PrefabInstance: {fileID: 0} 367 | m_PrefabAsset: {fileID: 0} 368 | m_GameObject: {fileID: 3926118966855480350} 369 | m_Material: {fileID: 0} 370 | m_IsTrigger: 0 371 | m_Enabled: 1 372 | m_Radius: 0.64540184 373 | m_Height: 11.12652 374 | m_Direction: 0 375 | m_Center: {x: 0, y: 0, z: 0} 376 | --- !u!1 &4026544826781710149 377 | GameObject: 378 | m_ObjectHideFlags: 0 379 | m_CorrespondingSourceObject: {fileID: 0} 380 | m_PrefabInstance: {fileID: 0} 381 | m_PrefabAsset: {fileID: 0} 382 | serializedVersion: 6 383 | m_Component: 384 | - component: {fileID: 4371580729926282751} 385 | - component: {fileID: 8858833537147361934} 386 | m_Layer: 0 387 | m_Name: Tree 388 | m_TagString: Untagged 389 | m_Icon: {fileID: 0} 390 | m_NavMeshLayer: 0 391 | m_StaticEditorFlags: 0 392 | m_IsActive: 1 393 | --- !u!4 &4371580729926282751 394 | Transform: 395 | m_ObjectHideFlags: 0 396 | m_CorrespondingSourceObject: {fileID: 0} 397 | m_PrefabInstance: {fileID: 0} 398 | m_PrefabAsset: {fileID: 0} 399 | m_GameObject: {fileID: 4026544826781710149} 400 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 401 | m_LocalPosition: {x: -0, y: 0, z: 0} 402 | m_LocalScale: {x: 1, y: 1, z: 1} 403 | m_Children: 404 | - {fileID: 3926118966855968830} 405 | - {fileID: 3926118966855968824} 406 | - {fileID: 3926118966855968826} 407 | - {fileID: 5321972603964461030} 408 | - {fileID: 4352593637748566366} 409 | - {fileID: 1571289127538631163} 410 | m_Father: {fileID: 0} 411 | m_RootOrder: 0 412 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 413 | --- !u!205 &8858833537147361934 414 | LODGroup: 415 | m_ObjectHideFlags: 0 416 | m_CorrespondingSourceObject: {fileID: 0} 417 | m_PrefabInstance: {fileID: 0} 418 | m_PrefabAsset: {fileID: 0} 419 | m_GameObject: {fileID: 4026544826781710149} 420 | serializedVersion: 2 421 | m_LocalReferencePoint: {x: 0.22991467, y: 9.409901, z: 0.69490147} 422 | m_Size: 19.546577 423 | m_FadeMode: 1 424 | m_AnimateCrossFading: 1 425 | m_LastLODIsBillboard: 0 426 | m_LODs: 427 | - screenRelativeHeight: 0.25 428 | fadeTransitionWidth: 0 429 | renderers: 430 | - renderer: {fileID: 2948092422216901565} 431 | - screenRelativeHeight: 0.125 432 | fadeTransitionWidth: 0 433 | renderers: 434 | - renderer: {fileID: 8077774035635329553} 435 | - screenRelativeHeight: 0.01 436 | fadeTransitionWidth: 0 437 | renderers: 438 | - renderer: {fileID: 7539080805507843884} 439 | m_Enabled: 1 440 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/Tree.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2747c4351dd956458844901446c26d4 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/layer_CliffAlbedoSpecular3d3aba195e4d26ee.terrainlayer: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1953259897 &8574412962073106934 4 | TerrainLayer: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: layer_CliffAlbedoSpecular3d3aba195e4d26ee 10 | m_DiffuseTexture: {fileID: 2800000, guid: 79a6f5b6ae9a4734b9cbc1440edd5952, type: 3} 11 | m_NormalMapTexture: {fileID: 0} 12 | m_MaskMapTexture: {fileID: 0} 13 | m_TileSize: {x: 15, y: 15} 14 | m_TileOffset: {x: 0, y: 0} 15 | m_Specular: {r: 0, g: 0, b: 0, a: 0} 16 | m_Metallic: 0 17 | m_Smoothness: 0 18 | m_NormalScale: 1 19 | m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0} 20 | m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1} 21 | m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0} 22 | m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1} 23 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/layer_CliffAlbedoSpecular3d3aba195e4d26ee.terrainlayer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2da7eee1123909a41ba0e197761ca3c0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8574412962073106934 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/layer_GrassHillAlbedo3d3aba195e4d26ee.terrainlayer: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1953259897 &8574412962073106934 4 | TerrainLayer: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: layer_GrassHillAlbedo3d3aba195e4d26ee 10 | m_DiffuseTexture: {fileID: 2800000, guid: 252bca6ee497d5c45a38774e4cb000e1, type: 3} 11 | m_NormalMapTexture: {fileID: 0} 12 | m_MaskMapTexture: {fileID: 0} 13 | m_TileSize: {x: 15, y: 15} 14 | m_TileOffset: {x: 0, y: 0} 15 | m_Specular: {r: 0, g: 0, b: 0, a: 0} 16 | m_Metallic: 0 17 | m_Smoothness: 0 18 | m_NormalScale: 1 19 | m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0} 20 | m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1} 21 | m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0} 22 | m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1} 23 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/layer_GrassHillAlbedo3d3aba195e4d26ee.terrainlayer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fd912eb826ce804a9bc55355e3adac1 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8574412962073106934 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/layer_GrassRockyAlbedo3d3aba195e4d26ee.terrainlayer: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1953259897 &8574412962073106934 4 | TerrainLayer: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: layer_GrassRockyAlbedo3d3aba195e4d26ee 10 | m_DiffuseTexture: {fileID: 2800000, guid: c26acf27d9382534d9a58bd79aaa14e3, type: 3} 11 | m_NormalMapTexture: {fileID: 0} 12 | m_MaskMapTexture: {fileID: 0} 13 | m_TileSize: {x: 15, y: 15} 14 | m_TileOffset: {x: 0, y: 0} 15 | m_Specular: {r: 0, g: 0, b: 0, a: 0} 16 | m_Metallic: 0 17 | m_Smoothness: 0 18 | m_NormalScale: 1 19 | m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0} 20 | m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1} 21 | m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0} 22 | m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1} 23 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/layer_GrassRockyAlbedo3d3aba195e4d26ee.terrainlayer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 211c44127815e0343a6db4e066bc034f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8574412962073106934 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/terrain.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/terrain.asset -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Arts/terrain.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 469206f46482fec4e804eedd50edc40b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 15600000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/DemoScene/Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Documentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/NNPostProcessing/Documentation.pdf -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Documentation.pdf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d0afd218605ee8468ddee6399f9638e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70db85e0f7fd23f4ba528ddfa234b6c9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Resources/Model.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a5168a864d592a43a1ef40549d13334 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Resources/Model/starry_night.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60c2974e49eaa1949b5784ca6e3acade 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Resources/NNLayer.compute: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | #pragma kernel LeakyReLU THREADS=1 3 | #pragma kernel BatchNormalization THREADS=1 4 | #pragma kernel InputLayer THREADS=1 5 | #pragma kernel OutputLayer THREADS=1 6 | #pragma kernel UpSampling2D THREADS=1 7 | #pragma kernel ReLU THREADS=1 8 | #pragma kernel Tanh THREADS=1 9 | #pragma kernel Add THREADS=1 10 | #pragma kernel Concatenate THREADS=1 11 | #pragma kernel Conv2D_8 THREADS=8 12 | #pragma kernel Conv2D_12 THREADS=12 13 | #pragma kernel Conv2D_16 THREADS=16 14 | #pragma kernel Conv2D_20 THREADS=20 15 | #pragma kernel Conv2D_32 THREADS=32 16 | #pragma kernel Conv2D_64 THREADS=64 17 | #pragma kernel Conv2D_128 THREADS=128 18 | #pragma kernel Conv2D_256 THREADS=256 19 | 20 | Texture2D InputImage; 21 | Texture2D InputImage1; 22 | RWTexture2D OutputImage; 23 | 24 | Buffer LayerInput0; 25 | Buffer LayerInput1; 26 | RWBuffer LayerOutput; 27 | Buffer Weights; 28 | uniform uint4 WeightsShape;//for conv2d: n_Hk, n_Wk, n_Ci, n_Ck; for other: size, 0, 0, 0 29 | uniform uint2 Stride; 30 | uniform uint3 InputShape;//n_Hi, n_Wi, n_Ci 31 | uniform uint3 OutputShape;//n_Ho, n_Wo, n_Co=n_Ck 32 | uniform uint3 InputShapeIdMultiplier; 33 | uniform uint3 InputShapeIdMultiplier1; 34 | uniform uint3 OutputShapeIdMultiplier; 35 | uniform uint4 WeightsShapeIdMultiplier; 36 | uniform uint2 Size; 37 | uniform half Alpha; 38 | 39 | #define n_Wk WeightsShape.y 40 | #define n_Hk WeightsShape.x 41 | #define n_Ck WeightsShape.w 42 | #define n_Wi InputShape.y 43 | #define n_Hi InputShape.x 44 | #define n_Ci InputShape.z 45 | #define n_Wo OutputShape.y 46 | #define n_Ho OutputShape.x 47 | #define n_Co OutputShape.z 48 | 49 | groupshared float cache[THREADS*4]; 50 | 51 | [numthreads(THREADS, 1, 4)] 52 | #define KERNEL_NAME(x, y) x##_##y 53 | void KERNEL_NAME(Conv2D, THREADS) 54 | (uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) 55 | { 56 | //id: outputshape 57 | uint2 InputId = id.zy * Stride; 58 | 59 | half bias = Weights[n_Wk * n_Hk * n_Ci * n_Ck + id.x]; 60 | half conv = 0; 61 | 62 | uint3 offset = uint3((n_Wk - 1) / 2, (n_Hk - 1) / 2, 0); 63 | 64 | //each kernel x 65 | for (uint p = 0; p < n_Wk; p++) { 66 | //each kernel y 67 | for (uint q = 0; q < n_Hk; q++) { 68 | 69 | int3 input_id = int3(InputId.xy, id.x) - int3(offset) + int3(p, q, 0); 70 | 71 | if (id.x < n_Ci) { 72 | //reflect padding 73 | input_id.x = input_id.x < 0 ? -input_id.x : input_id.x; 74 | input_id.y = input_id.y < 0 ? -input_id.y : input_id.y; 75 | input_id.x = input_id.x > (int)InputShape.x ? 2 * (int)InputShape.x - input_id.x : input_id.x; 76 | input_id.y = input_id.y > (int)InputShape.y ? 2 * (int)InputShape.y - input_id.y : input_id.y; 77 | 78 | cache[groupid.z * THREADS + id.x] = LayerInput0[dot(input_id.xyz, InputShapeIdMultiplier)]; 79 | } 80 | 81 | GroupMemoryBarrierWithGroupSync(); 82 | 83 | //each layer input, n_Ci = kernel z 84 | for (uint w = 0; w < n_Ci; w++) { 85 | conv += cache[groupid.z * THREADS + w] * Weights[dot(uint4(p, q, w, id.x), WeightsShapeIdMultiplier)]; 86 | } 87 | 88 | GroupMemoryBarrierWithGroupSync(); 89 | } 90 | } 91 | if (id.x < n_Co) { 92 | LayerOutput[dot(id.zyx, OutputShapeIdMultiplier)] = conv + bias; 93 | } 94 | } 95 | 96 | [numthreads(32, 1, 1)] 97 | void ReLU(uint3 id : SV_DispatchThreadID) 98 | { 99 | uint flattenid = dot(id, InputShapeIdMultiplier); 100 | LayerOutput[flattenid] = LayerInput0[flattenid] > 0 ? LayerInput0[flattenid] : 0; 101 | } 102 | 103 | [numthreads(32, 1, 1)] 104 | void Tanh(uint3 id : SV_DispatchThreadID) 105 | { 106 | uint flattenid = dot(id, InputShapeIdMultiplier); 107 | LayerOutput[flattenid] = tanh(LayerInput0[flattenid]); 108 | } 109 | 110 | [numthreads(32, 1, 1)] 111 | void LeakyReLU(uint3 id : SV_DispatchThreadID) 112 | { 113 | LayerOutput[id.x] = LayerInput0[id.x] > 0 ? LayerInput0[id.x] : LayerInput0[id.x] * Alpha; 114 | } 115 | 116 | [numthreads(8, 8, 1)] 117 | void Concatenate(uint3 id : SV_DispatchThreadID) 118 | { 119 | if (id.z < InputShape.z) { 120 | LayerOutput[dot(id, OutputShapeIdMultiplier)] = LayerInput0[dot(id, InputShapeIdMultiplier)]; 121 | } 122 | else { 123 | LayerOutput[dot(id, OutputShapeIdMultiplier)] = LayerInput1[dot(uint3(id.xy, id.z - InputShape.z), InputShapeIdMultiplier1)]; 124 | } 125 | } 126 | 127 | [numthreads(8, 8, 1)] 128 | void Add(uint3 id : SV_DispatchThreadID) 129 | { 130 | LayerOutput[dot(id, OutputShapeIdMultiplier)] = LayerInput0[dot(id, InputShapeIdMultiplier)] + LayerInput1[dot(id, InputShapeIdMultiplier)]; 131 | } 132 | 133 | //momentum trained, take parameter as population mean/std 134 | [numthreads(8, 4, 1)] 135 | void BatchNormalization(const uint3 id : SV_DispatchThreadID) 136 | { 137 | half gamma = Weights[id.z * 4]; 138 | half beta = Weights[id.z * 4 + 1]; 139 | half mov_mean = Weights[id.z * 4 + 2]; 140 | half mov_variance = Weights[id.z * 4 + 3]; 141 | 142 | half rescale = sqrt(mov_variance + 1e-3); 143 | rescale = gamma / rescale; 144 | uint flattenid = dot(id, InputShapeIdMultiplier); 145 | LayerOutput[flattenid] = LayerInput0[flattenid] * rescale - mov_mean * rescale + beta; 146 | } 147 | 148 | [numthreads(8, 8, 1)] 149 | void UpSampling2D(uint3 id : SV_DispatchThreadID) 150 | { 151 | half2 inputid = (half2)id.xy / (half2)Size.xy; 152 | uint3 floor_inputid = uint3(floor(inputid), id.z); 153 | half2 frac_inputid = inputid - floor_inputid.xy; 154 | half bilinear_interp = 155 | LayerInput0[dot(floor_inputid, InputShapeIdMultiplier)] * (1 - frac_inputid.x) * (1 - frac_inputid.y) + 156 | LayerInput0[dot(floor_inputid + uint3(1, 0, 0), InputShapeIdMultiplier)] * (frac_inputid.x) * (1 - frac_inputid.y) + 157 | LayerInput0[dot(floor_inputid + uint3(0, 1, 0), InputShapeIdMultiplier)] * (1 - frac_inputid.x) * (frac_inputid.y) + 158 | LayerInput0[dot(floor_inputid + uint3(1, 1, 0), InputShapeIdMultiplier)] * (frac_inputid.x) * (frac_inputid.y); 159 | LayerOutput[dot(id, OutputShapeIdMultiplier)] = bilinear_interp; 160 | } 161 | 162 | [numthreads(8, 8, 1)] 163 | void InputLayer(uint3 id : SV_DispatchThreadID) 164 | { 165 | uint2 remapid = uint2(id.y, InputShape.x - 1 - id.x); 166 | half3 remap = InputImage[remapid.xy] * 2.0f - 1.0f; 167 | /*if (InputShape.z == 4) { 168 | half3 remap_dep = InputImage1[remapid.xy] * 2.0f - 1.0f; 169 | LayerOutput[dot(uint3(id.xy, 3), InputShapeIdMultiplier)] = remap_dep.x; 170 | }*/ 171 | LayerOutput[dot(uint3(id.xy, 0), InputShapeIdMultiplier)] = remap.x; 172 | LayerOutput[dot(uint3(id.xy, 1), InputShapeIdMultiplier)] = remap.y; 173 | LayerOutput[dot(uint3(id.xy, 2), InputShapeIdMultiplier)] = remap.z; 174 | } 175 | 176 | [numthreads(8, 8, 1)] 177 | void OutputLayer(uint3 id : SV_DispatchThreadID) 178 | { 179 | uint2 remapid = uint2(id.y, InputShape.x - 1 - id.x); 180 | OutputImage[remapid.xy] = saturate(half3( 181 | LayerInput0[dot(uint3(id.xy, 0), InputShapeIdMultiplier)] * 0.5f + 0.5f, 182 | LayerInput0[dot(uint3(id.xy, 1), InputShapeIdMultiplier)] * 0.5f + 0.5f, 183 | LayerInput0[dot(uint3(id.xy, 2), InputShapeIdMultiplier)] * 0.5f + 0.5f)); 184 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Resources/NNLayer.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ba954e2ba57b3644b953c07c368a269 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 825335dafd4c1644a85bf2028904cf14 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNCompute.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | 7 | namespace NNPP 8 | { 9 | public class NNCompute 10 | { 11 | private static NNCompute _instance; 12 | 13 | public static NNCompute Instance 14 | { 15 | get 16 | { 17 | if (_instance == null) 18 | { 19 | _instance = new NNCompute(); 20 | _instance.Init(); 21 | } 22 | 23 | return _instance; 24 | } 25 | 26 | } 27 | 28 | private int[] Conv2DKernelLayers = new int[8] { 8, 12, 16, 20, 32, 64, 128, 256}; 29 | private int[] Conv2DKernels = new int[8]; 30 | 31 | public ComputeShader Shader; 32 | private string shaderpath = "NNLayer"; 33 | private int LeakyReluKernel, BatchNormalizationKernel, InputLayerKernel, AddKernel, 34 | ConcatenateKernel, OutputLayerKernel, UpSampling2DKernel, ReluKernel, TanhKernel; 35 | 36 | private void Init() 37 | { 38 | Conv2DKernels = new int[8]; 39 | Shader = Resources.Load(shaderpath); 40 | for (int i = 0; i < Conv2DKernelLayers.Length; i++) 41 | { 42 | Conv2DKernels[i] = Shader.FindKernel(string.Format("Conv2D_{0}", Conv2DKernelLayers[i])); 43 | } 44 | LeakyReluKernel = Shader.FindKernel("LeakyReLU"); 45 | BatchNormalizationKernel = Shader.FindKernel("BatchNormalization"); 46 | InputLayerKernel = Shader.FindKernel("InputLayer"); 47 | OutputLayerKernel = Shader.FindKernel("OutputLayer"); 48 | UpSampling2DKernel = Shader.FindKernel("UpSampling2D"); 49 | ConcatenateKernel = Shader.FindKernel("Concatenate"); 50 | ReluKernel = Shader.FindKernel("ReLU"); 51 | TanhKernel = Shader.FindKernel("Tanh"); 52 | AddKernel = Shader.FindKernel("Add"); 53 | } 54 | 55 | public int KernelConv2D(int channel) 56 | { 57 | for (int i = 0; i < Conv2DKernelLayers.Length; i++) 58 | { 59 | if (channel <= Conv2DKernelLayers[i]) 60 | { 61 | return Conv2DKernels[i]; 62 | } 63 | } 64 | return -1; 65 | } 66 | 67 | public int Kernel(string name) 68 | { 69 | switch (name) 70 | { 71 | case ("LeakyReLU"): 72 | return LeakyReluKernel; 73 | case ("BatchNormalization"): 74 | return BatchNormalizationKernel; 75 | case ("InputLayer"): 76 | return InputLayerKernel; 77 | case ("OutputLayer"): 78 | return OutputLayerKernel; 79 | case ("UpSampling2D"): 80 | return UpSampling2DKernel; 81 | case ("ReLU"): 82 | return ReluKernel; 83 | case ("Tanh"): 84 | return TanhKernel; 85 | case ("Concatenate"): 86 | return ConcatenateKernel; 87 | case ("Add"): 88 | return AddKernel; 89 | default: 90 | return -1; 91 | } 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNCompute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 472dad641becf7e4f8564da80a76455b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayerBase.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | namespace NNPP 7 | { 8 | [System.Serializable] 9 | public class NNLayerBase 10 | { 11 | public string Name; 12 | public Vector3Int InputShape; 13 | public Vector3Int OutputShape; 14 | public Vector4 WeightShape; 15 | public object Output; 16 | protected int KernelId; 17 | public NNLayerBase() 18 | { 19 | } 20 | 21 | /*public virtual void LoadWeight(KerasLayerWeightJson[] weights) 22 | { 23 | 24 | }*/ 25 | 26 | public virtual void Run(object[] input) 27 | { 28 | Output = input[0]; 29 | } 30 | 31 | public virtual void Init(Vector3Int inputShape) 32 | { 33 | InputShape = inputShape; 34 | OutputShape = inputShape; 35 | } 36 | 37 | public virtual void Release() 38 | { 39 | } 40 | 41 | public virtual void FromCache() 42 | { 43 | 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayerBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46ac9d5d60296bd4b98b3ecd01b71497 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b8a991f659ba2441ac577024923f9b4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Add.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class Add : NNLayerBase 11 | { 12 | private ComputeBuffer outputbuffer; 13 | public int AlternativeInputId; 14 | public Add() : base() 15 | { 16 | KernelId = NNCompute.Instance.Kernel("Add"); 17 | } 18 | 19 | public override void Init(Vector3Int inputShape) 20 | { 21 | base.Init(inputShape); 22 | if(outputbuffer != null) 23 | outputbuffer.Release(); 24 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 25 | Output = outputbuffer; 26 | } 27 | 28 | public override void Release() 29 | { 30 | if (outputbuffer != null) 31 | outputbuffer.Release(); 32 | } 33 | 34 | public override void Run(object[] input) 35 | { 36 | var input0 = input[0] as ComputeBuffer; 37 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input0); 38 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput1", input[1] as ComputeBuffer); 39 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 40 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 41 | { 42 | (int)InputShape.x, 43 | InputShape.y, 44 | InputShape.z 45 | }); 46 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 47 | { 48 | InputShape.y * InputShape.z, 49 | InputShape.z, 50 | 1 51 | }); 52 | NNCompute.Instance.Shader.SetInts("OutputShape", new int[3] 53 | { 54 | OutputShape.x, 55 | OutputShape.y, 56 | OutputShape.z 57 | }); 58 | NNCompute.Instance.Shader.SetInts("OutputShapeIdMultiplier", new int[3] 59 | { 60 | OutputShape.y * OutputShape.z, 61 | OutputShape.z, 62 | 1 63 | }); 64 | NNCompute.Instance.Shader.Dispatch(KernelId, Mathf.CeilToInt(OutputShape.x / 8.0f), Mathf.CeilToInt(OutputShape.y / 8.0f), OutputShape.z); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Add.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2152f2d908f1aa44986c0fd25b33d7e5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/BatchNormalization.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | [System.Serializable] 11 | public class BatchNormalization : NNLayerBase 12 | { 13 | public float[] weightcache; 14 | private ComputeBuffer weightbuffer; 15 | private ComputeBuffer outputbuffer; 16 | public BatchNormalization() : base() 17 | { 18 | KernelId = NNCompute.Instance.Kernel("BatchNormalization"); 19 | } 20 | 21 | 22 | public override void FromCache() 23 | { 24 | weightbuffer = new ComputeBuffer(weightcache.Length, sizeof(float)); 25 | weightbuffer.SetData(weightcache); 26 | weightcache = null; 27 | } 28 | /* 29 | public override void LoadWeight(KerasLayerWeightJson[] weightsKernel) 30 | { 31 | WeightShape.x = weightsKernel[0].shape[0]; 32 | float[] Weights = new float[(int)WeightShape.x * 4]; 33 | for (int i = 0; i < WeightShape.x; i++) 34 | { 35 | Weights[i * 4] = weightsKernel[0].arrayweight[i]; 36 | Weights[i * 4 + 1] = weightsKernel[1].arrayweight[i]; 37 | Weights[i * 4 + 2] = weightsKernel[2].arrayweight[i]; 38 | Weights[i * 4 + 3] = weightsKernel[3].arrayweight[i]; 39 | } 40 | if(weightbuffer !=null) 41 | weightbuffer.Release(); 42 | weightbuffer = new ComputeBuffer((int)WeightShape.x * 4, sizeof(float)); 43 | weightbuffer.SetData(Weights); 44 | }*/ 45 | 46 | public override void Init(Vector3Int inputShape) 47 | { 48 | base.Init(inputShape); 49 | if (outputbuffer != null) 50 | outputbuffer.Release(); 51 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 52 | Output = outputbuffer; 53 | } 54 | 55 | public override void Release() 56 | { 57 | if (outputbuffer != null) 58 | outputbuffer.Release(); 59 | if (weightbuffer != null) 60 | weightbuffer.Release(); 61 | } 62 | 63 | public override void Run(object[] input) 64 | { 65 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 66 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 67 | NNCompute.Instance.Shader.SetBuffer(KernelId, "Weights", weightbuffer); 68 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 69 | { 70 | InputShape.y * InputShape.z, 71 | InputShape.z, 72 | 1 73 | }); 74 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 75 | { 76 | InputShape.x, 77 | InputShape.y, 78 | InputShape.z 79 | }); 80 | NNCompute.Instance.Shader.SetInts("OutputShape", new int[3] 81 | { 82 | OutputShape.x, 83 | OutputShape.y, 84 | OutputShape.z 85 | }); 86 | //Threadgroup could exceed 65536 in high resolution, expand to 2d. 87 | NNCompute.Instance.Shader.Dispatch( 88 | KernelId, 89 | Mathf.CeilToInt(OutputShape.x / 8.0f), 90 | Mathf.CeilToInt(OutputShape.y / 4.0f), OutputShape.z); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/BatchNormalization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57eb890681fa92e40b4b9046463522f6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Concatenate.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class Concatenate : NNLayerBase 11 | { 12 | private ComputeBuffer outputbuffer; 13 | public int AlternativeInputId; 14 | public Concatenate() : base() 15 | { 16 | KernelId = NNCompute.Instance.Kernel("Concatenate"); 17 | } 18 | 19 | public override void Init(Vector3Int inputShape) 20 | { 21 | base.Init(inputShape); 22 | if (outputbuffer != null) 23 | outputbuffer.Release(); 24 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 25 | Output = outputbuffer; 26 | } 27 | 28 | public override void Release() 29 | { 30 | if (outputbuffer != null) 31 | outputbuffer.Release(); 32 | } 33 | 34 | public override void Run(object[] input) 35 | { 36 | var input0 = input[0] as ComputeBuffer; 37 | int inputfilters0 = input0.count / (OutputShape.x * OutputShape.y); 38 | int inputfilters1 = OutputShape.z - inputfilters0; 39 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input0); 40 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput1", input[1] as ComputeBuffer); 41 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 42 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 43 | { 44 | InputShape.x, 45 | InputShape.y, 46 | inputfilters0 47 | }); 48 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 49 | { 50 | InputShape.y * inputfilters0, 51 | inputfilters0, 52 | 1 53 | }); 54 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier1", new int[3] 55 | { 56 | InputShape.y * inputfilters1, 57 | inputfilters1, 58 | 1 59 | }); 60 | NNCompute.Instance.Shader.SetInts("OutputShape", new int[3] 61 | { 62 | OutputShape.x, 63 | OutputShape.y, 64 | OutputShape.z 65 | }); 66 | NNCompute.Instance.Shader.SetInts("OutputShapeIdMultiplier", new int[3] 67 | { 68 | OutputShape.y * OutputShape.z, 69 | OutputShape.z, 70 | 1 71 | }); 72 | NNCompute.Instance.Shader.Dispatch(KernelId, OutputShape.x / 8, OutputShape.y / 8, OutputShape.z); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Concatenate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ce309245fdd23c4e9540e6ffbe7f621 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Conv2D.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using UnityEngine; 7 | using UnityEngine.Rendering; 8 | 9 | namespace NNPP 10 | { 11 | [System.Serializable] 12 | public class Conv2D : NNLayerBase 13 | { 14 | public float[] weightcache; 15 | public int Filters; 16 | public Vector2Int KernalSize; 17 | public Vector2Int Stride; 18 | private ComputeBuffer outputbuffer; 19 | private ComputeBuffer weightbuffer; 20 | public Conv2D() : base() 21 | { 22 | KernelId = NNCompute.Instance.KernelConv2D(32); 23 | } 24 | 25 | public override void FromCache() 26 | { 27 | weightbuffer = new ComputeBuffer(weightcache.Length, sizeof(float)); 28 | weightbuffer.SetData(weightcache); 29 | weightcache = null; 30 | } 31 | /* 32 | public override void LoadWeight(KerasLayerWeightJson[] weightsKernel) 33 | { 34 | WeightShape = new Vector4(weightsKernel[0].shape[0], 35 | weightsKernel[0].shape[1], 36 | weightsKernel[0].shape[2], 37 | weightsKernel[0].shape[3]); 38 | int kernel_weight_length = (int)(WeightShape.x * WeightShape.y * WeightShape.z * WeightShape.w); 39 | int bias_weight_length = (int)WeightShape.w; 40 | float[] Weights = new float[kernel_weight_length + bias_weight_length]; 41 | for (int i = 0; i < WeightShape.x; i++) 42 | { 43 | for (int j = 0; j < WeightShape.y; j++) 44 | { 45 | for (int k = 0; k < WeightShape.z; k++) 46 | { 47 | for (int w = 0; w < WeightShape.w; w++) 48 | { 49 | float arrayindex = i * WeightShape.y * WeightShape.z * WeightShape.w + 50 | j * WeightShape.z * WeightShape.w + 51 | k * WeightShape.w + 52 | w; 53 | Weights[(int)arrayindex] = weightsKernel[0].kernelweight[i, j, k, w]; 54 | } 55 | } 56 | } 57 | } 58 | Array.Copy(weightsKernel[1].arrayweight, 0, Weights, kernel_weight_length, bias_weight_length); 59 | if (weightbuffer != null) 60 | weightbuffer.Release(); 61 | weightbuffer = new ComputeBuffer(kernel_weight_length + bias_weight_length, sizeof(float)); 62 | weightbuffer.SetData(Weights); 63 | } 64 | */ 65 | public override void Init(Vector3Int inputShape) 66 | { 67 | InputShape = inputShape; 68 | OutputShape = new Vector3Int(inputShape.x / Stride.x, inputShape.y / Stride.y, Filters); 69 | if (outputbuffer != null) 70 | outputbuffer.Release(); 71 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 72 | int maxfilter = Mathf.Max(inputShape.z, Filters); 73 | KernelId = NNCompute.Instance.KernelConv2D(maxfilter); 74 | Output = outputbuffer; 75 | } 76 | 77 | public override void Release() 78 | { 79 | if (weightbuffer != null) 80 | weightbuffer.Release(); 81 | if (outputbuffer != null) 82 | outputbuffer.Release(); 83 | } 84 | 85 | public override void Run(object[] input) 86 | { 87 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 88 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 89 | NNCompute.Instance.Shader.SetBuffer(KernelId, "Weights", weightbuffer); 90 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 91 | { 92 | InputShape.x, 93 | InputShape.y, 94 | InputShape.z 95 | }); 96 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 97 | { 98 | InputShape.y * InputShape.z, 99 | InputShape.z, 100 | 1 101 | }); 102 | NNCompute.Instance.Shader.SetInts("OutputShape", new int[3] 103 | { 104 | OutputShape.x, 105 | OutputShape.y, 106 | OutputShape.z 107 | }); 108 | NNCompute.Instance.Shader.SetInts("OutputShapeIdMultiplier", new int[3] 109 | { 110 | OutputShape.y * OutputShape.z, 111 | OutputShape.z, 112 | 1 113 | }); 114 | NNCompute.Instance.Shader.SetInts("WeightsShape", new int[4] 115 | { 116 | KernalSize.x, 117 | KernalSize.y, 118 | InputShape.z, 119 | Filters 120 | }); 121 | NNCompute.Instance.Shader.SetInts("WeightsShapeIdMultiplier", new int[4] 122 | { 123 | KernalSize.y * InputShape.z * Filters, 124 | InputShape.z * Filters, 125 | Filters, 126 | 1 127 | }); 128 | NNCompute.Instance.Shader.SetInts("Stride", new int[2] 129 | { 130 | Stride.x, 131 | Stride.y 132 | }); 133 | NNCompute.Instance.Shader.Dispatch(KernelId, 1, OutputShape.y, Mathf.CeilToInt(OutputShape.x/4.0f)); 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Conv2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d5a9002d5bf87544a04bf44994a8e6c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/InputLayer.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class InputLayer : NNLayerBase 11 | { 12 | private ComputeBuffer outputbuffer; 13 | public int InputChannels; 14 | public RenderTexture src; 15 | public InputLayer() : base() 16 | { 17 | KernelId = NNCompute.Instance.Kernel("InputLayer"); 18 | } 19 | 20 | public override void Run(object[] input) 21 | { 22 | 23 | NNCompute.Instance.Shader.SetTexture(KernelId, "InputImage", src); 24 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 25 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 26 | { 27 | InputShape.x, 28 | InputShape.y, 29 | InputShape.z 30 | }); 31 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 32 | { 33 | InputShape.y * InputShape.z, 34 | InputShape.z, 35 | 1 36 | }); 37 | NNCompute.Instance.Shader.Dispatch(KernelId, Mathf.CeilToInt(InputShape.x / 8.0f), Mathf.CeilToInt(InputShape.y / 8.0f), 1); 38 | } 39 | 40 | public override void Init(Vector3Int inputShape) 41 | { 42 | base.Init(inputShape); 43 | if(outputbuffer !=null) 44 | outputbuffer.Release(); 45 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 46 | Output = outputbuffer; 47 | } 48 | 49 | public override void Release() 50 | { 51 | if (outputbuffer != null) 52 | outputbuffer.Release(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/InputLayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e026548aea883a45a6ad4a45f11bfa7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/LeakyReLU.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class LeakyReLU : ReLU 11 | { 12 | public float Alpha; 13 | public LeakyReLU() : base() 14 | { 15 | KernelId = NNCompute.Instance.Kernel("LeakyReLU"); 16 | } 17 | 18 | public override void Run(object[] input) 19 | { 20 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 21 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 22 | NNCompute.Instance.Shader.SetFloat("Alpha", Alpha); 23 | NNCompute.Instance.Shader.Dispatch(KernelId, Mathf.CeilToInt(OutputShape.x * OutputShape.y * OutputShape.z / 32.0f), 1, 1); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/LeakyReLU.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09c5d394d9cbf764ea4e95354b9b1be5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/OutputLayer.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class OutputLayer : NNLayerBase 11 | { 12 | public RenderTexture outputTex; 13 | public OutputLayer() : base() 14 | { 15 | KernelId = NNCompute.Instance.Kernel("OutputLayer"); 16 | } 17 | 18 | public override void Run(object[] input) 19 | { 20 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 21 | NNCompute.Instance.Shader.SetTexture(KernelId, "OutputImage", outputTex); 22 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 23 | { 24 | InputShape.x, 25 | InputShape.y, 26 | InputShape.z 27 | }); 28 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 29 | { 30 | InputShape.y * InputShape.z, 31 | InputShape.z, 32 | 1 33 | }); 34 | NNCompute.Instance.Shader.Dispatch(KernelId, OutputShape.x / 8, OutputShape.y / 8, 1); 35 | } 36 | 37 | public override void Init(Vector3Int inputShape) 38 | { 39 | base.Init(inputShape); 40 | if (outputTex != null) 41 | outputTex.Release(); 42 | outputTex = new RenderTexture(OutputShape.y, OutputShape.x, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); 43 | outputTex.enableRandomWrite = true; 44 | outputTex.Create(); 45 | } 46 | 47 | public override void Release() 48 | { 49 | if (outputTex != null) 50 | outputTex.Release(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/OutputLayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfc33a23ef2a63146a4dc9fdc3fe5796 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/ReLU.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class ReLU : NNLayerBase 11 | { 12 | protected ComputeBuffer outputbuffer; 13 | public ReLU() : base() 14 | { 15 | KernelId = NNCompute.Instance.Kernel("ReLU"); 16 | } 17 | 18 | public override void Init(Vector3Int inputShape) 19 | { 20 | base.Init(inputShape); 21 | if (outputbuffer != null) 22 | outputbuffer.Release(); 23 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 24 | Output = outputbuffer; 25 | } 26 | 27 | public override void Release() 28 | { 29 | if (outputbuffer != null) 30 | outputbuffer.Release(); 31 | } 32 | 33 | public override void Run(object[] input) 34 | { 35 | //Unity2019 refuse threadgroup > 65536, so we make a 2d input threadgroup 36 | int threadGroupX = Mathf.CeilToInt(OutputShape.y * OutputShape.z / 32.0f); 37 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 38 | { 39 | OutputShape.x, 40 | 1, 41 | 1 42 | }); 43 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 44 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 45 | NNCompute.Instance.Shader.Dispatch(KernelId, threadGroupX, OutputShape.x, 1); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/ReLU.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e80f6e5637ec3e46b694698aa2d3e26 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Tanh.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class Tanh : NNLayerBase 11 | { 12 | private ComputeBuffer outputbuffer; 13 | public Tanh() : base() 14 | { 15 | KernelId = NNCompute.Instance.Kernel("Tanh"); 16 | } 17 | 18 | public override void Init(Vector3Int inputShape) 19 | { 20 | base.Init(inputShape); 21 | if (outputbuffer != null) 22 | outputbuffer.Release(); 23 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 24 | Output = outputbuffer; 25 | } 26 | 27 | public override void Release() 28 | { 29 | if (outputbuffer != null) 30 | outputbuffer.Release(); 31 | } 32 | 33 | public override void Run(object[] input) 34 | { 35 | //Unity2019 refuse threadgroup > 65536, so we make a 2d input threadgroup 36 | int threadGroupX = Mathf.CeilToInt(OutputShape.y * OutputShape.z / 32.0f); 37 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 38 | { 39 | OutputShape.x, 40 | 1, 41 | 1 42 | }); 43 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 44 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 45 | NNCompute.Instance.Shader.Dispatch(KernelId, threadGroupX, OutputShape.x, 1); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/Tanh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6564cf44fd84a5349ad86352d5f03edf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/UpSampling2D.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | public class UpSampling2D : NNLayerBase 11 | { 12 | public Vector2Int Size; 13 | private ComputeBuffer outputbuffer; 14 | public UpSampling2D() : base() 15 | { 16 | KernelId = NNCompute.Instance.Kernel("UpSampling2D"); 17 | } 18 | public override void Init(Vector3Int inputShape) 19 | { 20 | InputShape = inputShape; 21 | OutputShape = new Vector3Int(inputShape.x * Size.x, inputShape.y * Size.y, inputShape.z); 22 | if (outputbuffer != null) 23 | outputbuffer.Release(); 24 | outputbuffer = new ComputeBuffer(OutputShape.x * OutputShape.y * OutputShape.z, sizeof(float)); 25 | Output = outputbuffer; 26 | } 27 | 28 | public override void Release() 29 | { 30 | if (outputbuffer != null) 31 | outputbuffer.Release(); 32 | } 33 | 34 | public override void Run(object[] input) 35 | { 36 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerInput0", input[0] as ComputeBuffer); 37 | NNCompute.Instance.Shader.SetBuffer(KernelId, "LayerOutput", outputbuffer); 38 | NNCompute.Instance.Shader.SetInts("InputShape", new int[3] 39 | { 40 | InputShape.x, 41 | InputShape.y, 42 | InputShape.z 43 | }); 44 | NNCompute.Instance.Shader.SetInts("InputShapeIdMultiplier", new int[3] 45 | { 46 | InputShape.y * InputShape.z, 47 | InputShape.z, 48 | 1 49 | }); 50 | NNCompute.Instance.Shader.SetInts("OutputShape", new int[3] 51 | { 52 | OutputShape.x, 53 | OutputShape.y, 54 | OutputShape.z 55 | }); 56 | NNCompute.Instance.Shader.SetInts("OutputShapeIdMultiplier", new int[3] 57 | { 58 | OutputShape.y * OutputShape.z, 59 | OutputShape.z, 60 | 1 61 | }); 62 | NNCompute.Instance.Shader.SetInts("Size", new int[2] 63 | { 64 | Size.x, 65 | Size.y 66 | }); 67 | NNCompute.Instance.Shader.Dispatch(KernelId, Mathf.CeilToInt(OutputShape.x / 8.0f), Mathf.CeilToInt(OutputShape.y / 8.0f), OutputShape.z); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNLayers/UpSampling2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5099380f95fc2c44bce351b7c8821c8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNModel.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | //#define DEBUG_LAYER 3 | 4 | using System; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | #if UNITY_EDITOR 8 | using UnityEditor; 9 | #endif 10 | using UnityEngine; 11 | using UnityEngine.Rendering; 12 | 13 | 14 | namespace NNPP 15 | { 16 | public class NNModel 17 | { 18 | public List Layers; 19 | private InputLayer Input; 20 | private OutputLayer Output; 21 | #if DEBUG_LAYER 22 | public int debug_layer = 0; 23 | #endif 24 | public void Load(string name) 25 | { 26 | TextAsset text = Resources.Load("Model/" + name); 27 | NNModelSerialize modelSerialize = JsonUtility.FromJson(text.text); 28 | 29 | Layers = new List(); 30 | for (int i = 0; i < modelSerialize.LayerJson.Count; i++) 31 | { 32 | var nnlayer = JsonUtility.FromJson(modelSerialize.LayerJson[i], 33 | Type.GetType(modelSerialize.LayerTypes[i])) as NNLayerBase; 34 | nnlayer.FromCache(); 35 | Layers.Add(nnlayer); 36 | if (i == 0) Input = nnlayer as InputLayer; 37 | } 38 | Output = new OutputLayer(); 39 | } 40 | 41 | public void Init(int height, int width) 42 | { 43 | Input.Init(new Vector3Int(height, width, Input.InputChannels)); 44 | #if !DEBUG_LAYER 45 | for (int i = 1; i < Layers.Count; i++) 46 | #else 47 | for (int i = 1; i < debug_layer + 1; i++) 48 | #endif 49 | { 50 | if (Layers[i] is Concatenate) 51 | { 52 | Vector3Int input1 = Layers[i - 1].OutputShape; 53 | Vector3Int input2 = Layers[(Layers[i] as Concatenate).AlternativeInputId].OutputShape; 54 | Layers[i].Init(new Vector3Int(input1.x, input1.y, input1.z + input2.z)); 55 | } 56 | else 57 | { 58 | Layers[i].Init(Layers[i - 1].OutputShape); 59 | } 60 | } 61 | #if !DEBUG_LAYER 62 | Output.Init(Layers[Layers.Count - 1].OutputShape); 63 | #else 64 | Output.Init(Layers[debug_layer].OutputShape); 65 | #endif 66 | } 67 | private int _height, _width; 68 | 69 | private void Setup(RenderTexture src) 70 | { 71 | if (_height != src.height || _width != src.width) 72 | { 73 | Init(src.height, src.width); 74 | _height = src.height; 75 | _width = src.width; 76 | } 77 | Input.src = src; 78 | } 79 | 80 | public RenderTexture Predict(RenderTexture src) 81 | { 82 | Setup(src); 83 | Input.Run(null); 84 | #if !DEBUG_LAYER 85 | for (int i = 1; i < Layers.Count; i++) 86 | #else 87 | for (int i = 1; i < debug_layer + 1; i++) 88 | #endif 89 | { 90 | if (Layers[i] is Concatenate) 91 | { 92 | Layers[i].Run(new object[2] 93 | { 94 | Layers[i - 1].Output, 95 | Layers[(Layers[i] as Concatenate).AlternativeInputId].Output, 96 | }); 97 | } 98 | else if (Layers[i] is Add) 99 | { 100 | Layers[i].Run(new object[2] 101 | { 102 | Layers[i - 1].Output, 103 | Layers[(Layers[i] as Add).AlternativeInputId].Output, 104 | }); 105 | } 106 | else 107 | { 108 | Layers[i].Run(new object[1] {Layers[i - 1].Output}); 109 | } 110 | } 111 | #if !DEBUG_LAYER 112 | Output.Run(new object[1] { Layers[Layers.Count - 1].Output }); 113 | #else 114 | Output.Run(new object[1] { Layers[debug_layer].Output }); 115 | #endif 116 | return Output.outputTex; 117 | } 118 | 119 | public void Release() 120 | { 121 | foreach (var layer in Layers) 122 | { 123 | layer.Release(); 124 | } 125 | Input.Release(); 126 | Output.Release(); 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47e291716b0d4044fbc9fdd904a3f3fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNModelSerialize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class NNModelSerialize 7 | { 8 | public List LayerTypes; 9 | public List LayerJson; 10 | 11 | public NNModelSerialize() 12 | { 13 | LayerTypes = new List(); 14 | LayerJson = new List(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNModelSerialize.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83dd8e570301ed6418340a7bbcbc3b0e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNPostProcessingEffect.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEngine; 6 | using UnityEngine.Rendering; 7 | 8 | namespace NNPP 9 | { 10 | 11 | [System.Serializable] 12 | [RequireComponent(typeof(Camera))] 13 | public class NNPostProcessingEffect : MonoBehaviour 14 | { 15 | public NNStyle style = NNStyle.starry_night; 16 | 17 | private NNModel model; 18 | 19 | void Start() 20 | { 21 | model = new NNModel(); 22 | model.Load(style.ToString()); 23 | } 24 | 25 | void OnDisable() 26 | { 27 | model.Release(); 28 | } 29 | 30 | void OnRenderImage(RenderTexture src, RenderTexture dst) 31 | { 32 | var predict = model.Predict(src); 33 | Graphics.Blit(predict, dst); 34 | } 35 | 36 | } 37 | 38 | public enum NNStyle 39 | { 40 | des_glaneuses, 41 | la_muse, 42 | mirror, 43 | sketch, 44 | starry_night, 45 | udnie, 46 | wave 47 | } 48 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/NNPostProcessingEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e417fb013ae2d944a0ee5615c07bcaf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/SimpleCharacterController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | [RequireComponent(typeof (Rigidbody))] 5 | [RequireComponent(typeof (CapsuleCollider))] 6 | public class SimpleCharacterController : MonoBehaviour 7 | { 8 | public float Speed = 8.0f; 9 | public Camera cam; 10 | 11 | private Rigidbody m_RigidBody; 12 | private float m_YRotation; 13 | 14 | private Quaternion m_CharacterTargetRot; 15 | private Quaternion m_CameraTargetRot; 16 | 17 | private void Start() 18 | { 19 | m_RigidBody = GetComponent(); 20 | 21 | m_CharacterTargetRot = transform.localRotation; 22 | m_CameraTargetRot = cam.transform.localRotation; 23 | } 24 | 25 | 26 | private void Update() 27 | { 28 | if (Mathf.Abs(Time.timeScale) < float.Epsilon) return; 29 | 30 | float oldYRotation = transform.eulerAngles.y; 31 | 32 | float yRot = Input.GetAxis("Mouse X") * 2; 33 | float xRot = Input.GetAxis("Mouse Y") * 2; 34 | 35 | m_CharacterTargetRot *= Quaternion.Euler(0f, yRot, 0f); 36 | m_CameraTargetRot *= Quaternion.Euler(-xRot, 0f, 0f); 37 | 38 | transform.localRotation = m_CharacterTargetRot; 39 | cam.transform.localRotation = m_CameraTargetRot; 40 | 41 | Quaternion velRotation = Quaternion.AngleAxis(transform.eulerAngles.y - oldYRotation, Vector3.up); 42 | m_RigidBody.velocity = velRotation * m_RigidBody.velocity; 43 | } 44 | 45 | 46 | private void FixedUpdate() 47 | { 48 | Vector2 input = new Vector2 49 | { 50 | x = Input.GetAxis("Horizontal"), 51 | y = Input.GetAxis("Vertical") 52 | }; 53 | 54 | if ((Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon)) 55 | { 56 | Vector3 desiredMove = cam.transform.forward*input.y + cam.transform.right*input.x; 57 | desiredMove = Vector3.ProjectOnPlane(desiredMove, Vector3.up).normalized; 58 | 59 | desiredMove *= Speed; 60 | if (m_RigidBody.velocity.sqrMagnitude < 61 | (Speed * Speed)) 62 | { 63 | m_RigidBody.AddForce(desiredMove, ForceMode.Impulse); 64 | } 65 | } 66 | m_RigidBody.drag = 5f; 67 | } 68 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/NNPostProcessing/Scripts/SimpleCharacterController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81c9795a96c094f4cbde4d65546aa9b2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcc8a002c59d725478d9643876a41e1e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/KerasJsonParser.cs: -------------------------------------------------------------------------------- 1 | // neural network post-processing 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace NNPPUtil 6 | { 7 | 8 | [System.Serializable] 9 | public class KerasJson 10 | { 11 | public KerasModelJson model; 12 | public List weights; 13 | } 14 | 15 | [System.Serializable] 16 | public class KerasLayerWeightJson 17 | { 18 | public int[] shape; 19 | public float[] arrayweight; 20 | public float[,,,] kernelweight; 21 | } 22 | 23 | [System.Serializable] 24 | public class KerasModelJson 25 | { 26 | public string class_name; 27 | public KerasLayersJson config; 28 | } 29 | 30 | [System.Serializable] 31 | public class KerasLayersJson 32 | { 33 | public string name; 34 | public KerasLayerJson[] layers; 35 | } 36 | 37 | [System.Serializable] 38 | public class KerasLayerJson 39 | { 40 | public string name; 41 | public string class_name; 42 | public KerasLayerConfigJson config; 43 | public List>> inbound_nodes; 44 | } 45 | 46 | [System.Serializable] 47 | public class KerasLayerConfigJson 48 | { 49 | public string[] batch_input_shape; 50 | public string name; 51 | public int filters; 52 | public int[] kernel_size; 53 | public int[] strides; 54 | public int[] size; 55 | public float alpha; 56 | public string activation; 57 | } 58 | } -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/KerasJsonParser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 831693c5ae8069840bd8ec5035e1e607 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/NNLayerExtention.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using NNPP; 5 | using UnityEngine; 6 | 7 | namespace NNPPUtil 8 | { 9 | public static class NNLayerExtention { 10 | 11 | public static void LoadWeight(this BatchNormalization layer, KerasLayerWeightJson[] weightsKernel) 12 | { 13 | layer.WeightShape.x = weightsKernel[0].shape[0]; 14 | layer.weightcache = new float[(int)layer.WeightShape.x * 4]; 15 | for (int i = 0; i < layer.WeightShape.x; i++) 16 | { 17 | layer.weightcache[i * 4] = weightsKernel[0].arrayweight[i]; 18 | layer.weightcache[i * 4 + 1] = weightsKernel[1].arrayweight[i]; 19 | layer.weightcache[i * 4 + 2] = weightsKernel[2].arrayweight[i]; 20 | layer.weightcache[i * 4 + 3] = weightsKernel[3].arrayweight[i]; 21 | } 22 | } 23 | 24 | public static void LoadWeight(this Conv2D layer, KerasLayerWeightJson[] weightsKernel) 25 | { 26 | Vector4 WeightShape = new Vector4(weightsKernel[0].shape[0], 27 | weightsKernel[0].shape[1], 28 | weightsKernel[0].shape[2], 29 | weightsKernel[0].shape[3]); 30 | layer.WeightShape = WeightShape; 31 | int kernel_weight_length = (int)(WeightShape.x * WeightShape.y * WeightShape.z * WeightShape.w); 32 | int bias_weight_length = (int)WeightShape.w; 33 | layer.weightcache = new float[kernel_weight_length + bias_weight_length]; 34 | for (int i = 0; i < WeightShape.x; i++) 35 | { 36 | for (int j = 0; j < WeightShape.y; j++) 37 | { 38 | for (int k = 0; k < WeightShape.z; k++) 39 | { 40 | for (int w = 0; w < WeightShape.w; w++) 41 | { 42 | float arrayindex = i * WeightShape.y * WeightShape.z * WeightShape.w + 43 | j * WeightShape.z * WeightShape.w + 44 | k * WeightShape.w + 45 | w; 46 | layer.weightcache[(int)arrayindex] = weightsKernel[0].kernelweight[i, j, k, w]; 47 | } 48 | } 49 | } 50 | } 51 | Array.Copy(weightsKernel[1].arrayweight, 0, layer.weightcache, kernel_weight_length, bias_weight_length); 52 | } 53 | 54 | public static void LoadConfig(this Conv2D layer, KerasLayerConfigJson config) 55 | { 56 | layer.Filters = config.filters; 57 | layer.KernalSize = new Vector2Int(config.kernel_size[0], config.kernel_size[1]); 58 | layer.Stride = new Vector2Int(config.strides[0], config.strides[1]); 59 | } 60 | 61 | public static void LoadConfig(this InputLayer layer, KerasLayerConfigJson config) 62 | { 63 | layer.InputChannels = int.Parse(config.batch_input_shape[3]); 64 | } 65 | 66 | public static void LoadConfig(this LeakyReLU layer, KerasLayerConfigJson config) 67 | { 68 | layer.Alpha = config.alpha; 69 | } 70 | 71 | public static void LoadConfig(this UpSampling2D layer, KerasLayerConfigJson config) 72 | { 73 | layer.Size = new Vector2Int(config.size[0], config.size[1]); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/NNLayerExtention.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b089932aca50f3543824bb65cd72b783 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/NNRawModelParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using NNPP; 5 | using UnityEditor; 6 | using UnityEngine; 7 | using Newtonsoft.Json; 8 | 9 | namespace NNPPUtil 10 | { 11 | public class NNRawModelParser : MonoBehaviour 12 | { 13 | [MenuItem("Assets/ParseFromRawModel")] 14 | public static void Parse() 15 | { 16 | TextAsset tex = Selection.activeObject as TextAsset; 17 | 18 | var allLayers = ParseAllLayers(tex.text); 19 | NNModelSerialize modeljson = new NNModelSerialize(); 20 | foreach (var layer in allLayers) 21 | { 22 | object derivetype = Convert.ChangeType(layer, layer.GetType()); 23 | string value = JsonUtility.ToJson(derivetype, true); 24 | modeljson.LayerTypes.Add(layer.GetType().FullName); 25 | modeljson.LayerJson.Add(value); 26 | } 27 | 28 | string serialized = JsonUtility.ToJson(modeljson); 29 | string outpath = Application.dataPath + "/NNPostProcessing/Resources/Model/" + tex.name + ".json"; 30 | Debug.Log(outpath); 31 | System.IO.File.WriteAllText(outpath, serialized); 32 | 33 | foreach (var layer in allLayers) 34 | { 35 | layer.Release(); 36 | } 37 | } 38 | 39 | public static List ParseAllLayers(string text) 40 | { 41 | List Layers = new List(); 42 | var modeljson = JsonConvert.DeserializeObject(text); 43 | LoadModel(modeljson.model.config, Layers); 44 | LoadWeight(modeljson.weights, Layers); 45 | return Layers; 46 | } 47 | 48 | private static void LoadModel(KerasLayersJson layersJson, List Layers) 49 | { 50 | foreach (var layer in layersJson.layers) 51 | { 52 | switch (layer.class_name) 53 | { 54 | case "InputLayer": 55 | var Input = new InputLayer(); 56 | Input.LoadConfig(layer.config); 57 | Layers.Add(Input); 58 | break; 59 | case "Activation": 60 | if (layer.config.activation == "relu") 61 | { 62 | Layers.Add(new ReLU()); 63 | } 64 | 65 | if (layer.config.activation == "tanh") 66 | { 67 | Layers.Add(new Tanh()); 68 | } 69 | 70 | break; 71 | case "Conv2D": 72 | var Conv2DLayer = new Conv2D(); 73 | Conv2DLayer.LoadConfig(layer.config); 74 | Layers.Add(Conv2DLayer); 75 | if (layer.config.activation == "relu") 76 | { 77 | Layers.Add(new ReLU()); 78 | } 79 | 80 | if (layer.config.activation == "tanh") 81 | { 82 | Layers.Add(new Tanh()); 83 | } 84 | 85 | break; 86 | case "LeakyReLU": 87 | var LeakyReLULayer = new LeakyReLU(); 88 | LeakyReLULayer.LoadConfig(layer.config); 89 | Layers.Add(LeakyReLULayer); 90 | break; 91 | case "BatchNormalization": 92 | Layers.Add(new BatchNormalization()); 93 | break; 94 | case "UpSampling2D": 95 | var UpSampling2DLayer = new UpSampling2D(); 96 | UpSampling2DLayer.LoadConfig(layer.config); 97 | Layers.Add(UpSampling2DLayer); 98 | break; 99 | case "Concatenate": 100 | var thislayer = new Concatenate(); 101 | string alternativeLayerName = layer.inbound_nodes[0][1][0] as string; 102 | thislayer.AlternativeInputId = 103 | Layers.FindIndex(ly => string.Compare(ly.Name, alternativeLayerName) == 0); 104 | Layers.Add(thislayer); 105 | break; 106 | case "Add": 107 | var addlayer = new Add(); 108 | int alterinput = layer.inbound_nodes[0].FindIndex(node => 109 | string.Compare(node[0] as string, Layers[Layers.Count - 1].Name) != 0); 110 | string addalternativeLayerName = layer.inbound_nodes[0][alterinput][0] as string; 111 | addlayer.AlternativeInputId = 112 | Layers.FindIndex(ly => string.Compare(ly.Name, addalternativeLayerName) == 0); 113 | Layers.Add(addlayer); 114 | break; 115 | } 116 | 117 | Layers[Layers.Count - 1].Name = layer.name; 118 | } 119 | } 120 | 121 | private static void LoadWeight(List weights, List Layers) 122 | { 123 | int weightcount = 0; 124 | for (int i = 0; i < Layers.Count; i++) 125 | { 126 | if (Layers[i] is Conv2D) 127 | { 128 | (Layers[i] as Conv2D).LoadWeight(new KerasLayerWeightJson[2] 129 | { 130 | weights[weightcount], 131 | weights[weightcount + 1] 132 | }); 133 | weightcount += 2; 134 | } 135 | 136 | if (Layers[i] is BatchNormalization) 137 | { 138 | (Layers[i] as BatchNormalization).LoadWeight(new KerasLayerWeightJson[4] 139 | { 140 | weights[weightcount], 141 | weights[weightcount + 1], 142 | weights[weightcount + 2], 143 | weights[weightcount + 3] 144 | }); 145 | weightcount += 4; 146 | } 147 | } 148 | } 149 | } 150 | } 151 | 152 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/NNRawModelParser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fa4aae1df45b824785b24be8c403700 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNPostProcessing/Assets/Script/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Newtonsoft.Json.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d478ef95e5543f14bba1193467ac3f61 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | isPreloaded: 0 9 | isOverridable: 0 10 | platformData: 11 | - first: 12 | Any: 13 | second: 14 | enabled: 1 15 | settings: {} 16 | - first: 17 | Editor: Editor 18 | second: 19 | enabled: 0 20 | settings: 21 | DefaultValueInitialized: true 22 | - first: 23 | Windows Store Apps: WindowsStoreApps 24 | second: 25 | enabled: 0 26 | settings: 27 | CPU: AnyCPU 28 | userData: 29 | assetBundleName: 30 | assetBundleVariant: 31 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d578635c9467aa40ab2f68c4ad7a3f7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail/CameraTrail.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class CameraTrail : ScriptableObject 6 | { 7 | 8 | public List Positions; 9 | public List Rotations; 10 | 11 | public CameraTrail() 12 | { 13 | Positions = new List(); 14 | Rotations = new List(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail/CameraTrail.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 192a94c8f9dfccb42aa3ff05594abfdd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail/TrailPlayer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TrailPlayer : MonoBehaviour { 6 | 7 | public CameraTrail tr; 8 | 9 | public int FrameInterval = 5; 10 | // Use this for initialization 11 | void Start () { 12 | 13 | } 14 | 15 | // Update is called once per frame 16 | void Update () 17 | { 18 | int frame = Time.frameCount * FrameInterval; 19 | 20 | if (frame < tr.Positions.Count) 21 | { 22 | Vector3 pos = tr.Positions[frame]; 23 | Quaternion rot = tr.Rotations[frame]; 24 | transform.SetPositionAndRotation(pos, rot); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail/TrailPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80a76c3ccd4b567468639afdeedfb58f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail/TrailRecorder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | public class TrailRecorder : MonoBehaviour 7 | { 8 | 9 | private CameraTrail tr; 10 | // Use this for initialization 11 | void Start () 12 | { 13 | tr = ScriptableObject.CreateInstance(); 14 | } 15 | 16 | // Update is called once per frame 17 | void Update () { 18 | tr.Positions.Add(transform.position); 19 | tr.Rotations.Add(transform.rotation); 20 | } 21 | 22 | void OnDisable() 23 | { 24 | AssetDatabase.CreateAsset(tr, "Assets/Script/trail.asset"); 25 | AssetDatabase.SaveAssets(); 26 | Debug.Log("exit"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Trail/TrailRecorder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 893894246211adb43947effe34b29cba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f22a33136a02c34a99443adc0ed66a3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/NNDebug.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NNPP; 4 | using UnityEngine; 5 | using UnityEditor; 6 | using UnityEngine.Rendering; 7 | 8 | public class NNDebug : MonoBehaviour { 9 | 10 | [MenuItem("Assets/test")] 11 | public static void debug() 12 | { 13 | Texture tex = Selection.activeObject as Texture; 14 | Debug.Log(tex); 15 | 16 | var source = new RenderTexture(tex.width, tex.height,0); 17 | Graphics.Blit(tex, source); 18 | 19 | for (int i = 1; i < 32; i++) 20 | { 21 | NNModel model = new NNModel(); 22 | //model.debug_layer = i; 23 | model.Load("starry_night"); 24 | var dst = model.Predict(source); 25 | 26 | SaveRTToFile(dst, i); 27 | 28 | model.Release(); 29 | } 30 | } 31 | 32 | public static void SaveRTToFile(RenderTexture rt, int id) 33 | { 34 | RenderTexture.active = rt; 35 | Texture2D tex = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false); 36 | tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); 37 | RenderTexture.active = null; 38 | 39 | byte[] bytes; 40 | bytes = tex.EncodeToPNG(); 41 | 42 | string path = Application.dataPath + "/Art/out_" + id + ".png"; 43 | System.IO.File.WriteAllBytes(path, bytes); 44 | AssetDatabase.ImportAsset(path); 45 | Debug.Log("Saved to " + path); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/NNDebug.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ad2599a194562047b98778c2490178b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/RenderDepth.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RenderDepth : MonoBehaviour 6 | { 7 | void Start() 8 | { 9 | gameObject.GetComponent().depthTextureMode = DepthTextureMode.DepthNormals; 10 | } 11 | 12 | public Material mat; 13 | void OnRenderImage(RenderTexture src, RenderTexture dst) 14 | { 15 | Graphics.Blit(src, dst, mat); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/RenderDepth.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 432a056422ecc9c4e92445c88072a8ea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/copydepth.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Unlit/copydepth" 4 | { 5 | Properties{ 6 | _MainTex("", 2D) = "" {} 7 | } 8 | Subshader{ 9 | 10 | // -- DepthTextureCopy 11 | Pass{ 12 | ZTest Always Cull Off ZWrite Off Fog{ Mode Off } 13 | 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | #pragma fragmentoption ARB_precision_hint_fastest 18 | 19 | #include "UnityCG.cginc" 20 | 21 | float4 _CameraDepthNormalsTexture_ST; 22 | sampler2D _CameraDepthNormalsTexture; 23 | 24 | struct appdata_t { 25 | float4 vertex : POSITION; 26 | float2 texcoord : TEXCOORD0; 27 | }; 28 | 29 | struct v2f { 30 | float4 vertex : POSITION; 31 | float2 texcoord : TEXCOORD0; 32 | }; 33 | 34 | v2f vert(appdata_t v) 35 | { 36 | v2f o; 37 | o.vertex = UnityObjectToClipPos(v.vertex); 38 | o.texcoord = TRANSFORM_TEX(v.texcoord, _CameraDepthNormalsTexture); 39 | return o; 40 | } 41 | 42 | fixed4 frag(v2f i) : COLOR 43 | { 44 | float4 OrigDepth = tex2D(_CameraDepthNormalsTexture, i.texcoord); 45 | float depth; 46 | float3 normal; 47 | DecodeDepthNormal(OrigDepth, depth, normal); 48 | depth = LinearEyeDepth(depth) / 100.0f; 49 | return float4(depth, depth, depth, 1); 50 | } 51 | ENDCG 52 | 53 | } 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/copydepth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d73a485332f8f5148859e0635df8bf6e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/depth.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: depth 10 | m_Shader: {fileID: 4800000, guid: d73a485332f8f5148859e0635df8bf6e, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/depth.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ceca0a32a614d845afb421c1e03a5a0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Assets/Script/Utils/trail.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 741c33299e5fa304b8f5dfdc27942f99 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /NNPostProcessing/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.2d.sprite": "1.0.0", 4 | "com.unity.2d.tilemap": "1.0.0", 5 | "com.unity.ads": "3.4.5", 6 | "com.unity.analytics": "3.3.5", 7 | "com.unity.collab-proxy": "1.2.16", 8 | "com.unity.ext.nunit": "1.0.0", 9 | "com.unity.ide.rider": "1.1.4", 10 | "com.unity.ide.vscode": "1.2.1", 11 | "com.unity.multiplayer-hlapi": "1.0.6", 12 | "com.unity.purchasing": "2.0.6", 13 | "com.unity.test-framework": "1.1.14", 14 | "com.unity.textmeshpro": "2.0.1", 15 | "com.unity.timeline": "1.2.6", 16 | "com.unity.ugui": "1.0.0", 17 | "com.unity.xr.legacyinputhelpers": "2.1.4", 18 | "com.unity.modules.ai": "1.0.0", 19 | "com.unity.modules.androidjni": "1.0.0", 20 | "com.unity.modules.animation": "1.0.0", 21 | "com.unity.modules.assetbundle": "1.0.0", 22 | "com.unity.modules.audio": "1.0.0", 23 | "com.unity.modules.cloth": "1.0.0", 24 | "com.unity.modules.director": "1.0.0", 25 | "com.unity.modules.imageconversion": "1.0.0", 26 | "com.unity.modules.imgui": "1.0.0", 27 | "com.unity.modules.jsonserialize": "1.0.0", 28 | "com.unity.modules.particlesystem": "1.0.0", 29 | "com.unity.modules.physics": "1.0.0", 30 | "com.unity.modules.physics2d": "1.0.0", 31 | "com.unity.modules.screencapture": "1.0.0", 32 | "com.unity.modules.terrain": "1.0.0", 33 | "com.unity.modules.terrainphysics": "1.0.0", 34 | "com.unity.modules.tilemap": "1.0.0", 35 | "com.unity.modules.ui": "1.0.0", 36 | "com.unity.modules.uielements": "1.0.0", 37 | "com.unity.modules.umbra": "1.0.0", 38 | "com.unity.modules.unityanalytics": "1.0.0", 39 | "com.unity.modules.unitywebrequest": "1.0.0", 40 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 41 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 42 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 43 | "com.unity.modules.unitywebrequestwww": "1.0.0", 44 | "com.unity.modules.vehicles": "1.0.0", 45 | "com.unity.modules.video": "1.0.0", 46 | "com.unity.modules.vr": "1.0.0", 47 | "com.unity.modules.wind": "1.0.0", 48 | "com.unity.modules.xr": "1.0.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 1 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2019.4.1f1 2 | m_EditorVersionWithRevision: 2019.4.1f1 (e6c045e14e4e) 3 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 4 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 4 41 | resolutionScalingFixedDPIFactor: 1 42 | excludedTargetPlatforms: [] 43 | - serializedVersion: 2 44 | name: Low 45 | pixelLightCount: 0 46 | shadows: 0 47 | shadowResolution: 0 48 | shadowProjection: 1 49 | shadowCascades: 1 50 | shadowDistance: 20 51 | shadowNearPlaneOffset: 3 52 | shadowCascade2Split: 0.33333334 53 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 54 | shadowmaskMode: 0 55 | blendWeights: 2 56 | textureQuality: 0 57 | anisotropicTextures: 0 58 | antiAliasing: 0 59 | softParticles: 0 60 | softVegetation: 0 61 | realtimeReflectionProbes: 0 62 | billboardsFaceCameraPosition: 0 63 | vSyncCount: 0 64 | lodBias: 0.4 65 | maximumLODLevel: 0 66 | streamingMipmapsActive: 0 67 | streamingMipmapsAddAllCameras: 1 68 | streamingMipmapsMemoryBudget: 512 69 | streamingMipmapsRenderersPerFrame: 512 70 | streamingMipmapsMaxLevelReduction: 2 71 | streamingMipmapsMaxFileIORequests: 1024 72 | particleRaycastBudget: 16 73 | asyncUploadTimeSlice: 2 74 | asyncUploadBufferSize: 4 75 | resolutionScalingFixedDPIFactor: 1 76 | excludedTargetPlatforms: [] 77 | - serializedVersion: 2 78 | name: Medium 79 | pixelLightCount: 1 80 | shadows: 1 81 | shadowResolution: 0 82 | shadowProjection: 1 83 | shadowCascades: 1 84 | shadowDistance: 20 85 | shadowNearPlaneOffset: 3 86 | shadowCascade2Split: 0.33333334 87 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 88 | shadowmaskMode: 0 89 | blendWeights: 2 90 | textureQuality: 0 91 | anisotropicTextures: 1 92 | antiAliasing: 0 93 | softParticles: 0 94 | softVegetation: 0 95 | realtimeReflectionProbes: 0 96 | billboardsFaceCameraPosition: 0 97 | vSyncCount: 1 98 | lodBias: 0.7 99 | maximumLODLevel: 0 100 | streamingMipmapsActive: 0 101 | streamingMipmapsAddAllCameras: 1 102 | streamingMipmapsMemoryBudget: 512 103 | streamingMipmapsRenderersPerFrame: 512 104 | streamingMipmapsMaxLevelReduction: 2 105 | streamingMipmapsMaxFileIORequests: 1024 106 | particleRaycastBudget: 64 107 | asyncUploadTimeSlice: 2 108 | asyncUploadBufferSize: 4 109 | resolutionScalingFixedDPIFactor: 1 110 | excludedTargetPlatforms: [] 111 | - serializedVersion: 2 112 | name: High 113 | pixelLightCount: 2 114 | shadows: 2 115 | shadowResolution: 1 116 | shadowProjection: 1 117 | shadowCascades: 2 118 | shadowDistance: 40 119 | shadowNearPlaneOffset: 3 120 | shadowCascade2Split: 0.33333334 121 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 122 | shadowmaskMode: 1 123 | blendWeights: 2 124 | textureQuality: 0 125 | anisotropicTextures: 1 126 | antiAliasing: 2 127 | softParticles: 0 128 | softVegetation: 1 129 | realtimeReflectionProbes: 1 130 | billboardsFaceCameraPosition: 1 131 | vSyncCount: 1 132 | lodBias: 1 133 | maximumLODLevel: 0 134 | streamingMipmapsActive: 0 135 | streamingMipmapsAddAllCameras: 1 136 | streamingMipmapsMemoryBudget: 512 137 | streamingMipmapsRenderersPerFrame: 512 138 | streamingMipmapsMaxLevelReduction: 2 139 | streamingMipmapsMaxFileIORequests: 1024 140 | particleRaycastBudget: 256 141 | asyncUploadTimeSlice: 2 142 | asyncUploadBufferSize: 4 143 | resolutionScalingFixedDPIFactor: 1 144 | excludedTargetPlatforms: [] 145 | - serializedVersion: 2 146 | name: Very High 147 | pixelLightCount: 3 148 | shadows: 2 149 | shadowResolution: 2 150 | shadowProjection: 1 151 | shadowCascades: 2 152 | shadowDistance: 40 153 | shadowNearPlaneOffset: 3 154 | shadowCascade2Split: 0.33333334 155 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 156 | shadowmaskMode: 1 157 | blendWeights: 4 158 | textureQuality: 0 159 | anisotropicTextures: 1 160 | antiAliasing: 4 161 | softParticles: 1 162 | softVegetation: 1 163 | realtimeReflectionProbes: 1 164 | billboardsFaceCameraPosition: 1 165 | vSyncCount: 1 166 | lodBias: 1.5 167 | maximumLODLevel: 0 168 | streamingMipmapsActive: 0 169 | streamingMipmapsAddAllCameras: 1 170 | streamingMipmapsMemoryBudget: 512 171 | streamingMipmapsRenderersPerFrame: 512 172 | streamingMipmapsMaxLevelReduction: 2 173 | streamingMipmapsMaxFileIORequests: 1024 174 | particleRaycastBudget: 1024 175 | asyncUploadTimeSlice: 2 176 | asyncUploadBufferSize: 4 177 | resolutionScalingFixedDPIFactor: 1 178 | excludedTargetPlatforms: [] 179 | - serializedVersion: 2 180 | name: Ultra 181 | pixelLightCount: 4 182 | shadows: 2 183 | shadowResolution: 2 184 | shadowProjection: 1 185 | shadowCascades: 4 186 | shadowDistance: 150 187 | shadowNearPlaneOffset: 3 188 | shadowCascade2Split: 0.33333334 189 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 190 | shadowmaskMode: 1 191 | blendWeights: 4 192 | textureQuality: 0 193 | anisotropicTextures: 1 194 | antiAliasing: 4 195 | softParticles: 1 196 | softVegetation: 1 197 | realtimeReflectionProbes: 1 198 | billboardsFaceCameraPosition: 1 199 | vSyncCount: 1 200 | lodBias: 2 201 | maximumLODLevel: 0 202 | streamingMipmapsActive: 0 203 | streamingMipmapsAddAllCameras: 1 204 | streamingMipmapsMemoryBudget: 512 205 | streamingMipmapsRenderersPerFrame: 512 206 | streamingMipmapsMaxLevelReduction: 2 207 | streamingMipmapsMaxFileIORequests: 1024 208 | particleRaycastBudget: 4096 209 | asyncUploadTimeSlice: 2 210 | asyncUploadBufferSize: 4 211 | resolutionScalingFixedDPIFactor: 1 212 | excludedTargetPlatforms: [] 213 | m_PerPlatformDefaultQuality: 214 | Standalone: 0 215 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 1 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate 14 | m_Enabled: 0 15 | m_CaptureEditorExceptions: 1 16 | UnityPurchasingSettings: 17 | m_Enabled: 0 18 | m_TestMode: 0 19 | UnityAnalyticsSettings: 20 | m_Enabled: 0 21 | m_InitializeOnStartup: 1 22 | m_TestMode: 0 23 | m_TestEventUrl: 24 | m_TestConfigUrl: 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /NNPostProcessing/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /NNTrainer/README.md: -------------------------------------------------------------------------------- 1 | Neural Network Post Processing 2 | ======== 3 | 4 | ## 1. data preparation 5 | 6 | I use coco2017 val for training datasets, download at [coco2017](http://images.cocodataset.org/zips/val2017.zip), unzip into "datasets" folder, pictures should be in "datasets/coco2017/val/" 7 | 8 | add your style image to "datasets/style", remember that the image name is `` 9 | 10 | ## 2. modify the network 11 | 12 | You can decrease layers and filters it if it runs too slow, increase if it underfit. 13 | 14 | in "src/nets.py", method `SimpleTransformNet()` 15 | 16 | ## 3. train the network 17 | 18 | run `python train_fst.py --style ` 19 | 20 | ## 4. export to unity 21 | 22 | run `python exporter.py --dataset_name ` 23 | 24 | ## 5. parse model in unity 25 | 26 | - In Unity Project Window selected your recent imported model, should be `Assets/Script/RawModel/.json`, right click it, from the pop-up menu select "ParseFromRawModel" 27 | - Add `` to script enum "NNStyle" 28 | 29 | Now you should be able to select the model from NNPostProcessingEffect inspector window 30 | 31 | ## Requirements 32 | python>=3.8 33 | tensorflow>=2.3.0 34 | scipy>1.5.4 35 | imageio>=2.9.0 36 | scikit-image>=0.17.2 -------------------------------------------------------------------------------- /NNTrainer/datasets/chicago.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/chicago.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/example_dataset/test/placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/example_dataset/test/placeholder.txt -------------------------------------------------------------------------------- /NNTrainer/datasets/example_dataset/train/placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/example_dataset/train/placeholder.txt -------------------------------------------------------------------------------- /NNTrainer/datasets/style/des_glaneuses.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/des_glaneuses.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/gritty.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/gritty.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/la_muse.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/la_muse.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/mirror.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/mirror.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/mosaic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/mosaic.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/rain_princess.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/rain_princess.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/shanshui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/shanshui.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/sketch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/sketch.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/starry_night.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/starry_night.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/the_scream.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/the_scream.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/udnie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/udnie.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/watercolor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/watercolor.jpg -------------------------------------------------------------------------------- /NNTrainer/datasets/style/wave_crop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/datasets/style/wave_crop.jpg -------------------------------------------------------------------------------- /NNTrainer/debug.cmd: -------------------------------------------------------------------------------- 1 | python debug.py --modelpath udnie --modeltype fst -------------------------------------------------------------------------------- /NNTrainer/debug.py: -------------------------------------------------------------------------------- 1 | from keras.models import model_from_json, Model 2 | from keras.utils import plot_model 3 | from keras.optimizers import Adam 4 | from keras.utils import plot_model 5 | import matplotlib.pyplot as plt 6 | from data_loader import DataLoader 7 | import json 8 | import time 9 | import argparse 10 | from scipy.misc import imsave 11 | 12 | import sys 13 | sys.path.insert(0, 'src') 14 | import nets 15 | 16 | parser = argparse.ArgumentParser(description='') 17 | parser.add_argument('--dataset_name', dest='dataset_name', default='terrain', help='name of the dataset') 18 | parser.add_argument('--modelpath', dest='modelpath', default='model', help='name of model') 19 | parser.add_argument('--modeltype', dest='type', default='pix2pix', help='model type') 20 | args = parser.parse_args() 21 | 22 | class DebuggerFST(): 23 | def __init__(self, path = "model", dataset_name = "terrain"): 24 | self.path = path 25 | self.dataset_name = dataset_name 26 | self.load_model() 27 | self.plot() 28 | self.debug() 29 | 30 | def load_model(self): 31 | net = nets.image_transform_net_simple(512,512,3) 32 | net.compile(Adam(), loss='mse') 33 | net.load_weights("model/"+self.path+'_weight.h5',by_name=False) 34 | #net.summary() 35 | #predictnet = Model(input = model.input, output = model.get_layer(name = "transform_output").output) 36 | self.loaded_model = net 37 | ''' 38 | json_file = open("model/" + self.path + "_architecture.json", 'r') 39 | loaded_model_json = json_file.read() 40 | json_file.close() 41 | self.loaded_model = model_from_json(loaded_model_json) 42 | # load weights into new model 43 | self.loaded_model.load_weights("model/" + self.path + "_weight.h5")''' 44 | 45 | def plot(self): 46 | plot_model(self.loaded_model, to_file="model/" + self.path +"_architecture.png", show_shapes=True) 47 | print("Saved model to disk") 48 | 49 | def debug(self): 50 | fig, axs = plt.subplots(1,1, figsize=(15,15)) 51 | data_loader = DataLoader(dataset_name=self.dataset_name, img_res=(512, 512)) 52 | imgs_A, imgs_B = data_loader.load_data(batch_size=1, is_testing= False, is_debug = True) 53 | inputimg = (imgs_B[:,:,:,:3] + 1 ) * 0.5 54 | imsave("images/" + self.dataset_name + "/source.png", inputimg[0]) 55 | imgs_B = (imgs_B[:,:,:,:3] + 1 ) * 127.5 56 | fake_A = self.loaded_model.predict(imgs_B[:,:,:,:3]) 57 | t1 = time.time() 58 | fake_A = self.loaded_model.predict(imgs_B[:,:,:,:3]) 59 | print("process: %s" % (time.time() -t1)) 60 | fake_A =fake_A / 255 61 | imsave("images/" + self.dataset_name + "/predict.png", fake_A[0]) 62 | ''' 63 | for layernum in range(1, len(self.loaded_model.layers)): 64 | intermediate_model = Model(inputs = self.loaded_model.input, outputs = self.loaded_model.layers[layernum].output) 65 | inter_output = intermediate_model.predict(imgs_B) 66 | inter_output = inter_output * 0.5 + 0.5 67 | #imsave("images/" + self.dataset_name + "/inter" + str(layernum) + ".png", inter_output[0,:,:,0:3]) 68 | axs.imshow(inter_output[0,:,:,0:3]) 69 | fig.savefig("images/" + self.dataset_name + "/inter" + str(layernum) + ".png")''' 70 | 71 | class Debugger(): 72 | 73 | def __init__(self, path = "model", dataset_name = "terrain"): 74 | self.path = path 75 | self.dataset_name = dataset_name 76 | self.load_model() 77 | self.debug() 78 | 79 | def load_model(self): 80 | json_file = open("model/" + self.path + "_architecture.json", 'r') 81 | loaded_model_json = json_file.read() 82 | json_file.close() 83 | self.loaded_model = model_from_json(loaded_model_json) 84 | # load weights into new model 85 | self.loaded_model.load_weights("model/" + self.path + "_weight.h5") 86 | 87 | def debug(self): 88 | self.loaded_model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy']) 89 | 90 | 91 | data_loader = DataLoader(dataset_name=self.dataset_name, img_res=(512, 512)) 92 | imgs_A, imgs_B = data_loader.load_data(batch_size=1, is_testing= False, is_debug = True) 93 | interresult0 = imgs_B.tolist() 94 | t1 = time.time() 95 | fake_A = self.loaded_model.predict(imgs_B) 96 | print("process: %s" % (time.time() -t1)) 97 | fake_A = 0.5 * fake_A + 0.5 98 | fig, axs = plt.subplots(1,1, figsize=(15,15)) 99 | axs.imshow(fake_A[0]) 100 | fig.savefig("images/" + self.dataset_name + "/predict.png") 101 | axs.imshow(0.5 * imgs_B[0] + 0.5) 102 | fig.savefig("images/" + self.dataset_name + "/source.png") 103 | 104 | with open("debug/intermediate_result0.json", "w") as json_file: 105 | json_file.write(json.dumps(interresult0)) 106 | 107 | for layernum in range(1, len(self.loaded_model.layers)): 108 | intermediate_model = Model(inputs = self.loaded_model.input, outputs = self.loaded_model.layers[layernum].output) 109 | inter_output = intermediate_model.predict(imgs_B) 110 | with open("debug/intermediate_result" + str(layernum) + ".json", "w") as json_file: 111 | json_file.write(json.dumps(inter_output.tolist())) 112 | inter_output = 0.5 * inter_output + 0.5 113 | axs.imshow(inter_output[0,:,:,0:3]) 114 | fig.savefig("images/" + self.dataset_name + "/inter" + str(layernum) + ".png") 115 | 116 | 117 | if __name__ == '__main__': 118 | if args.type == "pix2pix": 119 | Debugger(path = args.modelpath, dataset_name = args.dataset_name) 120 | if args.type == "fst": 121 | DebuggerFST(path = args.modelpath, dataset_name = args.dataset_name) -------------------------------------------------------------------------------- /NNTrainer/export.cmd: -------------------------------------------------------------------------------- 1 | python exporter.py --dataset_name mosaic --modeltype fst -------------------------------------------------------------------------------- /NNTrainer/exporter.py: -------------------------------------------------------------------------------- 1 | from tensorflow.keras.models import load_model, Model 2 | from tensorflow.keras.utils import plot_model 3 | from tensorflow.keras.optimizers import Adam 4 | import json 5 | import argparse 6 | 7 | import sys 8 | sys.path.insert(0, 'src') 9 | from nets import SimpleTransformNet 10 | 11 | parser = argparse.ArgumentParser(description='') 12 | parser.add_argument('--dataset_name', dest='dataset_name', default='terrain', help='name of the dataset') 13 | parser.add_argument('--modeltype', dest='modeltype', default='fnst', help='type of model') 14 | args = parser.parse_args() 15 | 16 | 17 | class Exporter(): 18 | 19 | def __init__(self, dataset_name = "terrain", type = "fnst"): 20 | self.dataset_name = dataset_name 21 | self.type = type 22 | self.load_model() 23 | self.export() 24 | 25 | def load_model(self): 26 | net = SimpleTransformNet() 27 | self.loaded_model = net.model 28 | # load weights into new model 29 | self.loaded_model.load_weights("model/" + self.dataset_name + "_weight.h5") 30 | print(self.loaded_model.to_json()) 31 | 32 | def export(self): 33 | weights_dict = [] 34 | weights_list = self.loaded_model.get_weights() 35 | for i, weights in enumerate(weights_list): 36 | thisweight = {} 37 | thisweight["shape"] = weights.shape 38 | if len(weights.shape) == 1: 39 | thisweight["arrayweight"] = weights.tolist() 40 | else: 41 | thisweight["kernelweight"] = weights.tolist() 42 | weights_dict.append(thisweight) 43 | formatstr = '{"model":%s,"weights":%s}' % (self.loaded_model.to_json(), json.dumps(weights_dict)) 44 | with open("../NNPostProcessing/Assets/Script/RawModel/%s.json" % self.dataset_name, "w") as json_file: 45 | json_file.write(formatstr) 46 | print(self.loaded_model.summary()) 47 | #plot_model(self.loaded_model, to_file='model/' + self.dataset_name + '_architecture.png', show_shapes=True) 48 | 49 | if __name__ == '__main__': 50 | Exporter(dataset_name = args.dataset_name, type = args.modeltype) -------------------------------------------------------------------------------- /NNTrainer/images/placeholder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/images/placeholder.txt -------------------------------------------------------------------------------- /NNTrainer/model/model_architecture.json: -------------------------------------------------------------------------------- 1 | {"class_name": "Model", "config": {"name": "model_2", "layers": [{"name": "input_3", "class_name": "InputLayer", "config": {"batch_input_shape": [null, 512, 512, 4], "dtype": "float32", "sparse": false, "name": "input_3"}, "inbound_nodes": []}, {"name": "conv2d_6", "class_name": "Conv2D", "config": {"name": "conv2d_6", "trainable": true, "filters": 16, "kernel_size": [3, 3], "strides": [2, 2], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["input_3", 0, 0, {}]]]}, {"name": "leaky_re_lu_5", "class_name": "LeakyReLU", "config": {"name": "leaky_re_lu_5", "trainable": true, "alpha": 0.20000000298023224}, "inbound_nodes": [[["conv2d_6", 0, 0, {}]]]}, {"name": "conv2d_7", "class_name": "Conv2D", "config": {"name": "conv2d_7", "trainable": true, "filters": 32, "kernel_size": [3, 3], "strides": [2, 2], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["leaky_re_lu_5", 0, 0, {}]]]}, {"name": "leaky_re_lu_6", "class_name": "LeakyReLU", "config": {"name": "leaky_re_lu_6", "trainable": true, "alpha": 0.20000000298023224}, "inbound_nodes": [[["conv2d_7", 0, 0, {}]]]}, {"name": "batch_normalization_4", "class_name": "BatchNormalization", "config": {"name": "batch_normalization_4", "trainable": true, "axis": -1, "momentum": 0.8, "epsilon": 0.001, "center": true, "scale": true, "beta_initializer": {"class_name": "Zeros", "config": {}}, "gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null}, "inbound_nodes": [[["leaky_re_lu_6", 0, 0, {}]]]}, {"name": "conv2d_8", "class_name": "Conv2D", "config": {"name": "conv2d_8", "trainable": true, "filters": 64, "kernel_size": [3, 3], "strides": [2, 2], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["batch_normalization_4", 0, 0, {}]]]}, {"name": "leaky_re_lu_7", "class_name": "LeakyReLU", "config": {"name": "leaky_re_lu_7", "trainable": true, "alpha": 0.20000000298023224}, "inbound_nodes": [[["conv2d_8", 0, 0, {}]]]}, {"name": "batch_normalization_5", "class_name": "BatchNormalization", "config": {"name": "batch_normalization_5", "trainable": true, "axis": -1, "momentum": 0.8, "epsilon": 0.001, "center": true, "scale": true, "beta_initializer": {"class_name": "Zeros", "config": {}}, "gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null}, "inbound_nodes": [[["leaky_re_lu_7", 0, 0, {}]]]}, {"name": "up_sampling2d_1", "class_name": "UpSampling2D", "config": {"name": "up_sampling2d_1", "trainable": true, "size": [2, 2], "data_format": "channels_last", "interpolation": "nearest"}, "inbound_nodes": [[["batch_normalization_5", 0, 0, {}]]]}, {"name": "conv2d_9", "class_name": "Conv2D", "config": {"name": "conv2d_9", "trainable": true, "filters": 32, "kernel_size": [3, 3], "strides": [1, 1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["up_sampling2d_1", 0, 0, {}]]]}, {"name": "batch_normalization_6", "class_name": "BatchNormalization", "config": {"name": "batch_normalization_6", "trainable": true, "axis": -1, "momentum": 0.8, "epsilon": 0.001, "center": true, "scale": true, "beta_initializer": {"class_name": "Zeros", "config": {}}, "gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null}, "inbound_nodes": [[["conv2d_9", 0, 0, {}]]]}, {"name": "concatenate_2", "class_name": "Concatenate", "config": {"name": "concatenate_2", "trainable": true, "axis": -1}, "inbound_nodes": [[["batch_normalization_6", 0, 0, {}], ["batch_normalization_4", 0, 0, {}]]]}, {"name": "up_sampling2d_2", "class_name": "UpSampling2D", "config": {"name": "up_sampling2d_2", "trainable": true, "size": [2, 2], "data_format": "channels_last", "interpolation": "nearest"}, "inbound_nodes": [[["concatenate_2", 0, 0, {}]]]}, {"name": "conv2d_10", "class_name": "Conv2D", "config": {"name": "conv2d_10", "trainable": true, "filters": 16, "kernel_size": [3, 3], "strides": [1, 1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["up_sampling2d_2", 0, 0, {}]]]}, {"name": "batch_normalization_7", "class_name": "BatchNormalization", "config": {"name": "batch_normalization_7", "trainable": true, "axis": -1, "momentum": 0.8, "epsilon": 0.001, "center": true, "scale": true, "beta_initializer": {"class_name": "Zeros", "config": {}}, "gamma_initializer": {"class_name": "Ones", "config": {}}, "moving_mean_initializer": {"class_name": "Zeros", "config": {}}, "moving_variance_initializer": {"class_name": "Ones", "config": {}}, "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null}, "inbound_nodes": [[["conv2d_10", 0, 0, {}]]]}, {"name": "concatenate_3", "class_name": "Concatenate", "config": {"name": "concatenate_3", "trainable": true, "axis": -1}, "inbound_nodes": [[["batch_normalization_7", 0, 0, {}], ["leaky_re_lu_5", 0, 0, {}]]]}, {"name": "up_sampling2d_3", "class_name": "UpSampling2D", "config": {"name": "up_sampling2d_3", "trainable": true, "size": [2, 2], "data_format": "channels_last", "interpolation": "nearest"}, "inbound_nodes": [[["concatenate_3", 0, 0, {}]]]}, {"name": "conv2d_11", "class_name": "Conv2D", "config": {"name": "conv2d_11", "trainable": true, "filters": 4, "kernel_size": [3, 3], "strides": [1, 1], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "tanh", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "inbound_nodes": [[["up_sampling2d_3", 0, 0, {}]]]}], "input_layers": [["input_3", 0, 0]], "output_layers": [["conv2d_11", 0, 0]]}, "keras_version": "2.2.4", "backend": "tensorflow"} -------------------------------------------------------------------------------- /NNTrainer/model/model_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/model/model_architecture.png -------------------------------------------------------------------------------- /NNTrainer/model/model_weight.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maajor/NeuralNetworkPostProcessing/2264c8d57b995d48fdd708cb28dba61c5cff7785/NNTrainer/model/model_weight.h5 -------------------------------------------------------------------------------- /NNTrainer/requirements.txt: -------------------------------------------------------------------------------- 1 | tensorflow>=2.3.0 2 | scipy>1.5.4 3 | imageio>=2.9.0 4 | scikit-image>=0.17.2 -------------------------------------------------------------------------------- /NNTrainer/src/img_util.py: -------------------------------------------------------------------------------- 1 | from tensorflow.keras.preprocessing.image import img_to_array, load_img 2 | from skimage import transform 3 | import numpy as np 4 | 5 | def get_image(img_path, img_size=False): 6 | img = load_img(img_path) 7 | img = img_to_array(img, dtype=np.float32) 8 | if img_size != False: 9 | img = resize_img(img, img_size) 10 | return img 11 | 12 | def resize_img(img, size): 13 | if len(size) == 2: 14 | size += (3,) 15 | return transform.resize(img, size, preserve_range=True) -------------------------------------------------------------------------------- /NNTrainer/src/layers.py: -------------------------------------------------------------------------------- 1 | from tensorflow.keras.layers import Activation, Add, BatchNormalization, Conv2D, Conv2DTranspose, Layer, add, UpSampling2D 2 | 3 | class InputNormalize(Layer): 4 | def __init__(self, **kwargs): 5 | super(InputNormalize, self).__init__(**kwargs) 6 | 7 | def build(self, input_shape): 8 | pass 9 | 10 | def compute_output_shape(self,input_shape): 11 | return input_shape 12 | 13 | def call(self, x, mask=None): 14 | x = (x - 127.5)/ 127.5 15 | return x 16 | 17 | 18 | 19 | def conv_bn_relu(nb_filter, nb_row, nb_col,stride): 20 | def conv_func(x): 21 | x = Conv2D(nb_filter, (nb_row, nb_col), strides=stride,padding='same')(x) 22 | x = BatchNormalization(momentum = 0.8)(x) 23 | #x = LeakyReLU(0.2)(x) 24 | x = Activation("relu")(x) 25 | return x 26 | return conv_func 27 | 28 | 29 | 30 | #https://keunwoochoi.wordpress.com/2016/03/09/residual-networks-implementation-on-keras/ 31 | def res_conv(nb_filter, nb_row, nb_col,stride=(1,1)): 32 | def _res_func(x): 33 | #identity = Cropping2D(cropping=((2,2),(2,2)))(x) 34 | 35 | a = Conv2D(nb_filter, (nb_row, nb_col), strides=stride, padding='same')(x) 36 | a = BatchNormalization(momentum = 0.8)(a) 37 | #a = LeakyReLU(0.2)(a) 38 | a = Activation("relu")(a) 39 | a = Conv2D(nb_filter, (nb_row, nb_col), strides=stride, padding='same')(a) 40 | y = BatchNormalization(momentum = 0.8)(a) 41 | 42 | return add([x, y]) 43 | 44 | return _res_func 45 | 46 | 47 | def dconv_bn_nolinear(nb_filter, nb_row, nb_col,stride=(2,2),activation="relu"): 48 | def _dconv_bn(x): 49 | #TODO: Deconvolution2D 50 | #x = Deconvolution2D(nb_filter,nb_row, nb_col, output_shape=output_shape, subsample=stride, border_mode='same')(x) 51 | #x = UpSampling2D(size=stride)(x) 52 | x = UpSampling2D(size=stride)(x) 53 | #x = ReflectionPadding2D(padding=stride)(x) 54 | x = Conv2D(nb_filter, (nb_row, nb_col), padding='same')(x) 55 | x = BatchNormalization(momentum = 0.8)(x) 56 | x = Activation(activation)(x) 57 | return x 58 | return _dconv_bn 59 | 60 | class Denormalize(Layer): 61 | ''' 62 | Custom layer to denormalize the final Convolution layer activations (tanh) 63 | Since tanh scales the output to the range (-1, 1), we add 1 to bring it to the 64 | range (0, 2). We then multiply it by 127.5 to scale the values to the range (0, 255) 65 | ''' 66 | 67 | def __init__(self, **kwargs): 68 | super(Denormalize, self).__init__(**kwargs) 69 | 70 | def build(self, input_shape): 71 | pass 72 | 73 | def call(self, x, mask=None): 74 | ''' 75 | Scales the tanh output activations from previous layer (-1, 1) to the 76 | range (0, 255) 77 | ''' 78 | 79 | return (x + 1) * 127.5 80 | 81 | def compute_output_shape(self,input_shape): 82 | return input_shape 83 | -------------------------------------------------------------------------------- /NNTrainer/src/nets.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow.keras.layers import BatchNormalization, Conv2D, Add, Layer, Conv2DTranspose, Activation 3 | from layers import InputNormalize, Denormalize, conv_bn_relu, res_conv, dconv_bn_nolinear 4 | 5 | class SimpleTransformNet: 6 | def __init__(self): 7 | self.model = self._get_model() 8 | 9 | def _get_model(self): 10 | x = tf.keras.Input(shape=(None,None,3)) 11 | a = InputNormalize()(x) 12 | #a = ReflectionPadding2D(padding=(40,40),input_shape=(img_width,img_height,3))(a) 13 | a = conv_bn_relu(8, 9, 9, stride=(1,1))(a) 14 | a = conv_bn_relu(16, 3, 3, stride=(2,2))(a) 15 | a = conv_bn_relu(32, 3, 3, stride=(2,2))(a) 16 | for i in range(2): 17 | a = res_conv(32,3,3)(a) 18 | a = dconv_bn_nolinear(16,3,3)(a) 19 | a = dconv_bn_nolinear(8,3,3)(a) 20 | a = dconv_bn_nolinear(3,9,9,stride=(1,1),activation="tanh")(a) 21 | # Scale output to range [0, 255] via custom Denormalize layer 22 | y = Denormalize(name='transform_output')(a) 23 | return tf.keras.Model(x, y, name="transformnet") 24 | 25 | def get_variables(self): 26 | return self.model.trainable_variables 27 | 28 | def preprocess(self, img): 29 | return img 30 | 31 | def postprocess(self, img): 32 | return tf.clip_by_value(img, 0.0, 255.0) -------------------------------------------------------------------------------- /NNTrainer/src/trainer.py: -------------------------------------------------------------------------------- 1 | from tensorflow.keras.applications import VGG19 2 | from tensorflow.keras.preprocessing.image import img_to_array, load_img 3 | from tensorflow.keras.applications.vgg19 import preprocess_input 4 | from collections import namedtuple 5 | from glob import glob 6 | import os 7 | import datetime 8 | import numpy as np 9 | import tensorflow as tf 10 | import imageio 11 | 12 | from nets import SimpleTransformNet 13 | from vgg import VGGModel 14 | from img_util import get_image, resize_img 15 | 16 | Loss = namedtuple('Loss', 'total_loss style_loss content_loss tv_loss') 17 | 18 | 19 | class Trainer: 20 | def __init__(self, 21 | style_path, 22 | content_file_path, 23 | epochs=10, 24 | batch_size=4, 25 | content_weight=1e0, 26 | style_weight=4e1, 27 | tv_weight=2e2, 28 | learning_rate=1e-3, 29 | log_period=100, 30 | save_period=1000, 31 | content_layers=["conv4_2"], 32 | style_layers=["conv1_1", "conv2_1", "conv3_1", "conv4_1", "conv5_1"], 33 | content_layer_weights=[1], 34 | style_layer_weights=[0.2, 0.2, 0.2, 0.2, 0.2], 35 | img_res=512): 36 | self.style_path = style_path 37 | self.style_name = style_path.split("/")[-1].split(".")[0] 38 | self.content_file_path = content_file_path 39 | assert (len(content_layers) == len(content_layer_weights)) 40 | self.content_layers = content_layers 41 | self.content_layer_weights = content_layer_weights 42 | assert (len(style_layers) == len(style_layer_weights)) 43 | self.style_layers = style_layers 44 | self.style_layer_weights = style_layer_weights 45 | self.epochs = epochs 46 | self.batch_size = batch_size 47 | self.log_period = log_period 48 | self.save_period = save_period 49 | self.saved_model_path = "model/{0}_weight.h5".format(self.style_name) 50 | 51 | self.style_weight = style_weight 52 | self.content_weight = content_weight 53 | self.tv_weight = tv_weight 54 | self.img_res = img_res 55 | 56 | self.transform = SimpleTransformNet() 57 | self.vgg = VGGModel(content_layers, style_layers) 58 | self.learing_rate = learning_rate 59 | self.train_optimizer = tf.keras.optimizers.Adam(learning_rate=self.learing_rate) 60 | 61 | def run(self): 62 | self.S_outputs = self._get_S_outputs() 63 | self.S_style_grams = [self._gram_matrix(tf.convert_to_tensor(m, tf.float32)) for m in 64 | self.S_outputs[self.vgg.partition_idx:]] 65 | 66 | content_images = glob(os.path.join(self.content_file_path, "*.jpg")) 67 | num_images = len(content_images) - (len(content_images) % self.batch_size) 68 | print("Training on %d images" % num_images) 69 | 70 | self.iteration = 0 71 | 72 | for e in range(self.epochs): 73 | for e_i, batch in enumerate( 74 | [content_images[i:i + self.batch_size] for i in range(0, num_images, self.batch_size)]): 75 | 76 | content_imgs = [get_image(img_path, (self.img_res, self.img_res, 3)) for img_path in batch] 77 | content_imgs = np.array(content_imgs) 78 | content_tensors = tf.convert_to_tensor(content_imgs) 79 | 80 | loss = self._train_step(content_tensors) 81 | 82 | if (self.iteration % self.log_period == 0): 83 | self._log_protocol(loss) 84 | if (self.iteration % self.save_period == 0): 85 | self._save_protocol() 86 | 87 | self.iteration += 1 88 | 89 | if self.iteration % 100 == 0: 90 | self._display_img(self.iteration) 91 | 92 | self._log_protocol(loss) 93 | self._save_protocol() 94 | print("Epoch complete.") 95 | print("Training finished.") 96 | 97 | def _get_S_outputs(self): 98 | img = tf.convert_to_tensor(get_image(self.style_path), tf.float32) 99 | img = tf.expand_dims(img, 0) 100 | img = self.vgg.preprocess(img) 101 | return self.vgg.model(img) 102 | 103 | @tf.function 104 | def _train_step(self, content_tensors): 105 | with tf.GradientTape(watch_accessed_variables=False) as tape: 106 | tape.watch(self.transform.get_variables()) 107 | C = self.transform.preprocess(content_tensors) 108 | X = self.transform.model(C) 109 | X = self.transform.postprocess(X) 110 | 111 | X_vgg = self.vgg.preprocess(X) 112 | Y_hat = self.vgg.forward(X_vgg) 113 | Y_hat_content = Y_hat.content_output 114 | Y_hat_style = Y_hat.style_output 115 | 116 | C_vgg = self.vgg.preprocess(content_tensors) 117 | Y = self.vgg.forward(C_vgg) 118 | Y_content = Y.content_output 119 | 120 | L = self._get_loss(Y_hat_content, Y_hat_style, Y_content, X) 121 | grads = tape.gradient(L.total_loss, self.transform.get_variables()) 122 | self.train_optimizer.apply_gradients(zip(grads, self.transform.get_variables())) 123 | return L 124 | 125 | def _get_loss(self, transformed_content, transformed_style, content, transformed_img): 126 | 127 | content_loss = self._get_content_loss(transformed_outputs=transformed_content, content_outputs=content) 128 | style_loss = self._get_style_loss(transformed_style) 129 | tv_loss = self._get_total_variation_loss(transformed_img) 130 | 131 | L_style = style_loss * self.style_weight 132 | L_content = content_loss * self.content_weight 133 | L_tv = tv_loss * self.tv_weight 134 | 135 | total_loss = L_style + L_content + L_tv 136 | 137 | return Loss(total_loss=total_loss, 138 | style_loss=L_style, 139 | content_loss=L_content, 140 | tv_loss=L_tv) 141 | 142 | def _get_content_loss(self, transformed_outputs, content_outputs): 143 | content_loss = 0 144 | assert (len(transformed_outputs) == len(content_outputs)) 145 | for i, output in enumerate(transformed_outputs): 146 | weight = self.content_layer_weights[i] 147 | B, H, W, CH = output.get_shape() 148 | HW = H * W 149 | loss_i = weight * 2 * tf.nn.l2_loss(output - content_outputs[i]) / (B * HW * CH) 150 | content_loss += loss_i 151 | return content_loss 152 | 153 | def _get_style_loss(self, transformed_outputs): 154 | style_loss = 0 155 | assert (len(transformed_outputs) == len(self.S_style_grams)) 156 | for i, output in enumerate(transformed_outputs): 157 | weight = self.style_layer_weights[i] 158 | B, H, W, CH = output.get_shape() 159 | G = self._gram_matrix(output) 160 | A = self.S_style_grams[i] 161 | style_loss += weight * 2 * tf.nn.l2_loss(G - A) / (B * (CH ** 2)) 162 | return style_loss 163 | 164 | def _gram_matrix(self, input_tensor, shape=None): 165 | result = tf.linalg.einsum('bijc,bijd->bcd', input_tensor, input_tensor) 166 | input_shape = input_tensor.get_shape() 167 | num_locations = input_shape[1] * input_shape[2] * input_shape[3] 168 | num_locations = tf.cast(num_locations, tf.float32) 169 | return result / num_locations 170 | 171 | def _get_total_variation_loss(self, img): 172 | B, W, H, CH = img.get_shape() 173 | return tf.reduce_sum(tf.image.total_variation(img)) / (W * H) 174 | 175 | def _log_protocol(self, L): 176 | tf.print("iteration: %d, total_loss: %f, style_loss: %f, content_loss: %f, tv_loss: %f" \ 177 | % (self.iteration, L.total_loss, L.style_loss, L.content_loss, L.tv_loss)) 178 | 179 | def _save_protocol(self): 180 | self.transform.model.save_weights(self.saved_model_path) 181 | 182 | def _display_img(self, i): 183 | img = get_image("datasets/chicago.jpg") 184 | img_tensor = tf.convert_to_tensor(img) 185 | img_tensor = tf.expand_dims(img_tensor, 0) 186 | res = self.transform.model.predict(img_tensor) 187 | res = tf.clip_by_value(res, 0, 255) 188 | res = res.numpy() 189 | res = tf.squeeze(res) 190 | res = res.numpy() 191 | res = res.astype(int) 192 | fname = 'datasets/output/train_%d_val.png' % (i) 193 | imageio.imwrite(fname, res) 194 | -------------------------------------------------------------------------------- /NNTrainer/src/vgg.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow.keras.applications import VGG16 3 | from tensorflow.keras import Model 4 | from collections import namedtuple 5 | 6 | VGG_Output = namedtuple('VGG_Output', 'content_output style_output') 7 | 8 | 9 | class VGGModel: 10 | def __init__(self, 11 | content_layers=["conv4_2"], 12 | style_layers=["conv1_1", "conv2_1", "conv3_1", "conv4_1", "conv5_1"] 13 | ): 14 | self.vgg = VGG16(include_top=False, weights='imagenet') 15 | self.layers = { 16 | "input": 0, 17 | "conv1_1": 1, 18 | "conv1_2": 2, 19 | "pool1": 3, 20 | "conv2_1": 4, 21 | "conv2_2": 5, 22 | "pool2": 6, 23 | "conv3_1": 7, 24 | "conv3_2": 8, 25 | "conv3_3": 9, 26 | "pool3": 10, 27 | "conv4_1": 11, 28 | "conv4_2": 12, 29 | "conv4_3": 13, 30 | "pool4": 14, 31 | "conv5_1": 15, 32 | "conv5_2": 16, 33 | "conv5_3": 17, 34 | "pool5": 18, 35 | "flatten": 19, 36 | "fc1": 20, 37 | "fc2": 21, 38 | "predictions": 22, 39 | } 40 | self.content_layers = content_layers 41 | self.style_layers = style_layers 42 | self.total_output_layers = self.content_layers + self.style_layers 43 | self.partition_idx = len(self.content_layers) 44 | self.model = Model(self.vgg.inputs, self._get_outputs(), trainable=False) 45 | 46 | def forward(self, X): 47 | outputs = self.model(X) 48 | return VGG_Output(outputs[:self.partition_idx], outputs[self.partition_idx:]) 49 | 50 | def _get_outputs(self): 51 | return [self.vgg.layers[self.layers[layer]].output for layer in self.total_output_layers] 52 | 53 | def preprocess(self, images): 54 | images = tf.keras.applications.vgg16.preprocess_input(images) 55 | images = tf.cast(images, tf.float32) 56 | return images -------------------------------------------------------------------------------- /NNTrainer/train_fst.cmd: -------------------------------------------------------------------------------- 1 | python train_fst.py --style shanshui --style_weight 5 -------------------------------------------------------------------------------- /NNTrainer/train_fst.py: -------------------------------------------------------------------------------- 1 | from tensorflow.keras.layers import Input 2 | from tensorflow.keras.models import Model,Sequential 3 | from tensorflow.keras.optimizers import Adam, SGD,RMSprop 4 | from tensorflow.keras.preprocessing.image import ImageDataGenerator 5 | from tensorflow.keras import backend as K 6 | import imageio 7 | import time 8 | import numpy as np 9 | import argparse 10 | 11 | from tensorflow.keras.callbacks import TensorBoard 12 | 13 | import sys 14 | sys.path.insert(0, 'src') 15 | from trainer import Trainer 16 | 17 | 18 | 19 | def display_img(i,x,style,is_val=False): 20 | # save current generated image 21 | img = x #deprocess_image(x) 22 | if is_val: 23 | #img = ndimage.median_filter(img, 3) 24 | 25 | fname = 'datasets/output/%s_%d_val.png' % (style,i) 26 | else: 27 | fname = 'datasets/output/%s_%d.png' % (style,i) 28 | imageio.imwrite(fname, img) 29 | print('Image saved as', fname) 30 | 31 | def get_style_img_path(style): 32 | return "datasets/style/"+style+".jpg" 33 | 34 | 35 | def main(args): 36 | style_weight= args.style_weight 37 | content_weight= args.content_weight 38 | tv_weight= args.tv_weight 39 | style= args.style 40 | img_width = img_height = args.image_size 41 | 42 | style_image_path = get_style_img_path(style) 43 | 44 | trainer = Trainer(style_image_path, "datasets/coco2017/val", content_weight=content_weight, style_weight=style_weight, tv_weight=tv_weight) 45 | 46 | trainer.run() 47 | 48 | 49 | if __name__ == "__main__": 50 | parser = argparse.ArgumentParser(description='Real-time style transfer') 51 | 52 | parser.add_argument('--style', '-s', type=str, required=True, 53 | help='style image file name without extension') 54 | 55 | parser.add_argument('--output', '-o', default=None, type=str, 56 | help='output model file path without extension') 57 | parser.add_argument('--tv_weight', default=1e-6, type=float, 58 | help='weight of total variation regularization according to the paper to be set between 10e-4 and 10e-6.') 59 | parser.add_argument('--content_weight', default=1.0, type=float) 60 | parser.add_argument('--style_weight', default=5.0, type=float) 61 | parser.add_argument('--image_size', default=512, type=int) 62 | 63 | args = parser.parse_args() 64 | main(args) 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Neural Network Post Processing 2 | ======== 3 | 4 | Post Processing for Unity using Convolution Neural Network. CNN Model trained with pix2pix/GAN, Fast Neural Style Transfer 5 | You can create your style offline and train the network with your own data, making your NNPP! 6 | 7 | * Trainer with pix2pix or fast-style-transfer 8 | * Keras model and weight discription to Unity 9 | 10 | trained with Fast Neural Style Transfer: 11 | [![FNST](http://img.youtube.com/vi/aA8qO4o-Xp0/0.jpg)](http://www.youtube.com/watch?v=aA8qO4o-Xp0 "FNST") 12 | 13 | This is the source-code for both runtime and trainning. Pre-trained model is on AssetStore 14 | [Neural Network Post Processing on Unity AssetStore](https://assetstore.unity.com/packages/vfx/shaders/neural-network-post-processing-135895) 15 | ![img](/Imgs/img_large.jpg) 16 | 17 | ## How to Run: 18 | 19 | Open ***Scene*** scene and run! 20 | 21 | ### Requirement 22 | * Unity 2018.2+ 23 | * Compute Shader support (DX11+, Vulkan, Metal) 24 | 25 | Reference 26 | ======== 27 | 28 | * https://github.com/eriklindernoren/Keras-GAN 29 | * https://github.com/misgod/fast-neural-style-keras 30 | * https://github.com/keijiro/Pix2Pix 31 | * https://github.com/altonelli/fast-style-transfer-tf2 --------------------------------------------------------------------------------