try improve colab (#366)

* try improve colab

* try improve colab

* try improve colab

* try improve colab

* try improve colab

* try improve colab
This commit is contained in:
lllyasviel 2023-09-13 13:30:12 -07:00 committed by GitHub
parent e32f04da34
commit 2e543fb93f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -1 +1 @@
version = '2.0.5'
version = '2.0.8'

View File

@ -32,6 +32,7 @@ def worker():
print(e)
def progressbar(number, text):
print(f'[Fooocus] {text}')
outputs.append(['preview', (number, text, None)])
@torch.no_grad()

View File

@ -28,9 +28,14 @@ def remove_pattern(x, pattern):
class FooocusExpansion:
def __init__(self):
use_fp16 = model_management.should_use_fp16()
self.tokenizer = AutoTokenizer.from_pretrained(fooocus_expansion_path)
self.model = AutoModelForCausalLM.from_pretrained(fooocus_expansion_path)
if use_fp16:
self.model.half()
load_device = model_management.text_encoder_device()
offload_device = model_management.text_encoder_offload_device()
self.patcher = ModelPatcher(self.model, load_device=load_device, offload_device=offload_device)
@ -39,7 +44,7 @@ class FooocusExpansion:
model=self.model,
tokenizer=self.tokenizer,
device='cpu',
torch_dtype=torch.float32)
torch_dtype=torch.float16 if use_fp16 else torch.float32)
print(f'Fooocus Expansion engine loaded.')