Skip to content

Commit

Permalink
updater copyright year, fix leak in ImportModel
Browse files Browse the repository at this point in the history
  • Loading branch information
galeone committed Oct 15, 2022
1 parent 2eb64a6 commit ffa0df0
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion image/filter/filters.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions image/image.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion image/image_override.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion image/image_private.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions image/image_test.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 (
Expand Down
15 changes: 11 additions & 4 deletions model.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion ops.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion scope.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tensor.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test_models/create.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017-2020 Paolo Galeone <[email protected]>
# Copyright (C) 2017-2022 Paolo Galeone <[email protected]>
#
# 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
Expand Down
2 changes: 1 addition & 1 deletion tfgo_test.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit ffa0df0

Please sign in to comment.