diff --git a/image/filter/filters.go b/image/filter/filters.go index cf002af..005ab24 100644 --- a/image/filter/filters.go +++ b/image/filter/filters.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/image/image.go b/image/image.go index 77c1ecd..1b9546e 100644 --- a/image/image.go +++ b/image/image.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -15,11 +15,12 @@ package image import ( "fmt" + "strings" + tf "github.com/galeone/tensorflow/tensorflow/go" "github.com/galeone/tensorflow/tensorflow/go/op" tg "github.com/galeone/tfgo" "github.com/galeone/tfgo/image/padding" - "strings" ) // ReadJPEG reads the JPEG image whose path is `imagePath` that has `channels` channels diff --git a/image/image_override.go b/image/image_override.go index c2e1cfd..fc6ce8f 100644 --- a/image/image_override.go +++ b/image/image_override.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/image/image_private.go b/image/image_private.go index 6f589b4..b41feee 100644 --- a/image/image_private.go +++ b/image/image_private.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -15,6 +15,7 @@ package image import ( "fmt" + tf "github.com/galeone/tensorflow/tensorflow/go" "github.com/galeone/tensorflow/tensorflow/go/op" tg "github.com/galeone/tfgo" diff --git a/image/image_test.go b/image/image_test.go index a081d45..ef06c45 100644 --- a/image/image_test.go +++ b/image/image_test.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -14,14 +14,15 @@ limitations under the License. package image_test import ( + "reflect" + "testing" + tf "github.com/galeone/tensorflow/tensorflow/go" "github.com/galeone/tensorflow/tensorflow/go/op" tg "github.com/galeone/tfgo" "github.com/galeone/tfgo/image" "github.com/galeone/tfgo/image/filter" "github.com/galeone/tfgo/image/padding" - "reflect" - "testing" ) const ( diff --git a/model.go b/model.go index 9df4a19..3fbd999 100644 --- a/model.go +++ b/model.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -34,14 +34,16 @@ func LoadModel(exportDir string, tags []string, options *tf.SessionOptions) (mod var err error model = new(Model) model.saved, err = tf.LoadSavedModel(exportDir, tags, options) + + if err != nil { + panic(err.Error()) + } + runtime.SetFinalizer(model, func(model *Model) { if model.saved != nil && model.saved.Session != nil { _ = model.saved.Session.Close() } }) - if err != nil { - panic(err.Error()) - } return } @@ -66,6 +68,11 @@ func ImportModel(serializedModel, prefix string, options *tf.SessionOptions) (mo } model.saved = &tf.SavedModel{Session: session, Graph: graph} + runtime.SetFinalizer(model, func(model *Model) { + if model.saved != nil && model.saved.Session != nil { + _ = model.saved.Session.Close() + } + }) return } diff --git a/ops.go b/ops.go index 8457e7f..3275d95 100644 --- a/ops.go +++ b/ops.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/scope.go b/scope.go index 7e99b4a..22f008a 100644 --- a/scope.go +++ b/scope.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/tensor.go b/tensor.go index c7ee87f..995354b 100644 --- a/tensor.go +++ b/tensor.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/test_models/create.py b/test_models/create.py index ad7ca5e..a5132ba 100644 --- a/test_models/create.py +++ b/test_models/create.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2020 Paolo Galeone +# Copyright (C) 2017-2022 Paolo Galeone # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/tfgo_test.go b/tfgo_test.go index 614483b..77389f0 100644 --- a/tfgo_test.go +++ b/tfgo_test.go @@ -1,5 +1,5 @@ /* -Copyright 2017-2020 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/types.go b/types.go index e6cf5c5..771357f 100644 --- a/types.go +++ b/types.go @@ -1,5 +1,5 @@ /* -Copyright 2017 Paolo Galeone. All right reserved. +Copyright 2017-2022 Paolo Galeone. All right reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -15,8 +15,9 @@ package tfgo import ( "fmt" - tf "github.com/galeone/tensorflow/tensorflow/go" "math" + + tf "github.com/galeone/tensorflow/tensorflow/go" ) // IsInteger returns true if dtype is a tensorflow integer type