AI is broken, split across incompatible frameworks, infrastructure, and hardware. Ivy brings all of the best-in-class tools directly to you, with one line of code.
Access all models, libraries, frameworks, infra and hardware
Run your model faster than ever, with 10x improvements on average
Integrate directly into your pre-existing projects, in seconds
Access all models, libraries, frameworks, infra and hardware
Run you model faster than ever, with 10x improvements on average
Integrate directly into your pre-existing projects, in seconds
When building ML tools, you have to decide on one framework or duplicate your efforts across frameworks. If you write your code once with Ivy, it will be available and interoperable with all frameworks, including ones that don't yet exist!
With all frameworks available under the hood with Ivy, all hardware targets are also available under the hood. Want to run on a mobile phone? Use TensorFlow with TFLite. Want to run on a TPU? Use JAX etc.
Your Ivy code can be integrated into any project, written in any framework. This could be just one Ivy function, one Ivy model, or an entire Ivy library. Ivy is totally complimentary to framework-native code.
Take any function, library or model from any framework, and use this directly in your own project, with one line of code. Never worry about frameworks or versions again, and finally experience "speed-of-thought" prototyping!
import ivy
import timm
import torch
import jax
import haiku as hk
# Get a pretrained pytorch model
mlp_encoder = timm.create_model("mixer_b16_224", pretrained=True, num_classes=0)
# Transpile it into a hk.Module with the corresponding parameters
noise = torch.randn(1, 3, 224, 224)
mlp_encoder = ivy.transpile(mlp_encoder, to="jax", args=(noise,))
# Build a classifier using the transpiled encoder
class Classifier(hk.Module):
def __init__(self, num_classes=1000):
super(Classifier, self).__init__()
self.encoder = mlp_encoder()
self.fc = hk.Linear(output_size=num_classes, with_bias=True)
def __call__(self, x):
x = self.encoder(x)
x = self.fc(x)
return x
def _forward_classifier(x):
module = Classifier()
return module(x)
# Transform the classifier and use it as a standard hk.Module
rng_key = jax.random.PRNGKey(42)
x = jax.random.uniform(key=rng_key, shape=(1, 3, 224, 224), dtype=jax.numpy.float32)
forward_classifier = hk.transform(_forward_classifier)
params = forward_classifier.init(rng=rng_key, x=x)
ret = forward_classifier.apply(params, None, x)
import ivy
import torch
import tensorflow as tf
# Get a pretrained keras model
eff_encoder = tf.keras.applications.efficientnet_v2.EfficientNetV2B0(
include_top=False, weights="imagenet", input_shape=(224, 224, 3)
)
# Transpile it into a torch.nn.Module with the corresponding parameters
noise = tf.random.normal(shape=(1, 224, 224, 3))
torch_eff_encoder = ivy.transpile(eff_encoder, to="torch", args=(noise,))
# Build a classifier using the transpiled encoder
class Classifier(torch.nn.Module):
def __init__(self, num_classes=20):
super(Classifier, self).__init__()
self.encoder = torch_eff_encoder
self.fc = torch.nn.Linear(1280, num_classes)
def forward(self, x):
x = self.encoder(x)
return self.fc(x)
# Initialize a trainable, customizable, torch.nn.Module
classifier = Classifier()
ret = classifier(torch.rand((1, 244, 244, 3)))
import ivy
import jax
import torch
# Get a pretrained haiku model
# https://unify.ai/demos/scripts/deepmind_perceiver_io.py
from deepmind_perceiver_io import key, perceiver_backbone
# Transpile it into a torch.nn.Module with the corresponding parameters
dummy_input = jax.random.uniform(key, shape=(1, 3, 224, 224))
params = perceiver_backbone.init(rng=key, images=dummy_input)
backbone = ivy.transpile(
perceiver_backbone, to="torch", params_v=params, kwargs={"images": dummy_input}
)
# Build a classifier using the transpiled backbone
class PerceiverIOClassifier(torch.nn.Module):
def __init__(self, num_classes=20):
super(PerceiverIOClassifier, self).__init__()
self.backbone = backbone
self.max_pool = torch.nn.MaxPool2d((512, 1))
self.flatten = torch.nn.Flatten()
self.fc = torch.nn.Linear(1024, num_classes)
def forward(self, x):
x = self.backbone(images=x)
x = self.flatten(self.max_pool(x))
return self.fc(x)
# Initialize a trainable, customizable, torch.nn.Module
classifier = PerceiverIOClassifier()
ret = classifier(torch.rand((1, 3, 224, 224)))
import ivy
import torch
import timm
import tensorflow as tf
# Get a pretrained pytorch model
mlp_encoder = timm.create_model("mixer_b16_224", pretrained=True, num_classes=0)
# Transpile it into a keras.Model with the corresponding parameters
noise = torch.randn(1, 3, 224, 224)
mlp_encoder = ivy.transpile(mlp_encoder, to="tensorflow", args=(noise,))
# Build a classifier using the transpiled encoder
class Classifier(tf.keras.Model):
def __init__(self):
super(Classifier, self).__init__()
self.encoder = mlp_encoder
self.output_dense = tf.keras.layers.Dense(units=1000, activation="softmax")
def call(self, x):
x = self.encoder(x)
return self.output_dense(x)
# Transform the classifier and use it as a standard keras.Model
x = tf.random.normal(shape=(1, 3, 224, 224))
model = Classifier()
ret = model(x)
import ivy
import jax
import tensorflow as tf
# Get a pretrained haiku model
# https://unify.ai/demos/scripts/deepmind_perceiver_io.py
from deepmind_perceiver_io import key, perceiver_backbone
# Transpile it into a tf.keras.Model with the corresponding parameters
dummy_input = jax.random.uniform(key, shape=(1, 3, 224, 224))
params = perceiver_backbone.init(rng=key, images=dummy_input)
backbone = ivy.transpile(
perceiver_backbone, to="tensorflow", params_v=params, args=(dummy_input,)
)
# Build a classifier using the transpiled backbone
class PerceiverIOClassifier(tf.keras.Model):
def __init__(self, num_classes=20):
super(PerceiverIOClassifier, self).__init__()
self.backbone = backbone
self.max_pool = tf.keras.layers.MaxPooling1D(pool_size=512)
self.flatten = tf.keras.layers.Flatten()
self.fc = tf.keras.layers.Dense(num_classes)
def call(self, x):
x = self.backbone(x)
x = self.flatten(self.max_pool(x))
return self.fc(x)
# Initialize a trainable, customizable, tf.keras.Model
x = tf.random.normal(shape=(1, 3, 224, 224))
classifier = PerceiverIOClassifier()
ret = classifier(x)
import ivy
import timm
import torch
import jax
import haiku as hk
# Get a pretrained pytorch model
mlp_encoder = timm.create_model("mixer_b16_224", pretrained=True, num_classes=0)
# Transpile it into a hk.Module with the corresponding parameters
noise = torch.randn(1, 3, 224, 224)
mlp_encoder = ivy.transpile(mlp_encoder, to="jax", args=(noise,))
# Build a classifier using the transpiled encoder
class Classifier(hk.Module):
def __init__(self, num_classes=1000):
super(Classifier, self).__init__()
self.encoder = mlp_encoder()
self.fc = hk.Linear(output_size=num_classes, with_bias=True)
def __call__(self, x):
x = self.encoder(x)
x = self.fc(x)
return x
def _forward_classifier(x):
module = Classifier()
return module(x)
# Transform the classifier and use it as a standard hk.Module
rng_key = jax.random.PRNGKey(42)
x = jax.random.uniform(key=rng_key, shape=(1, 3, 224, 224), dtype=jax.numpy.float32)
forward_classifier = hk.transform(_forward_classifier)
params = forward_classifier.init(rng=rng_key, x=x)
ret = forward_classifier.apply(params, None, x)
import ivy
import jax
import haiku as hk
import tensorflow as tf
# Get a pretrained keras model
eff_encoder = tf.keras.applications.efficientnet_v2.EfficientNetV2B0(
include_top=False, weights="imagenet", input_shape=(224, 224, 3)
)
# Transpile it into a hk.Module with the corresponding parameters
noise = tf.random.normal(shape=(1, 224, 224, 3))
hk_eff_encoder = ivy.transpile(eff_encoder, to="jax", args=(noise,))
# Build a classifier using the transpiled encoder
class Classifier(hk.Module):
def __init__(self, num_classes=1000):
super(Classifier, self).__init__()
self.encoder = hk_eff_encoder()
self.fc = hk.Linear(output_size=num_classes, with_bias=True)
def __call__(self, x):
x = self.encoder(x)
x = self.fc(x)
return x
def _forward_classifier(x):
module = Classifier()
return module(x)
# Transform the classifier and use it as a standard hk.Module
rng_key = jax.random.PRNGKey(42)
dummy_x = jax.random.uniform(key=rng_key, shape=(1, 224, 224, 3))
forward_classifier = hk.transform(_forward_classifier)
params = forward_classifier.init(rng=rng_key, x=dummy_x)
ret = forward_classifier.apply(params, None, dummy_x)
Code coming soon...
Code coming soon...
Code coming soon...
import ivy
import torch
import os
os.environ["SM_FRAMEWORK"] = "tf.keras"
import segmentation_models as sm
# transpile sm from tensorflow to torch
torch_sm = ivy.transpile(sm, source="tensorflow", to="torch")
# get some image-like arrays
output = torch.rand((1, 3, 512, 512))
target = torch.rand((1, 3, 512, 512))
# and use the transpiled version of any function from the library!
out = torch_sm.metrics.iou_score(output, target)
import ivy
import rax
import torch
# transpile rax from jax to torch
torch_rax = ivy.transpile(rax, source="jax", to="torch")
# get some arrays
scores = torch.tensor([2.2, 1.3, 5.4])
labels = torch.tensor([1.0, 0.0, 0.0])
# and use the transpiled version of any function from the library!
out = torch_rax.poly1_softmax_loss(scores, labels)
import ivy
import torch
import madmom
# transpile madmon from numpy to torch
torch_madmom = ivy.transpile(madmom, source="numpy", to="torch")
# get some arrays
freqs = torch.arange(20) * 10
# and use the transpiled version of any function from the library!
out = torch_madmom.audio.filters.hz2midi(freqs)
import ivy
import kornia
import requests
import numpy as np
import tensorflow as tf
from PIL import Image
# transpile kornia from torch to tensorflow
tf_kornia = ivy.transpile(kornia, source="torch", to="tensorflow")
# get an image
url = "http://images.cocodataset.org/train2017/000000000034.jpg"
raw_img = Image.open(requests.get(url, stream=True).raw)
# convert it to the format expected by kornia
img = np.array(raw_img)
img = tf.transpose(tf.constant(img), (2, 0, 1))
img = tf.expand_dims(img, 0) / 255
# and use the transpiled version of any function from the library!
out = tf_kornia.enhance.sharpness(img, 5)
import ivy
import rax
import tensorflow as tf
# transpile rax from jax to tensorflow
tf_rax = ivy.transpile(rax, source="jax", to="tensorflow")
# get some arrays
scores = tf.constant([2.2, 1.3, 5.4])
labels = tf.constant([1.0, 0.0, 0.0])
# and use the transpiled version of any function from the library!
out = tf_rax.poly1_softmax_loss(scores, labels)
import ivy
import madmom
import tensorflow as tf
# transpile madmom from numpy to tensorflow
tf_madmom = ivy.transpile(madmom, source="numpy", to="tensorflow")
# get some arrays
freqs = tf.range(20) * 10
# and use the transpiled version of any function from the library!
out = tf_madmom.audio.filters.hz2midi(freqs)
import ivy
import kornia
import requests
import jax.numpy as jnp
from PIL import Image
# transpile kornia from torch to jax
jax_kornia = ivy.transpile(kornia, source="torch", to="jax")
# get an image
url = "http://images.cocodataset.org/train2017/000000000034.jpg"
raw_img = Image.open(requests.get(url, stream=True).raw)
# convert it to the format expected by kornia
img = jnp.transpose(jnp.array(raw_img), (2, 0, 1))
img = jnp.expand_dims(img, 0) / 255
# and use the transpiled version of any function from the library!
out = jax_kornia.enhance.sharpness(img, 5)
import ivy
import jax
import os
os.environ["SM_FRAMEWORK"] = "tf.keras"
import segmentation_models as sm
# transpile sm from tensorflow to jax
jax_sm = ivy.transpile(sm, source="tensorflow", to="jax")
# get some image-like arrays
key = jax.random.PRNGKey(23)
key1, key2 = jax.random.split(key)
output = jax.random.uniform(key1, (1, 3, 512, 512))
target = jax.random.uniform(key2, (1, 3, 512, 512))
# and use the transpiled version of any function from the library!
out = jax_sm.metrics.iou_score(output, target)
import ivy
import madmom
import jax.numpy as jnp
# transpile madmon from numpy to jax
jax_madmom = ivy.transpile(madmom, source="numpy", to="jax")
# get some arrays
freqs = jnp.arange(20) * 10
# and use the transpiled version of any function from the library!
out = jax_madmom.audio.filters.hz2midi(freqs)
import ivy
import kornia
import requests
import numpy as np
from PIL import Image
# transpile kornia from torch to np
np_kornia = ivy.transpile(kornia, source="torch", to="numpy")
# get an image
url = "http://images.cocodataset.org/train2017/000000000034.jpg"
raw_img = Image.open(requests.get(url, stream=True).raw)
# convert it to the format expected by kornia
img = np.transpose(np.array(raw_img), (2, 0, 1))
img = np.expand_dims(img, 0) / 255
# and use the transpiled version of any function from the library!
out = np_kornia.enhance.sharpness(img, 5)
import ivy
import numpy as np
import os
os.environ["SM_FRAMEWORK"] = "tf.keras"
import segmentation_models as sm
# transpile sm from tensorflow to numpy
np_sm = ivy.transpile(sm, source="tensorflow", to="numpy")
# get some image-like arrays
output = np.random.rand(1, 3, 512, 512).astype(dtype=np.float32)
target = np.random.rand(1, 3, 512, 512).astype(dtype=np.float32)
# and use the transpiled version of any function from the library!
out = np_sm.metrics.iou_score(output, target)
import ivy
import rax
import numpy as np
# transpile rax from jax to numpy
np_rax = ivy.transpile(rax, source="jax", to="numpy")
# get some arrays
scores = np.array([2.2, 1.3, 5.4])
labels = np.array([1.0, 0.0, 0.0])
# and use the transpiled version of any function from the library!
out = np_rax.poly1_softmax_loss(scores, labels)
import ivy
import tensorflow as tf
import torch
def loss(predictions, targets):
return tf.sqrt(tf.reduce_mean(tf.square(predictions - targets)))
# transpile any function from tf to torch
torch_loss = ivy.transpile(loss, source="tensorflow", to="torch")
# get some arrays
p = torch.tensor([3.0, 2.0, 1.0])
t = torch.tensor([0.0, 0.0, 0.0])
# and use the transpiled version!
out = torch_loss(p, t)
import ivy
import jax.numpy as jnp
import torch
def loss(predictions, targets):
return jnp.sqrt(jnp.mean((predictions - targets) ** 2))
# transpile any function from jax to torch
torch_loss = ivy.transpile(loss, source="jax", to="torch")
# get some arrays
p = torch.tensor([3.0, 2.0, 1.0])
t = torch.tensor([0.0, 0.0, 0.0])
# and use the transpiled version!
out = torch_loss(p, t)
import ivy
import numpy as np
import torch
def loss(predictions, targets):
return np.sqrt(np.mean((predictions - targets) ** 2))
# transpile any function from numpy to torch
torch_loss = ivy.transpile(loss, source="numpy", to="torch")
# get some arrays
p = torch.tensor([3.0, 2.0, 1.0])
t = torch.tensor([0.0, 0.0, 0.0])
# and use the transpiled version!
out = torch_loss(p, t)
import ivy
import torch
import tensorflow as tf
def loss(predictions, targets):
return torch.sqrt(torch.mean((predictions - targets) ** 2))
# transpile any function from torch to tensorflow
tf_loss = ivy.transpile(loss, source="torch", to="tensorflow")
# get some arrays
p = tf.constant([3.0, 2.0, 1.0])
t = tf.constant([0.0, 0.0, 0.0])
# and use the transpiled version!
out = tf_loss(p, t)
import ivy
import jax.numpy as jnp
import tensorflow as tf
def loss(predictions, targets):
return jnp.sqrt(jnp.mean((predictions - targets) ** 2))
# transpile any function from jax to tensorflow
tf_loss = ivy.transpile(loss, source="jax", to="tensorflow")
# get some arrays
p = tf.constant([3.0, 2.0, 1.0])
t = tf.constant([0.0, 0.0, 0.0])
# and use the transpiled version!
out = tf_loss(p, t)
import ivy
import numpy as np
import tensorflow as tf
def loss(predictions, targets):
return np.sqrt(np.mean((predictions - targets) ** 2))
# transpile any function from numpy to tensorflow
tf_loss = ivy.transpile(loss, source="numpy", to="tensorflow")
# get some arrays
p = tf.constant([3.0, 2.0, 1.0])
t = tf.constant([0.0, 0.0, 0.0])
# and use the transpiled version!
out = tf_loss(p, t)
import ivy
import torch
import jax.numpy as jnp
def loss(predictions, targets):
return torch.sqrt(torch.mean((predictions - targets) ** 2))
# transpile any function from torch to jax
jax_loss = ivy.transpile(loss, source="torch", to="jax")
# get some arrays
p = jnp.array([3.0, 2.0, 1.0])
t = jnp.array([0.0, 0.0, 0.0])
# and use the transpiled version!
out = jax_loss(p, t)
import ivy
import tensorflow as tf
import jax.numpy as jnp
def loss(predictions, targets):
return tf.sqrt(tf.reduce_mean(tf.square(predictions - targets)))
# transpile any function from tf to jax
jax_loss = ivy.transpile(loss, source="tensorflow", to="jax")
# get some arrays
p = jnp.array([3.0, 2.0, 1.0])
t = jnp.array([0.0, 0.0, 0.0])
# and use the transpiled version!
out = jax_loss(p, t)
import ivy
import numpy as np
import jax
import jax.numpy as jnp
jax.config.update('jax_enable_x64', True)
def loss(predictions, targets):
return np.sqrt(np.mean((predictions - targets) ** 2))
# transpile any function from numpy to jax
jax_loss = ivy.transpile(loss, source="numpy", to="jax")
# get some arrays
p = jnp.array([3.0, 2.0, 1.0])
t = jnp.array([0.0, 0.0, 0.0])
# and use the transpiled version!
out = jax_loss(p, t)
import ivy
import torch
import numpy as np
def loss(predictions, targets):
return torch.sqrt(torch.mean((predictions - targets) ** 2))
# transpile any function from torch to numpy
np_loss = ivy.transpile(loss, source="torch", to="numpy")
# get some arrays
p = np.array([3.0, 2.0, 1.0])
t = np.array([0.0, 0.0, 0.0])
# and use the transpiled version!
out = np_loss(p, t)
import ivy
import tensorflow as tf
import numpy as np
def loss(predictions, targets):
return tf.sqrt(tf.reduce_mean(tf.square(predictions - targets)))
# transpile any function from tf to numpy
np_loss = ivy.transpile(loss, source="tensorflow", to="numpy")
# get some arrays
p = np.array([3.0, 2.0, 1.0])
t = np.array([0.0, 0.0, 0.0])
# and use the transpiled version!
out = np_loss(p, t)
import ivy
import jax.numpy as jnp
import numpy as np
def loss(predictions, targets):
return jnp.sqrt(jnp.mean((predictions - targets) ** 2))
# transpile any function from jax to numpy
np_loss = ivy.transpile(loss, source="jax", to="numpy")
# get some arrays
p = np.array([3.0, 2.0, 1.0])
t = np.array([0.0, 0.0, 0.0])
# and use the transpiled version!
out = np_loss(p, t)
With so many frameworks, compilers, cloud providers, and hardware targets, it's impossible to know which combination would be the fastest, cheapest, and the most scalable for your unique case. Ivy automatically finds the optimal match for your own deployment needs, with one line of code.
Join our growing community on a mission to unify AI, by using Ivy in your own projects! Ivy's discord server is the perfect place to ask questions, share ideas, and get help from fellow developers and also the Ivy team
GitHub stars
GitHub Open source contributors
GitHub forks
Members in Discord
GitHub stars
GitHub forks
GitHub Open source contributors
Members in Discord
We're honoured to have continued support from several top VC funds and angel investors, all backing our ambitious mission to unify the field!
We won’t spam you
Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet
pip install ivy, and see how the new era of AI interoperability can accelerate your own workflow