Files
photoprism/internal/ai/tensorflow/util.go
raystlin d0f6d903e2 Added utilities to inspect tensorflow models.
These new functions allows us to inspect the saved models, get the tags
and try to guess the inputs and outputs.
2025-04-11 14:30:48 +00:00

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
}