Documentation
¶
Overview ¶
Package onnx provides a pure-Go wrapper around the ONNX Runtime shared library for AIGC image detection. Zero CGO dependency.
Index ¶
Constants ¶
const ( // ModelInputName is the expected ONNX model input tensor name. ModelInputName = "pixel_values" // ModelOutputName is the expected ONNX model output tensor name. ModelOutputName = "logits" // ModelInputSize is the expected image size (width/height) in pixels. ModelInputSize = 224 // ModelChannels is the expected number of color channels. ModelChannels = 3 )
Variables ¶
This section is empty.
Functions ¶
func DefaultLibPath ¶
DefaultLibPath returns the expected path for the ONNX Runtime shared library. Prefers GPU variant, falls back to CPU.
func DefaultModelPath ¶
DefaultModelPath returns the expected path for the ONNX model file.
func Preprocess ¶
Preprocess converts an image to a normalized float32 tensor suitable for the AIGC detection model. It resizes to targetSize x targetSize and normalizes pixel values to [0, 1].
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector manages the ONNX Runtime lifecycle and inference session.
func NewDetector ¶
NewDetector creates a new ONNX Detector, loading the runtime and model. Call Close() when done to release resources.
func (*Detector) Detect ¶
Detect runs AIGC detection on the given image. The image must be decoded (can be any format supported by image.Decode).
func (*Detector) DetectFile ¶
DetectFile loads an image file and runs AIGC detection.