1require'onnxruntime'23# Assumes you have SigLIP2 embeddings from your existing Ruby setup4# (e.g., via the onnxruntime gem with the SigLIP2 ONNX model)56classModerationClassifier7definitialize(model_dir =".")8@nsfw= OnnxRuntime::Model.new(File.join(model_dir,"nsfw_head.onnx"))9@violence= OnnxRuntime::Model.new(File.join(model_dir,"violence_head.onnx"))10@ai_generated= OnnxRuntime::Model.new(File.join(model_dir,"ai_generated_head.onnx"))11end1213defclassify(embedding)14# embedding should be a normalized 768-dim array15 input ={"embedding"=>[embedding]}1617{18nsfw: sigmoid(@nsfw.predict(input)["logits"][0][0]),19violence: sigmoid(@violence.predict(input)["logits"][0][0]),20ai_generated: sigmoid(@ai_generated.predict(input)["logits"][0][0])21}22end2324private2526defsigmoid(x)271.0/(1.0+ Math.exp(-x))28end29end3031# Usage32classifier =ModerationClassifier.new("path/to/models")33embedding = get_siglip_embedding("test.jpg")# your SigLIP2 code34scores = classifier.classify(embedding)3536puts "NSFW: #{scores[:nsfw].round(3)}"37puts "Violence: #{scores[:violence].round(3)}"38puts "AI-Generated: #{scores[:ai_generated].round(3)}"