mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-20 05:08:00 +00:00
added stuff to diffusers
This commit is contained in:
parent
9d1f734d74
commit
8049b42091
@ -19,6 +19,16 @@ from lollms.utilities import git_pull
|
|||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
import pipmaster as pm
|
||||||
|
if not pm.is_installed("torch"):
|
||||||
|
pm.install_or_update("torch torchvision torchaudio", "https://download.pytorch.org/whl/cu121")
|
||||||
|
|
||||||
|
import torch
|
||||||
|
if not torch.cuda.is_available():
|
||||||
|
pm.install_or_update("torch torchvision torchaudio", "https://download.pytorch.org/whl/cu121")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def adjust_dimensions(value: int) -> int:
|
def adjust_dimensions(value: int) -> int:
|
||||||
"""Adjusts the given value to be divisible by 8."""
|
"""Adjusts the given value to be divisible by 8."""
|
||||||
return (value // 8) * 8
|
return (value // 8) * 8
|
||||||
@ -152,10 +162,13 @@ class LollmsDiffusers(LollmsTTI):
|
|||||||
# use_safetensors=True,
|
# use_safetensors=True,
|
||||||
# ) # app.config.diffusers_model
|
# ) # app.config.diffusers_model
|
||||||
# Enable memory optimizations.
|
# Enable memory optimizations.
|
||||||
if app.config.diffusers_offloading_mode=="sequential_cpu_offload":
|
try:
|
||||||
self.model.enable_sequential_cpu_offload()
|
if app.config.diffusers_offloading_mode=="sequential_cpu_offload":
|
||||||
elif app.coinfig.diffusers_offloading_mode=="model_cpu_offload":
|
self.model.enable_sequential_cpu_offload()
|
||||||
self.model.enable_model_cpu_offload()
|
elif app.coinfig.diffusers_offloading_mode=="model_cpu_offload":
|
||||||
|
self.model.enable_model_cpu_offload()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.model= None
|
self.model= None
|
||||||
trace_exception(ex)
|
trace_exception(ex)
|
||||||
@ -221,8 +234,8 @@ class LollmsDiffusers(LollmsTTI):
|
|||||||
sc = self.get_scheduler_by_name(sampler_name)
|
sc = self.get_scheduler_by_name(sampler_name)
|
||||||
if sc:
|
if sc:
|
||||||
self.model.scheduler = sc
|
self.model.scheduler = sc
|
||||||
width = adjust_dimensions(width)
|
width = adjust_dimensions(int(width))
|
||||||
height = adjust_dimensions(height)
|
height = adjust_dimensions(int(height))
|
||||||
if output_path is None:
|
if output_path is None:
|
||||||
output_path = self.output_dir
|
output_path = self.output_dir
|
||||||
if seed!=-1:
|
if seed!=-1:
|
||||||
|
Loading…
Reference in New Issue
Block a user