mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 08:44:04 +01:00
These new functions allows us to inspect the saved models, get the tags and try to guess the inputs and outputs.
28 lines
517 B
Go
28 lines
517 B
Go
package tensorflow
|
|
|
|
import "math/rand"
|
|
|
|
func randomString(length int) string {
|
|
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
result := make([]byte, length)
|
|
for i := range result {
|
|
result[i] = charset[rand.Intn(len(charset))]
|
|
}
|
|
return string(result)
|
|
}
|
|
|
|
func GetOne[K comparable, V any](input map[K]V) (*K, *V) {
|
|
for k, v := range input {
|
|
return &k, &v
|
|
}
|
|
|
|
return nil, nil
|
|
}
|
|
|
|
func Deref[V any](input *V, defval V) V {
|
|
if input == nil {
|
|
return defval
|
|
}
|
|
return *input
|
|
}
|