Files
photoprism/internal/api/vision_labels.go
Michael Mayer 35e9294d87 AI: Add vision package and vision API endpoints #127 #1090
These changes allow to configure the computer vision models through an
optional vision.yml configuration file. Note that the API endpoints
are not yet functional and require further work.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2025-04-06 23:39:37 +02:00

36 lines
881 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/ai/vision"
"github.com/photoprism/photoprism/internal/auth/acl"
"github.com/photoprism/photoprism/pkg/rnd"
)
// PostVisionLabels returns suitable labels for an image.
//
// @Summary returns suitable labels for an image
// @Id PostVisionLabels
// @Tags Vision
// @Produce json
// @Success 200 {object} vision.LabelsResponse
// @Failure 401,403,429 {object} i18n.Response
// @Router /api/v1/vision/labels [post]
func PostVisionLabels(router *gin.RouterGroup) {
router.POST("/vision/labels", func(c *gin.Context) {
s := Auth(c, acl.ResourceVision, acl.AccessAll)
// Abort if permission is not granted.
if s.Abort(c) {
return
}
response := vision.NewLabelsResponse(rnd.UUID(), vision.NasnetModel, nil)
c.JSON(http.StatusOK, response)
})
}