Uform

Latest version: v3.0.2

Safety actively analyzes 625891 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 6

3.0.2

[3.0.2](https://github.com/unum-cloud/uform/compare/v3.0.1...v3.0.2) (2024-04-25)


Make

* Change NPM name ([e97977e](https://github.com/unum-cloud/uform/commit/e97977e1fd82669f47cb0972a61c2a58e0f928a4))

3.0.1

[3.0.1](https://github.com/unum-cloud/uform/compare/v3.0.0...v3.0.1) (2024-04-25)


Make

* Upgrade CI ([83fc71a](https://github.com/unum-cloud/uform/commit/83fc71a16250c0ae9a1e8bccd414aa746b6139f6))

3.0.0

Multimodal AI for JavaScript, Swift, and Python

How many AI models can run on-device out of the box? UForm multimodal embeddings can 🥳

| Model | Parameters | Languages | Architecture |
| :-------------------------------------------------- | ---------: | --------: | -------------------------------------------: |
| [`uform3-image-text-english-large`][model-e-l] 🆕 | 365M | 1 | 6 text layers, ViT-L/14, 6 multimodal layers |
| [`uform3-image-text-english-base`][model-e] | 143M | 1 | 2 text layers, ViT-B/16, 2 multimodal layers |
| [`uform3-image-text-english-small`][model-e-s] 🆕 | 79M | 1 | 2 text layers, ViT-S/16, 2 multimodal layers |
| [`uform3-image-text-multilingual-base`][model-m-v2] | 206M | 21 | 8 text layers, ViT-B/16, 4 multimodal layers |

[model-e-l]: https://huggingface.co/unum-cloud/uform-vl-english-large/
[model-e]: https://huggingface.co/unum-cloud/uform-vl-english/
[model-e-s]: https://huggingface.co/unum-cloud/uform-vl-english-small/
[model-m]: https://huggingface.co/unum-cloud/uform-vl-multilingual/
[model-m-v2]: https://huggingface.co/unum-cloud/uform-vl-multilingual-v2/

JavaScript

Load the models and preprocessors for different modalities:

js
import { getModel, Modality, TextProcessor, TextEncoder, ImageEncoder, ImageProcessor } from 'unum-cloud/uform';

const { configPath, modalityPaths, tokenizerPath } = await getModel({
modelId: 'unum-cloud/uform3-image-text-english-small',
modalities: [Modality.TextEncoder, Modality.ImageEncoder],
});


Embed images:

js
const imageProcessor = new ImageProcessor(configPath);
await imageProcessor.init();
const processedImages = await imageProcessor.process("path/to/image.png");

const imageEncoder = new ImageEncoder(modalityPaths.image_encoder, imageProcessor);
await imageEncoder.init();
const imageOutput = await imageEncoder.encode(processedImages);
assert(imageOutput.embeddings.dims.length === 2, "Output should be 2D");


Embed queries:

js
const textProcessor = new TextProcessor(configPath, tokenizerPath);
await textProcessor.init();
const processedTexts = await textProcessor.process("a small red panda in a zoo");

const textEncoder = new TextEncoder(modalityPaths.text_encoder, textProcessor);
await textEncoder.init();
const textOutput = await textEncoder.encode(processedTexts);
assert(textOutput.embeddings.dims.length === 2, "Output should be 2D");
await textEncoder.dispose();


Swift

Embed images:

swift
let imageModel = try await ImageEncoder(modelName: "unum-cloud/uform3-image-text-english-small")
let imageURL = "https://github.com/ashvardanian/ashvardanian/blob/master/demos/bbq-on-beach.jpg?raw=true"
guard let url = URL(string: imageURL),
let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil),
let cgImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) {
throw Exception("Could not load image from URL: \(imageURL)")
}

var imageEmbedding: Embedding = try imageModel.encode(cgImage)
var imageVector: [Float32] = embedding.asFloats()


Embed queries:

swift
let textModel = try await TextEncoder(modelName: "unum-cloud/uform3-image-text-english-small")
let text = "A group of friends enjoy a barbecue on a sandy beach, with one person grilling over a large black grill, while the other sits nearby, laughing and enjoying the camaraderie."
let textEmbedding: Embedding = try textModel.encode(text)
let textVector: [Float32] = textEmbedding.asFloats()


Python

Load model:

py
from uform import get_model, Modality

model_name = 'unum-cloud/uform3-image-text-english-small'
modalities = [Modality.TEXT_ENCODER, Modality.IMAGE_ENCODER]
processors, models = get_model(model_name, modalities=modalities)


Embed images:

py
import requests
from io import BytesIO
from PIL import Image

image_url = 'https://media-cdn.tripadvisor.com/media/photo-s/1b/28/6b/53/lovely-armenia.jpg'
image = Image.open(BytesIO(requests.get(image_url).content))

processor_image = processors[Modality.IMAGE_ENCODER]
model_image = models[Modality.IMAGE_ENCODER]
image_data = processor_image(image)
image_features, image_embedding = model_image.encode(image_data, return_features=True)


Embed queries:

py
text = 'a cityscape bathed in the warm glow of the sun, with varied architecture and a towering, snow-capped mountain rising majestically in the background'

model_text = models[Modality.TEXT_ENCODER]
processor_text = processors[Modality.TEXT_ENCODER]

text_data = processor_text(text)
text_features, text_embedding = model_text.encode(text_data, return_features=True)

2.1.1

[2.1.1](https://github.com/unum-cloud/uform/compare/v2.1.0...v2.1.1) (2024-04-16)


Fix

* Importing ViT in `gen_model.py` (80) ([21f49ba](https://github.com/unum-cloud/uform/commit/21f49bab444e0761ab7fc7ed20b3c81fb7924d17)), closes [#80](https://github.com/unum-cloud/uform/issues/80)

2.1.0

[2.1.0](https://github.com/unum-cloud/uform/compare/v2.0.2...v2.1.0) (2024-04-14)


Add

* Initial Swift support ([00bd84c](https://github.com/unum-cloud/uform/commit/00bd84c59995c7b3daa0b4fa1597f77608806fdb))

Fix

* Image preprocessing in Swift ([f2772d0](https://github.com/unum-cloud/uform/commit/f2772d0d92317818c4d1c49166bc7ec3ee314f60))

Improve

* Fetching nested configs ([729b9d9](https://github.com/unum-cloud/uform/commit/729b9d9f73990f2689c22af593171184589a2b27))

Make

* Formatting Swift code ([f6faf4c](https://github.com/unum-cloud/uform/commit/f6faf4cd877f6034d8c66edb108bc07ec1735232))

2.0.2

[2.0.2](https://github.com/unum-cloud/uform/compare/v2.0.1...v2.0.2) (2024-03-28)


Make

* Fix PyPi CI version with hash ([364afe6](https://github.com/unum-cloud/uform/commit/364afe605540c5ca8649c6b798ce4d8e65540c7c))

Page 1 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.