Backend: Remove NSFW code from photoprism package

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2019-12-14 14:38:43 +01:00
parent 63dab60a5e
commit 9987d65933
2 changed files with 3 additions and 35 deletions

View file

@ -46,13 +46,6 @@ func NewTensorFlow(conf *config.Config) *TensorFlow {
return &TensorFlow{conf: conf, modelName: "nasnet", modelTags: []string{"photoprism"}}
}
// NewTensorFlowNSFW returns new TensorFlow instance with NSFW model.
/* TODO: Need to convert model to tagged .pb file before we can test
func NewTensorFlowNSFW(conf *config.Config) *TensorFlow {
return &TensorFlow{conf: conf, modelName: "nsfw", modelTags: []string{"photoprism"}}
}
*/
func (t *TensorFlow) loadLabelRules() (err error) {
if len(t.labelRules) > 0 {
return nil
@ -103,6 +96,7 @@ func (t *TensorFlow) Labels(img []byte) (result Labels, err error) {
tensor, err := t.makeTensor(img, "jpeg")
if err != nil {
log.Error(err)
return nil, errors.New("invalid image")
}
@ -117,6 +111,7 @@ func (t *TensorFlow) Labels(img []byte) (result Labels, err error) {
nil)
if err != nil {
log.Error(err)
return result, errors.New("could not run inference")
}
@ -239,7 +234,7 @@ func (t *TensorFlow) bestLabels(probabilities []float32) Labels {
}
// Sort by probability
sort.Sort(Labels(result))
sort.Sort(result)
if l := len(result); l < 5 {
return result[:l]

View file

@ -273,30 +273,3 @@ func Test_ConvertTF(t *testing.T) {
result := convertTF(uint32(98765432))
assert.Equal(t, float32(3024.898), result)
}
/* TODO: Need to convert model to tagged .pb file before we can test
func TestTensorFlow_NSFW(t *testing.T) {
t.Run("/chameleon_lime.jpg", func(t *testing.T) {
conf := config.TestConfig()
conf.TensorFlowModelPath()
tensorFlow := NewTensorFlowNSFW(conf)
result, err := tensorFlow.LabelsFromFile(conf.ExamplesPath() + "/chameleon_lime.jpg")
assert.Nil(t, err)
if err != nil {
t.Log(err.Error())
t.Fail()
}
assert.NotNil(t, result)
assert.IsType(t, Labels{}, result)
assert.Equal(t, 1, len(result))
t.Log(result)
})
}
*/