The XrAiFactory
class serves as the central factory for creating instances of various AI model pipelines in the XR AI Library. It provides static methods to load different types of AI models by name.
public class XrAiFactory
Creates an instance of an Image-to-3D model pipeline.
public static IXrAImageTo3d LoadImageTo3d(string name, Dictionary<string, string> options = null)
Parameters:
name
(string): The name of the Image-to-3D model to load (e.g., “StabilityAi”)options
(Dictionary<string, string>, optional): Configuration options for the modelReturns:
IXrAImageTo3d
: An instance of the requested Image-to-3D modelThrows:
NotSupportedException
: When the specified model name is not supportedCreates an instance of an object detection model pipeline.
public static IXrAiObjectDetector LoadObjectDetector(string name, Dictionary<string, string> options = null, XrAiAssets assets = null)
Parameters:
name
(string): The name of the object detector model to load (e.g., “Google”, “Yolo”, “Roboflow”, “RoboflowLocal”)options
(Dictionary<string, string>, optional): Configuration options for the modelassets
(XrAiAssets, optional): Asset references required by some modelsReturns:
IXrAiObjectDetector
: An instance of the requested object detector modelThrows:
NotSupportedException
: When the specified model name is not supportedCreates an instance of an Image-to-Text model pipeline.
public static IXrAiImageToText LoadImageToText(string name, Dictionary<string, string> properties = null)
Parameters:
name
(string): The name of the Image-to-Text model to load (e.g., “Groq”, “Google”, “Nvidia”)properties
(Dictionary<string, string>, optional): Configuration properties for the modelReturns:
IXrAiImageToText
: An instance of the requested Image-to-Text modelThrows:
NotSupportedException
: When the specified model name is not supportedCreates an instance of an Image-to-Image model pipeline.
public static IXrAiImageToImage LoadImageToImage(string name, Dictionary<string, string> properties = null)
Parameters:
name
(string): The name of the Image-to-Image model to load (e.g., “OpenAI”)properties
(Dictionary<string, string>, optional): Configuration properties for the modelReturns:
IXrAiImageToImage
: An instance of the requested Image-to-Image modelThrows:
NotSupportedException
: When the specified model name is not supportedCreates an instance of a Text-to-Image model pipeline.
public static IXrAiTextToImage LoadTextToImage(string name, Dictionary<string, string> properties = null)
Parameters:
name
(string): The name of the Text-to-Image model to load (e.g., “OpenAI”)properties
(Dictionary<string, string>, optional): Configuration properties for the modelReturns:
IXrAiTextToImage
: An instance of the requested Text-to-Image modelThrows:
NotSupportedException
: When the specified model name is not supportedCreates an instance of a Speech-to-Text model pipeline.
public static IXrAiSpeechToText LoadSpeechToText(string name, Dictionary<string, string> properties = null)
Parameters:
name
(string): The name of the Speech-to-Text model to load (e.g., “OpenAI”)properties
(Dictionary<string, string>, optional): Configuration properties for the modelReturns:
IXrAiSpeechToText
: An instance of the requested Speech-to-Text modelThrows:
NotSupportedException
: When the specified model name is not supportedCreates an instance of a Text-to-Speech model pipeline.
public static IXrAiTextToSpeech LoadTextToSpeech(string name, Dictionary<string, string> properties = null)
Parameters:
name
(string): The name of the Text-to-Speech model to loadproperties
(Dictionary<string, string>, optional): Configuration properties for the modelReturns:
IXrAiTextToSpeech
: An instance of the requested Text-to-Speech modelThrows:
NotSupportedException
: When the specified model name is not supported// Load a Groq Image-to-Text model
IXrAiImageToText imageToText = XrAiFactory.LoadImageToText("Groq", new Dictionary<string, string>
{
{ "apiKey", "your-api-key" }
});
// Load a YOLO object detector
IXrAiObjectDetector objectDetector = XrAiFactory.LoadObjectDetector("Yolo", null, assets);
NotSupportedException
for unsupported model names