Classes
Audio
Inherits from: File
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
__pydantic_self__ | - | - | - |
data | Any | - | - |
Methods
Methods
Config
CompressedFile
Inherits from: File
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
__pydantic_self__ | - | - | - |
data | Any | - | - |
Class Variables
Class Variables
| Name | Type | Default | Description |
|---|---|---|---|
extract_dir | Optional[str] | - | - |
Methods
Methods
File
Inherits from: BaseModel
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
__pydantic_self__ | - | - | - |
data | Any | - | - |
Class Variables
Class Variables
| Name | Type | Default | Description |
|---|---|---|---|
url | str | - | - |
content_type | Optional[str] | - | - |
file_name | Optional[str] | - | - |
file_size | Optional[int] | - | - |
file_data | Optional[bytes] | - | - |
Methods
Methods
as_bytes
bytesfrom_bytes
| Parameter | Type | Default | Description |
|---|---|---|---|
data | bytes | - | - |
content_type | Optional[str] | None | - |
file_name | Optional[str] | None | - |
repository | FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn] | 'fal_v3' | - |
fallback_repository | FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn] | list[FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn]] | NoneType | ['cdn', 'fal'] | - |
request | Optional[Request] | None | - |
save_kwargs | Optional[dict] | None | - |
fallback_save_kwargs | Optional[dict] | None | - |
Filefrom_path
| Parameter | Type | Default | Description |
|---|---|---|---|
path | str | pathlib.Path | - | - |
content_type | Optional[str] | None | - |
repository | FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn] | 'fal_v3' | - |
multipart | bool | None | None | - |
fallback_repository | FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn] | list[FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn]] | NoneType | ['cdn', 'fal'] | - |
request | Optional[Request] | None | - |
save_kwargs | Optional[dict] | None | - |
fallback_save_kwargs | Optional[dict] | None | - |
Filesave
| Parameter | Type | Default | Description |
|---|---|---|---|
path | str | pathlib.Path | - | - |
overwrite | bool | False | - |
PathImage
Inherits from: File
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
__pydantic_self__ | - | - | - |
data | Any | - | - |
Class Variables
Class Variables
| Name | Type | Default | Description |
|---|---|---|---|
width | Optional[int] | - | - |
height | Optional[int] | - | - |
Methods
Methods
Config
from_bytes
| Parameter | Type | Default | Description |
|---|---|---|---|
data | bytes | - | - |
format | Literal[png, jpeg, jpg, webp, gif] | - | - |
size | fal.toolkit.image.image.ImageSize | None | None | - |
file_name | str | None | None | - |
repository | FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn] | 'fal_v3' | - |
fallback_repository | FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn] | list[FileRepository | Literal[fal, fal_v2, fal_v3, in_memory, gcp_storage, r2, cdn]] | NoneType | ['cdn', 'fal'] | - |
request | Optional[Request] | None | - |
Imagefrom_pil
| Parameter | Type | Default | Description |
|---|---|---|---|
pil_image | PILImage.Image | - | - |
format | ImageFormat | None | None | - |
file_name | str | None | None | - |
repository | FileRepository | RepositoryId | 'fal_v3' | - |
fallback_repository | Optional[FileRepository | RepositoryId | list[FileRepository | RepositoryId]] | ['cdn', 'fal'] | - |
request | Optional[Request] | None | - |
to_pil
| Parameter | Type | Default | Description |
|---|---|---|---|
mode | str | 'RGB' | - |
KVStore
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
db_name | str | - | The name of the database/namespace to use for this KV store. |
Properties
Properties
| Name | Type | Description |
|---|---|---|
auth_headers | dict[str, str] | - |
Methods
Methods
Video
Inherits from: File
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
__pydantic_self__ | - | - | - |
data | Any | - | - |
Methods
Methods
Config
FalTookitException
Inherits from: Exception
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
args | - | - | - |
kwargs | - | - | - |
FileUploadException
Inherits from: FalTookitException
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
args | - | - | - |
kwargs | - | - | - |
KVStoreException
Inherits from: FalTookitException
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
args | - | - | - |
kwargs | - | - | - |
DownloadError
Inherits from: Exception
Constructor Parameters
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
args | - | - | - |
kwargs | - | - | - |
Functions
get_image_size
| Parameter | Type | Default | Description |
|---|---|---|---|
source | ImageSize | Literal[square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9] | - | - |
ImageSize
optimize
| Parameter | Type | Default | Description |
|---|---|---|---|
module | torch.nn.Module | - | - |
optimization_config | dict[str, Any] | None | None | - |
clone_repository
commit_hash is provided.
If a custom target_dir or repo_name is not specified, a predefined directory is
used for the target directory, and the repository name is determined from the URL.
| Parameter | Type | Default | Description |
|---|---|---|---|
https_url | str | - | The HTTPS URL of the Git repository to be cloned. |
commit_hash | str | None | None | The commit hash to checkout after cloning. |
target_dir | str | pathlib.Path | None | None | The directory where the repository will be saved. If not provided, a predefined directory is used. |
repo_name | str | None | None | The name to be used for the cloned repository directory. If not provided, the repository’s name from the URL is used. |
force | bool | False | If True, the repository is cloned even if it already exists locally and its commit hash matches the provided commit hash. Defaults to False. |
include_to_path | bool | False | If True, the cloned repository is added to the sys.path. Defaults to False. |
Path
download_file
DownloadError if necessary.
| Parameter | Type | Default | Description |
|---|---|---|---|
url | str | - | The URL of the file to be downloaded. |
target_dir | str | pathlib.Path | - | The directory where the downloaded file will be saved. If it’s not an absolute path, it’s treated as a relative directory to “/data”. |
force | bool | False | If True, the file is downloaded even if it already exists locally and its content length matches the expected content length from the remote file. Defaults to False. |
request_headers | dict[str, str] | None | None | A dictionary containing additional headers to be included in the HTTP request. Defaults to None. |
filesize_limit | int | None | None | An integer specifying the maximum downloadable size, in megabytes. Defaults to None. |
Path
Raises:
ValueError: If the providedfile_namecontains a forward slash (’/’).DownloadError: If an error occurs during the download process.
download_model_weights
download_file function with the provided
URL and the target directory set to a pre-defined location for model weights.
The downloaded model weights are saved in this directory, and the function returns
the full path to the downloaded weights file.
| Parameter | Type | Default | Description |
|---|---|---|---|
url | str | - | The URL from which the model weights will be downloaded. |
force | bool | False | If True, the model weights are downloaded even if they already exist locally and their content length matches the expected content length from the remote file. Defaults to False. |
request_headers | dict[str, str] | None | None | A dictionary containing additional headers to be included in the HTTP request. Defaults to None. |
Path
get_gpu_type
str
load_inductor_cache
- Sets TORCHINDUCTOR_CACHE_DIR environment variable
- Looks for cached compiled kernels in GPU-specific global storage
- Unpacks the cache to local temporary directory
- Returns a hash of the unpacked directory for change detection
| Parameter | Type | Default | Description |
|---|---|---|---|
cache_key | str | - | Unique identifier for this cache (e.g., “flux/2”, “mymodel/v1”) |
str
sync_inductor_cache
- Checks if the local cache has changed (by comparing hashes)
- If changed, creates a zip archive of the new cache
- Saves it to GPU-specific global storage
| Parameter | Type | Default | Description |
|---|---|---|---|
cache_key | str | - | Unique identifier for this cache (same as used in load_inductor_cache) |
unpacked_dir_hash | str | - | Hash returned from load_inductor_cache (for change detection) |
NoneType
synchronized_inductor_cache
| Parameter | Type | Default | Description |
|---|---|---|---|
cache_key | str | - | Unique identifier for this cache (e.g., “flux/2”, “mymodel/v1”) |
Iterator[]