Skip to content

Commit e01706f

Browse files
Lincoln Steinhipsterusername
authored andcommitted
add fp16 support to controlnet models
1 parent 52948a1 commit e01706f

File tree

11 files changed

+342
-347
lines changed

11 files changed

+342
-347
lines changed

invokeai/backend/model_management/models/controlnet.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import os
22
import torch
33
from enum import Enum
4-
from pathlib import Path
5-
from typing import Optional, Union, Literal
4+
from typing import Optional
65
from .base import (
76
ModelBase,
87
ModelConfigBase,
@@ -14,6 +13,7 @@
1413
calc_model_size_by_data,
1514
classproperty,
1615
InvalidModelException,
16+
ModelNotFoundException,
1717
)
1818

1919
class ControlNetModelFormat(str, Enum):
@@ -60,10 +60,20 @@ def get_model(
6060
if child_type is not None:
6161
raise Exception("There is no child models in controlnet model")
6262

63-
model = self.model_class.from_pretrained(
64-
self.model_path,
65-
torch_dtype=torch_dtype,
66-
)
63+
model = None
64+
for variant in ['fp16',None]:
65+
try:
66+
model = self.model_class.from_pretrained(
67+
self.model_path,
68+
torch_dtype=torch_dtype,
69+
variant=variant,
70+
)
71+
break
72+
except:
73+
pass
74+
if not model:
75+
raise ModelNotFoundException()
76+
6777
# calc more accurate size
6878
self.model_size = calc_model_size_by_data(model)
6979
return model

invokeai/frontend/web/dist/assets/App-3986879c.js

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

invokeai/frontend/web/dist/assets/App-4c33c38e.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

invokeai/frontend/web/dist/assets/App-6125620a.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)