classify

package
v0.0.0-...-c8acfb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package classify encapsulates image classification using TensorFlow.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const (
	// data sources
	SrcAuto     = ""
	SrcManual   = "manual"
	SrcLocation = "location"
	SrcImage    = "image"
	SrcKeyword  = "keyword"
)

Variables

View Source
var Rules = LabelRules{}/* 1075 elements not displayed */

Functions

This section is empty.

Types

type Label

type Label struct {
	Name        string   `json:"label"`       // Label name
	Source      string   `json:"source"`      // Where was this label found / detected?
	Uncertainty int      `json:"uncertainty"` // >= 0
	Priority    int      `json:"priority"`    // >= 0
	Categories  []string `json:"categories"`  // List of similar labels
}

Label represents a MediaFile label (automatically created).

func LocationLabel

func LocationLabel(name string, uncertainty int) Label

LocationLabel returns a new location label.

func (Label) Title

func (l Label) Title() string

Title returns a formatted label title as string.

type LabelRule

type LabelRule struct {
	Label      string
	Threshold  float32
	Categories []string
	Priority   int
}

LabelRule defines the rule for a given Label

type LabelRules

type LabelRules map[string]LabelRule

LabelRules is a map of rules with label name as index

func (LabelRules) Find

func (rules LabelRules) Find(label string) (rule LabelRule, ok bool)

Find is a getter for LabelRules that give a default rule with a non-zero threshold for missing keys

type Labels

type Labels []Label

Labels is list of MediaFile labels.

func (Labels) AppendLabel

func (l Labels) AppendLabel(label Label) Labels

AppendLabel extends append func by not appending empty label

func (Labels) Keywords

func (l Labels) Keywords() (result []string)

Keywords returns all keywords contains in Labels and their categories

func (Labels) Len

func (l Labels) Len() int

func (Labels) Less

func (l Labels) Less(i, j int) bool

func (Labels) Swap

func (l Labels) Swap(i, j int)

func (Labels) Title

func (l Labels) Title(fallback string) string

Title gets the best label out a list of labels or fallback to compute a meaningful default title.

type TensorFlow

type TensorFlow struct {
	// contains filtered or unexported fields
}

TensorFlow is a wrapper for tensorflow low-level API.

func New

func New(modelsPath string, disabled bool) *TensorFlow

New returns new TensorFlow instance with Nasnet model.

func (*TensorFlow) File

func (t *TensorFlow) File(filename string) (result Labels, err error)

File returns matching labels for a jpeg media file.

func (*TensorFlow) Init

func (t *TensorFlow) Init() (err error)

Init initialises tensorflow models if not disabled

func (*TensorFlow) Labels

func (t *TensorFlow) Labels(img []byte) (result Labels, err error)

Labels returns matching labels for a jpeg media string.

func (*TensorFlow) ModelLoaded

func (t *TensorFlow) ModelLoaded() bool

ModelLoaded tests if the TensorFlow model is loaded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL