chore: rename model.size to model.file_size

to disambiguate from RAM size or pixel size
This commit is contained in:
Kevin Turner
2025-04-05 15:05:00 -07:00
committed by psychedelicious
parent e537020c11
commit 52a8ad1c18
12 changed files with 85 additions and 85 deletions

View File

@@ -85,7 +85,7 @@ example_model_config = {
"config_path": "string",
"key": "string",
"hash": "string",
"size": 1,
"file_size": 1,
"description": "string",
"source": "string",
"converted_at": 0,

View File

@@ -80,7 +80,7 @@ class ModelRecordChanges(BaseModelExcludeNull):
type: Optional[ModelType] = Field(description="Type of model", default=None)
key: Optional[str] = Field(description="Database ID for this model", default=None)
hash: Optional[str] = Field(description="hash of model file", default=None)
size: Optional[int] = Field(description="Size of model file", default=None)
file_size: Optional[int] = Field(description="Size of model file", default=None)
format: Optional[str] = Field(description="format of model file", default=None)
trigger_phrases: Optional[set[str]] = Field(description="Set of trigger phrases for this model", default=None)
default_settings: Optional[MainModelDefaultSettings | ControlAdapterDefaultSettings] = Field(

View File

@@ -15,8 +15,8 @@ class Migration19Callback:
def _add_size_column(self, cursor: sqlite3.Cursor) -> None:
cursor.execute(
"ALTER TABLE models ADD COLUMN size INTEGER "
"GENERATED ALWAYS as (json_extract(config, '$.size')) VIRTUAL NOT NULL"
"ALTER TABLE models ADD COLUMN file_size INTEGER "
"GENERATED ALWAYS as (json_extract(config, '$.file_size')) VIRTUAL NOT NULL"
)
def _populate_size(self, cursor: sqlite3.Cursor) -> None:
@@ -25,7 +25,7 @@ class Migration19Callback:
for model_id, model_path in all_models:
mod = ModelOnDisk(self.models_path / model_path)
cursor.execute(
"UPDATE models SET config = json_set(config, '$.size', ?) WHERE id = ?", (mod.size(), model_id)
"UPDATE models SET config = json_set(config, '$.file_size', ?) WHERE id = ?", (mod.size(), model_id)
)

View File

@@ -128,7 +128,7 @@ class ModelConfigBase(ABC, BaseModel):
path: str = Field(
description="Path to the model on the filesystem. Relative paths are relative to the Invoke root directory."
)
size: int = Field(description="The size of the model in bytes.")
file_size: int = Field(description="The size of the model in bytes.")
name: str = Field(description="Name of the model.")
type: ModelType = Field(description="Model type")
format: ModelFormat = Field(description="Model format")
@@ -242,7 +242,7 @@ class ModelConfigBase(ABC, BaseModel):
fields["key"] = fields.get("key") or uuid_string()
fields["description"] = fields.get("description") or f"{base.value} {type.value} model {name}"
fields["repo_variant"] = fields.get("repo_variant") or mod.repo_variant()
fields["size"] = fields.get("size") or mod.size()
fields["file_size"] = fields.get("file_size") or mod.size()
return cls(**fields)

View File

@@ -208,7 +208,7 @@ class ModelProbe(object):
)
fields["format"] = ModelFormat(fields.get("format")) if "format" in fields else probe.get_format()
fields["hash"] = fields.get("hash") or ModelHash(algorithm=hash_algo).hash(model_path)
fields["size"] = fields.get("size") or ModelOnDisk(model_path).size()
fields["file_size"] = fields.get("file_size") or ModelOnDisk(model_path).size()
fields["default_settings"] = fields.get("default_settings")

View File

@@ -767,6 +767,7 @@
"deleteMsg2": "This WILL delete the model from disk if it is in the InvokeAI root folder. If you are using a custom location, then the model WILL NOT be deleted from disk.",
"description": "Description",
"edit": "Edit",
"fileSize": "File Size",
"fluxRedux": "FLUX Redux",
"height": "Height",
"huggingFace": "HuggingFace",
@@ -841,7 +842,6 @@
"selectModel": "Select Model",
"settings": "Settings",
"simpleModelPlaceholder": "URL or path to a local file or diffusers folder",
"size": "Size",
"source": "Source",
"sigLip": "SigLIP",
"spandrelImageToImage": "Image to Image (Spandrel)",

View File

@@ -109,7 +109,7 @@ const ModelListItem = ({ model }: ModelListItemProps) => {
<ModelFormatBadge format={model.format} />
</Flex>
<Text>
{(model.size / 1024 ** 3).toLocaleString(undefined, {
{(model.file_size / 1024 ** 3).toLocaleString(undefined, {
maximumFractionDigits: 2,
style: 'unit',
unit: 'gigabyte',

View File

@@ -51,8 +51,8 @@ export const ModelView = memo(({ modelConfig }: Props) => {
<ModelAttrView label={t('common.format')} value={modelConfig.format} />
<ModelAttrView label={t('modelManager.path')} value={modelConfig.path} />
<ModelAttrView
label={t('modelManager.size')}
value={(modelConfig.size / 1024 ** 3).toLocaleString(undefined, {
label={t('modelManager.fileSize')}
value={(modelConfig.file_size / 1024 ** 3).toLocaleString(undefined, {
maximumFractionDigits: 2,
style: 'unit',
unit: 'gigabyte',

View File

@@ -627,7 +627,7 @@ describe('Graph', () => {
key: 'b00ee8df-523d-40d2-9578-597283b07cb2',
hash: 'random:9adf270422f525715297afa1649c4ff007a55f09937f57ca628278305624d194',
path: 'sdxl/main/stable-diffusion-xl-1.0-inpainting-0.1',
size: 6123456789,
file_size: 6123456789,
name: 'stable-diffusion-xl-1.0-inpainting-0.1',
base: 'sdxl',
description: 'sdxl main model stable-diffusion-xl-1.0-inpainting-0.1',

View File

@@ -2914,10 +2914,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -2996,10 +2996,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -3154,10 +3154,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -4316,10 +4316,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -4409,10 +4409,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -4490,10 +4490,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -4577,10 +4577,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -7772,10 +7772,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -8552,10 +8552,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -8745,10 +8745,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -12817,10 +12817,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -12987,10 +12987,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -13153,10 +13153,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -13424,10 +13424,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -13527,10 +13527,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -13631,10 +13631,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -13719,10 +13719,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -15848,10 +15848,10 @@ export type components = {
*/
hash?: string | null;
/**
* Size
* File Size
* @description Size of model file
*/
size?: number | null;
file_size?: number | null;
/**
* Format
* @description format of model file
@@ -18580,10 +18580,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -18724,10 +18724,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -19446,10 +19446,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -19669,10 +19669,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -19740,10 +19740,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -19848,10 +19848,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -19922,10 +19922,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -20446,10 +20446,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.
@@ -20531,10 +20531,10 @@ export type components = {
*/
path: string;
/**
* Size
* File Size
* @description The size of the model in bytes.
*/
size: number;
file_size: number;
/**
* Name
* @description Name of the model.

View File

@@ -45,7 +45,7 @@ def example_ti_config(key: Optional[str] = None) -> TextualInversionFileConfig:
source="test/source/",
source_type=ModelSourceType.Path,
path="/tmp/pokemon.bin",
size=1024,
file_size=1024,
name="old name",
base=BaseModelType.StableDiffusion1,
type=ModelType.TextualInversion,
@@ -129,7 +129,7 @@ def test_filter(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG1HASH",
size=1001,
file_size=1001,
source="test/source",
source_type=ModelSourceType.Path,
)
@@ -140,7 +140,7 @@ def test_filter(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG2HASH",
size=1002,
file_size=1002,
source="test/source",
source_type=ModelSourceType.Path,
)
@@ -151,7 +151,7 @@ def test_filter(store: ModelRecordServiceBase):
base=BaseModelType("sd-2"),
type=ModelType.VAE,
hash="CONFIG3HASH",
size=1003,
file_size=1003,
source="test/source",
source_type=ModelSourceType.Path,
)
@@ -182,7 +182,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.Main,
name="nonuniquename",
hash="CONFIG1HASH",
size=1004,
file_size=1004,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -192,7 +192,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.Main,
name="nonuniquename",
hash="CONFIG1HASH",
size=1005,
file_size=1005,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -202,7 +202,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.VAE,
name="nonuniquename",
hash="CONFIG1HASH",
size=1006,
file_size=1006,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -212,7 +212,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.Main,
name="nonuniquename",
hash="CONFIG1HASH",
size=1007,
file_size=1007,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -235,7 +235,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG1HASH",
size=1008,
file_size=1008,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -245,7 +245,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG2HASH",
size=1009,
file_size=1009,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -255,7 +255,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType("sd-2"),
type=ModelType.Main,
hash="CONFIG3HASH",
size=1010,
file_size=1010,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -265,7 +265,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType("sdxl"),
type=ModelType.Main,
hash="CONFIG3HASH",
size=1011,
file_size=1011,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -275,7 +275,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.VAE,
hash="CONFIG3HASH",
size=1012,
file_size=1012,
source="test/source/",
source_type=ModelSourceType.Path,
)

View File

@@ -140,7 +140,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusion2,
type=ModelType.VAE,
hash="111222333444",
size=4096,
file_size=4096,
source="stabilityai/sdxl-vae",
source_type=ModelSourceType.HFRepoID,
)
@@ -154,7 +154,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
config_path="/tmp/foo.yaml",
variant=ModelVariantType.Normal,
hash="111222333444",
size=8192,
file_size=8192,
source="https://civitai.com/models/206883/split",
source_type=ModelSourceType.Url,
)
@@ -166,7 +166,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusionXL,
type=ModelType.Main,
hash="111222333444",
size=8193,
file_size=8193,
source="author3/model3",
description="This is test 3",
source_type=ModelSourceType.HFRepoID,
@@ -179,7 +179,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusionXL,
type=ModelType.LoRA,
hash="111222333444",
size=5000,
file_size=5000,
source="author4/model4",
source_type=ModelSourceType.HFRepoID,
)
@@ -191,7 +191,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusion1,
type=ModelType.LoRA,
hash="111222333444",
size=5001,
file_size=5001,
source="author4/model5",
source_type=ModelSourceType.HFRepoID,
)