Skip to main content

Mutimodal-files

Web-ready standardized file processing and serialization

Features

Read, load and convert to standard file types with a common interface. Especially useful for code that works with multiple file types like images, audio, video, etc.

Load and convert from and to common data types:

  • numpy arrays
  • file paths
  • bytes,
  • base64
  • json
  • etc.

Transmit files between services with a common interface

  • Native FastSDK and FastTaskAPI integration
  • Supports httpx, requests

Work with native python libs like BytesIO.

Only use the file types you need, no unnecessary dependencies.

Installation

You can install the package with PIP, or clone the repository.

# install full version
pip install multimodal-files[full]
# install from pypi (no dependencies)
pip install multimodal-files

# install from github for newest release
pip install git+git://github.com/SocAIty/multimodal-files

The version without dependencies does not include the optional dependencies like numpy, soundfile, etc. Instead you can only install the dependencies which are required for your project. Making the package size tiny.

Usage

Create a multimodal-file from any data type

The library automatically detect the data type and loads it correctly.

from multimodal_files import MultiModalFile, ImageFile, AudioFile, VideoFile

# represents either path, base64, bytesio, file_handle, numpy array ...
arbitrary_data = "...."
new_file = ImageFile().from_any(arbitrary_data)

All files (ImageFile, AudioFile, VideoFile) types support the same interface / methods.

Explicitly load from a certain type.

This method is more secure than from_any, because it definitely uses the correct method to load the file.

new_file = MultiModalFile()

new_file.from_file("path/to/file")
new_file.from_file(open("path/to/file", "rb"))
new_file.from_numpy_array(my_array)
new_file.from_bytes(b'bytes')
new_file.from_base64('base64string')
new_file.from_starlette_upload_file(starlette_upload_file)

Convert to any format or write to file

Supports common serialization methods like bytes(), np.array(), dict()

my_file = ImageFile().from_file("path/to/my_image.png")

my_file.save("path/to/new_file.png")  
as_numpy_array = my_file.to_numpy_array()
as_numpy_array = np.array(my_file)

as_bytes = my_file.to_bytes()
as_bytes = bytes(my_file)
as_base64 = my_file.to_base64()
as_json = my_file.to_json()

Easy conversion from any type

my_image_file = convert_to_upload_file_type(arbitrary_data, ImageFile) 

Metadata

Release files for multimodal-files 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multimodal-files 0.0.0
File Size Uploaded Provenance Actions
multimodal_files-0.0.0.tar.gz 21.3 kB Without provenance Details for multimodal_files-0.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multimodal-files 0.0.0
File Interpreter ABI Platform Actions
multimodal_files-0.0.0-py3-none-any.whl Python 3 none any Details for multimodal_files-0.0.0-py3-none-any.whl

Total release size: 43.7 kB

Release files / multimodal_files-0.0.0.tar.gz

Download URL multimodal_files-0.0.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
80e87952563ec5cc735b16626022efb1afa38895a67b1c41a2be2f198e65df28
BLAKE2b-256 checksum
How to use checksums
79412d8c1218a1e414725d3b0f49819d7b68313ae07bd6f66fe5c0a2c7b16cc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.11

Release files / multimodal_files-0.0.0-py3-none-any.whl

Download URL multimodal_files-0.0.0-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1332bb8d2c84c96098b123244448cb398e2339d8afda3d18a2f8509e60753784
BLAKE2b-256 checksum
How to use checksums
960e69cc9ad07899529027d21f5a6c9f2f41f857dfd01057ef74e9b4f952c807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.11

Security for multimodal-files 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page