Types
Mixtrain types add semantics to your data values. That meaning follows a value through the whole platform: mark a dataset column as an Image and you get Image previews in dataset, in SQL query results, as an input or output of models, workflows, and routines, and in evaluation views. Each type also provides convenient helper methods for common tasks, such as downloading a file or converting an image to numpy.
Media Types
File, Image, Video, and Audio reference a file by URL (https://, gs://, or s3://).
File
Base class for file references. Use for generic files. See File for details.
from mixtrain import MixModel, File
class Archiver(MixModel):
def run(self, data: File) -> dict[str, File]:
path = data.to_file() # download to a local path
archive(path, out="out.zip")
return {"result": File.from_file("out.zip").save()}Helpers:
to_file(path=None)- Download to local file. Returns path. Cached for subsequent calls.save()- Upload file to Mixtrain storage and return a saved reference. Saved files can be accessed by other models and workflows.save(path)- Upload file to specific path in Mixtrain storage and return a saved reference.
Image
Renders an image inline. Extends File with image-specific helpers. See Image for details.
from mixtrain import MixModel, Image
class Upscaler(MixModel):
def run(self, image: Image) -> dict[str, Image]:
arr = image.to_numpy() # numpy array (H, W, C)
upscale(arr, out="out.png")
return {"result": Image.from_file("out.png").save()}Helpers:
to_file(path=None)- Download to local fileto_pil()- Return as PIL.Image objectto_numpy()- Return as numpy array (H, W, C)
Video
Renders a video with a player. Extends File with video-specific helpers. See Video for details.
from mixtrain import MixFlow, Video
class FrameInterpolator(MixFlow):
def run(self, video: Video) -> dict[str, Video]:
frames = [interpolate(f) for f in video.to_frames()] # numpy arrays (H, W, C)
write_video(frames, "out.mp4")
return {"result": Video.from_file("out.mp4").save()}Helpers:
to_file(path=None)- Download to local fileto_cv2()- Return as cv2.VideoCaptureto_frames()- Yield frames as numpy arrays (H, W, C) in BGR
Audio
Renders an audio player. Extends File with audio-specific helpers. See Audio for details.
from mixtrain import MixFlow, Audio
class Denoiser(MixFlow):
def run(self, audio: Audio) -> dict[str, Audio]:
samples, sample_rate = audio.to_numpy()
denoise(samples, sample_rate, out="out.wav")
return {"result": Audio.from_file("out.wav").save()}Helpers:
to_file(path=None)- Download to local fileto_numpy()- Return as (samples array, sample_rate) tuple
Model3D
Renders a 3D model viewer. url points to the model file; format is one of glb, gltf, or obj.
from mixtrain import MixModel, Model3D
class MeshGenerator(MixModel):
def run(self, prompt: str) -> dict[str, Model3D]:
generate_mesh(prompt, out="out.glb")
return {"result": Model3D.from_file("out.glb").save()}Array Types
Numeric vectors and N-dimensional arrays for ML features, robotics, and multimodal data.
Embedding
ML embedding vectors for semantic representations. See Embedding for details.
from mixtrain import MixModel, Embedding
class TextEmbedder(MixModel):
def run(self, text: str) -> dict[str, Embedding]:
return {"embedding": Embedding(values=embed(text))}Tensor
N-dimensional numeric arrays for ML features, robotics, and multimodal data — such as action sequences, joint state, depth maps, or point clouds. See Tensor for details.
from mixtrain import MixModel, Tensor
class Policy(MixModel):
def run(self, observation: Tensor) -> dict[str, Tensor]:
actions = predict(observation.to_numpy()) # action sequence (timesteps, joints)
return {"action": Tensor.from_numpy(actions)}Helpers:
Tensor.from_numpy(array, dim_names=None)- Create from a numpy array, capturing its shape and dtypeto_numpy()- Return as a numpy array
As a dataset column type, tensors in a column should share the same shape and dtype. Reading the column back with to_tensors() restores each row's full N-dimensional shape.
Text Types
Inline text content rendered in the UI:
from mixtrain import Text, Markdown, JSON
Text(content="Processing complete!") # plain text
Markdown(content="# Results\n- Item 1") # rich Markdown
JSON(data={"key": "value", "items": [1, 2, 3]}) # syntax-highlighted JSON