mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-01 20:35:06 +08:00
Added support for launching on Apple Silicon
This commit is contained in:
parent
15bb8e8057
commit
65fbefd033
@ -14,8 +14,11 @@ import modules.images
|
|||||||
|
|
||||||
def load_model(filename):
|
def load_model(filename):
|
||||||
# this code is adapted from https://github.com/xinntao/ESRGAN
|
# this code is adapted from https://github.com/xinntao/ESRGAN
|
||||||
|
if torch.has_mps:
|
||||||
pretrained_net = torch.load(filename)
|
map_l = 'cpu'
|
||||||
|
else:
|
||||||
|
map_l = None
|
||||||
|
pretrained_net = torch.load(filename, map_location=map_l)
|
||||||
crt_model = arch.RRDBNet(3, 3, 64, 23, gc=32)
|
crt_model = arch.RRDBNet(3, 3, 64, 23, gc=32)
|
||||||
|
|
||||||
if 'conv_first.weight' in pretrained_net:
|
if 'conv_first.weight' in pretrained_net:
|
||||||
|
@ -232,7 +232,10 @@ class FrozenCLIPEmbedderWithCustomWords(torch.nn.Module):
|
|||||||
z = outputs.last_hidden_state
|
z = outputs.last_hidden_state
|
||||||
|
|
||||||
# restoring original mean is likely not correct, but it seems to work well to prevent artifacts that happen otherwise
|
# restoring original mean is likely not correct, but it seems to work well to prevent artifacts that happen otherwise
|
||||||
batch_multipliers = torch.asarray(np.array(batch_multipliers)).to(device)
|
if torch.has_mps:
|
||||||
|
batch_multipliers = torch.asarray(np.array(batch_multipliers).astype('float32')).to(device)
|
||||||
|
else:
|
||||||
|
batch_multipliers = torch.asarray(np.array(batch_multipliers)).to(device)
|
||||||
original_mean = z.mean()
|
original_mean = z.mean()
|
||||||
z *= batch_multipliers.reshape(batch_multipliers.shape + (1,)).expand(z.shape)
|
z *= batch_multipliers.reshape(batch_multipliers.shape + (1,)).expand(z.shape)
|
||||||
new_mean = z.mean()
|
new_mean = z.mean()
|
||||||
|
@ -36,9 +36,12 @@ parser.add_argument("--opt-split-attention", action='store_true', help="enable o
|
|||||||
parser.add_argument("--listen", action='store_true', help="launch gradio with 0.0.0.0 as server name, allowing to respond to network requests")
|
parser.add_argument("--listen", action='store_true', help="launch gradio with 0.0.0.0 as server name, allowing to respond to network requests")
|
||||||
cmd_opts = parser.parse_args()
|
cmd_opts = parser.parse_args()
|
||||||
|
|
||||||
cpu = torch.device("cpu")
|
if torch.has_cuda:
|
||||||
gpu = torch.device("cuda")
|
device = torch.device("cuda")
|
||||||
device = gpu if torch.cuda.is_available() else cpu
|
elif torch.has_mps:
|
||||||
|
device = torch.device("mps")
|
||||||
|
else:
|
||||||
|
device = torch.device("cpu")
|
||||||
batch_cond_uncond = cmd_opts.always_batch_cond_uncond or not (cmd_opts.lowvram or cmd_opts.medvram)
|
batch_cond_uncond = cmd_opts.always_batch_cond_uncond or not (cmd_opts.lowvram or cmd_opts.medvram)
|
||||||
parallel_processing_allowed = not cmd_opts.lowvram and not cmd_opts.medvram
|
parallel_processing_allowed = not cmd_opts.lowvram and not cmd_opts.medvram
|
||||||
|
|
||||||
|
@ -10,5 +10,7 @@ omegaconf
|
|||||||
pytorch_lightning
|
pytorch_lightning
|
||||||
diffusers
|
diffusers
|
||||||
invisible-watermark
|
invisible-watermark
|
||||||
|
einops
|
||||||
|
taming-transformers-rom1504
|
||||||
git+https://github.com/crowsonkb/k-diffusion.git
|
git+https://github.com/crowsonkb/k-diffusion.git
|
||||||
git+https://github.com/TencentARC/GFPGAN.git
|
git+https://github.com/TencentARC/GFPGAN.git
|
||||||
|
Loading…
Reference in New Issue
Block a user