stable-diffusion-videos
stable-diffusion-videos copied to clipboard
Support for M1 macs MPS api
Feature request
Add support for the M1 chip, since the current macs do not have a Nvidia CUDA GPU.
Useful Resource
Pull request for stable-diffusion M1 support https://github.com/lstein/stable-diffusion/pull/268/files#diff-fde39b496af1173c473e9bccb3ccf07a148c1b050a15f659d5241252268bbb1d
I will do a pull request to fix it
I was trying to run gradio via jupyter on my Mac M1 but think I'm hitting the same issue.
from stable_diffusion_videos import interface
interface.launch()
I am getting an AssertionError: Torch not compiled with CUDA enabled. I assume there's currently no fallback option?
AssertionError Traceback (most recent call last)
Cell In [2], line 1
----> 1 from stable_diffusion_videos import interface
3 interface.launch()
File <frozen importlib._bootstrap>:1075, in _handle_fromlist(module, fromlist, import_, recursive)
File ~/env/lib/python3.10/site-packages/stable_diffusion_videos/__init__.py:73, in _attach.<locals>.__getattr__(name)
71 elif name in attr_to_modules:
72 submod_path = f"{package_name}.{attr_to_modules[name]}"
---> 73 submod = importlib.import_module(submod_path)
74 attr = getattr(submod, name)
76 # If the attribute lives in a file (module) with the same
77 # name as the attribute, ensure that the attribute and *not*
78 # the module is accessible on the package.
File ~/env/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File ~/env/lib/python3.10/site-packages/stable_diffusion_videos/app.py:14
6 from .stable_diffusion_pipeline import StableDiffusionWalkPipeline
7 from .upsampling import RealESRGANModel
9 pipeline = StableDiffusionWalkPipeline.from_pretrained(
10 "CompVis/stable-diffusion-v1-4",
11 use_auth_token=True,
12 torch_dtype=torch.float16,
13 revision="fp16",
---> 14 ).to("cuda")
17 def fn_images(
18 prompt,
19 seed,
(...)
22 upsample,
23 ):
24 if upsample:
File ~/env/lib/python3.10/site-packages/diffusers/pipeline_utils.py:177, in DiffusionPipeline.to(self, torch_device)
171 if module.dtype == torch.float16 and str(torch_device) in ["cpu", "mps"]:
172 raise ValueError(
173 "Pipelines loaded with `torch_dtype=torch.float16` cannot be moved to `cpu` or `mps` "
174 "due to the lack of support for `float16` operations on those devices in PyTorch. "
175 "Please remove the `torch_dtype=torch.float16` argument, or use a `cuda` device."
176 )
--> 177 module.to(torch_device)
178 return self
File ~/env/lib/python3.10/site-packages/torch/nn/modules/module.py:987, in Module.to(self, *args, **kwargs)
983 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None,
984 non_blocking, memory_format=convert_to_format)
985 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
--> 987 return self._apply(convert)
File ~/env/lib/python3.10/site-packages/torch/nn/modules/module.py:639, in Module._apply(self, fn)
637 def _apply(self, fn):
638 for module in self.children():
--> 639 module._apply(fn)
641 def compute_should_use_set_data(tensor, tensor_applied):
642 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied):
643 # If the new tensor has compatible tensor type as the existing tensor,
644 # the current behavior is to change the tensor in-place using `.data =`,
(...)
649 # global flag to let the user control whether they want the future
650 # behavior of overwriting the existing tensor or not.
File ~/env/lib/python3.10/site-packages/torch/nn/modules/module.py:662, in Module._apply(self, fn)
658 # Tensors stored in modules are graph leaves, and we don't want to
659 # track autograd history of `param_applied`, so we have to use
660 # `with torch.no_grad():`
661 with torch.no_grad():
--> 662 param_applied = fn(param)
663 should_use_set_data = compute_should_use_set_data(param, param_applied)
664 if should_use_set_data:
File ~/env/lib/python3.10/site-packages/torch/nn/modules/module.py:985, in Module.to.<locals>.convert(t)
982 if convert_to_format is not None and t.dim() in (4, 5):
983 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None,
984 non_blocking, memory_format=convert_to_format)
--> 985 return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
File ~/env/lib/python3.10/site-packages/torch/cuda/__init__.py:221, in _lazy_init()
217 raise RuntimeError(
218 "Cannot re-initialize CUDA in forked subprocess. To use CUDA with "
219 "multiprocessing, you must use the 'spawn' start method")
220 if not hasattr(torch._C, '_cuda_getDeviceCount'):
--> 221 raise AssertionError("Torch not compiled with CUDA enabled")
222 if _cudart is None:
223 raise AssertionError(
224 "libcudart functions unavailable. It looks like you have a broken build?")
AssertionError: Torch not compiled with CUDA enabled
You can checkout this branch of the PR (shame on me / i have not integrated the feedback yet). https://github.com/nateraw/stable-diffusion-videos/pull/39
I used the environment defined by INSTALL_MAC.md and in environment-mac.yaml.
thanks for sharing that. so, I didn't end up creating a new env because I already have the fallback set in my current one (for another variant of SD) and assume there are a number of dependencies. if I can't figure this out I might just try creating a new env. I just checked out your changes and updated these files with your commits
- stable_diffusion_pipeline.py
- stable_diffusion_walk.py
- app.py
- devices.py
Then I ran this again in jupyter
from stable_diffusion_videos import interface
interface.launch()
Now, I am getting these errors
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In [25], line 1
----> 1 from stable_diffusion_videos import interface
3 interface.launch()
File ~/env/lib/python3.10/site-packages/stable_diffusion_videos/__init__.py:73, in _attach.<locals>.__getattr__(name)
71 elif name in attr_to_modules:
72 submod_path = f"{package_name}.{attr_to_modules[name]}"
---> 73 submod = importlib.import_module(submod_path)
74 attr = getattr(submod, name)
76 # If the attribute lives in a file (module) with the same
77 # name as the attribute, ensure that the attribute and *not*
78 # the module is accessible on the package.
File ~/env/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File ~/env/lib/python3.10/site-packages/stable_diffusion_videos/app.py:6
3 import gradio as gr
4 import torch
----> 6 from .stable_diffusion_walk import SCHEDULERS, pipeline, walk
7 from .devices import choose_torch_device
10 def fn_images(
11 prompt,
12 seed,
(...)
17 upsample,
18 ):
File ~/env/lib/python3.10/site-packages/stable_diffusion_videos/stable_diffusion_walk.py:12
9 from diffusers import ModelMixin
10 from contextlib import nullcontext
---> 12 from .stable_diffusion_pipeline import StableDiffusionPipeline
13 from .devices import choose_torch_device
16 device = choose_torch_device()
ImportError: cannot import name 'StableDiffusionPipeline' from 'stable_diffusion_videos.stable_diffusion_pipeline' (/Users/somehuman/env/lib/python3.10/site-packages/stable_diffusion_videos/stable_diffusion_pipeline.py)
Actually, I restarted the jupyter kernel and now I can run the gradio UX. Thanks for your patches!
Unfortunately, during runtime there were a series of new errors which seem related to something totally different.
Traceback (most recent call last):
File "/Users/somehuman/env/lib/python3.10/site-packages/gradio/routes.py", line 275, in run_predict
output = await app.blocks.process_api(
File "/Users/somehuman/env/lib/python3.10/site-packages/gradio/blocks.py", line 785, in process_api
result = await self.call_function(fn_index, inputs, iterator)
File "/Users/somehuman/env/lib/python3.10/site-packages/gradio/blocks.py", line 694, in call_function
prediction = await anyio.to_thread.run_sync(
File "/Users/somehuman/env/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/Users/somehuman/env/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/Users/somehuman/env/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/Users/somehuman/env/lib/python3.10/site-packages/stable_diffusion_videos/app.py", line 35, in fn_images
img = pipeline(
File "/Users/somehuman/env/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/Users/somehuman/env/lib/python3.10/site-packages/stable_diffusion_videos/stable_diffusion_pipeline.py", line 201, in __call__
noise_pred = self.unet(
File "/Users/somehuman/env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/Users/somehuman/env/lib/python3.10/site-packages/diffusers/models/unet_2d_condition.py", line 263, in forward
timesteps = timesteps[None].to(sample.device)
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
I am running the latest nightlies
- torch 1.13.0.dev20220922
- torchvision 0.14.0.dev20220924
Per this comment the offending line appears to be in unet_2d_condition.py. I can confirm this fixed my runtime issues and I am now able to render images and videos.
The current code is: timesteps = timesteps[None].to(sample.device)
Changing that to the following stops the crash: timesteps = timesteps[None].long().to(sample.device)
Hey there, the latest version of the code is using diffusers==0.5.1 and might support mps, but I have no way of checking. If anybody wants to install this repo from main and give it a try, let me know!
pip install git+https://github.com/nateraw/stable-diffusion-videos
Can then follow instructions from here to initialize the pipeline for mps.
Hey folks, I think M1 may be supported on latest PyPi version now. Can any of you verify if this works?
pip install --upgrade stable-diffusion-videos[realesrgan]
from stable_diffusion_videos import StableDiffusionWalkPipeline
pipeline = StableDiffusionWalkPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipeline = pipeline.to('mps')
video_path = pipeline.walk(
['a cat', 'a dog'],
[42, 1337],
fps=5, # use 5 for testing, 25 or 30 for better quality
num_interpolation_steps=5, # use 3-5 for testing, 30 or more for better results
height=512, # use multiples of 64 if > 512. Multiples of 8 if < 512.
width=512, # use multiples of 64 if > 512. Multiples of 8 if < 512.
)
Running this worked for me
%pip install --upgrade stable-diffusion-videos
However, running this did not work for me
% pip install --upgrade stable-diffusion-videos[realesrgan]
zsh: no matches found: stable-diffusion-videos[realesrgan]
When I ran this…
from stable_diffusion_videos import StableDiffusionWalkPipeline
pipeline = StableDiffusionWalkPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipeline = pipeline.to('mps')
video_path = pipeline.walk(
['a cat', 'a dog'],
[42, 1337],
fps=5, # use 5 for testing, 25 or 30 for better quality
num_interpolation_steps=5, # use 3-5 for testing, 30 or more for better results
height=512, # use multiples of 64 if > 512. Multiples of 8 if < 512.
width=512, # use multiples of 64 if > 512. Multiples of 8 if < 512.
)
I got the following output
/Users/somehuman/env/lib/python3.10/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: dlopen(/Users/somehuman/env/lib/python3.10/site-packages/torchvision/image.so, 0x0006): Symbol not found: (__ZN2at4_ops19empty_memory_format4callEN3c108ArrayRefIxEENS2_8optionalINS2_10ScalarTypeEEENS5_INS2_6LayoutEEENS5_INS2_6DeviceEEENS5_IbEENS5_INS2_12MemoryFormatEEE)
Referenced from: '/Users/somehuman/env/lib/python3.10/site-packages/torchvision/image.so'
Expected in: '/Users/somehuman/env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.dylib'
warn(f"Failed to load image Python extension: {e}")
Fetching 16 files: 100%
16/16 [00:00<00:00, 656.36it/s]
/Users/somehuman/env/lib/python3.10/site-packages/torch/amp/autocast_mode.py:202: UserWarning: User provided device_type of 'cuda', but CUDA is not available. Disabling
warnings.warn('User provided device_type of \'cuda\', but CUDA is not available. Disabling')
/Users/somehuman/env/lib/python3.10/site-packages/stable_diffusion_videos/stable_diffusion_pipeline.py:513: UserWarning: The operator 'aten::lerp.Scalar_out' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/mps/MPSFallback.mm:11.)
embeds = torch.lerp(embeds_a, embeds_b, t)
100%
51/51 [00:52<00:00, 1.07it/s]
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.
100%
51/51 [00:48<00:00, 1.02it/s]
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.
100%
51/51 [00:48<00:00, 1.06it/s]
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.
100%
51/51 [00:48<00:00, 1.07it/s]
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.
100%
51/51 [00:47<00:00, 1.06it/s]
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.
Also, now if I try to run this (which did work before) it no longer works (I also tried by reapplying the patches from https://github.com/nateraw/stable-diffusion-videos/issues/38#issuecomment-1272288022 and got the same error)
from stable_diffusion_videos import interface
interface.launch()
I get this error
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In [3], line 1
----> 1 from stable_diffusion_videos import interface
2 interface.launch()
ImportError: cannot import name 'interface' from 'stable_diffusion_videos' (/Users/somehuman/env/lib/python3.10/site-packages/stable_diffusion_videos/__init__.py)
btw I already had realesrgan installed
% pip install realesrgan
Requirement already satisfied: realesrgan in ./env/lib/python3.10/site-packages (0.3.0)
Requirement already satisfied: opencv-python in ./env/lib/python3.10/site-packages (from realesrgan) (4.5.5)
Requirement already satisfied: gfpgan>=1.3.5 in ./env/lib/python3.10/site-packages (from realesrgan) (1.3.8)
Requirement already satisfied: facexlib>=0.2.5 in ./env/lib/python3.10/site-packages (from realesrgan) (0.2.5)
Requirement already satisfied: numpy in ./env/lib/python3.10/site-packages (from realesrgan) (1.23.2)
Requirement already satisfied: Pillow in ./env/lib/python3.10/site-packages (from realesrgan) (9.2.0)
Requirement already satisfied: torch>=1.7 in ./env/lib/python3.10/site-packages (from realesrgan) (1.13.0.dev20220924)
Requirement already satisfied: tqdm in ./env/lib/python3.10/site-packages (from realesrgan) (4.64.1)
Requirement already satisfied: basicsr>=1.4.2 in ./env/lib/python3.10/site-packages (from realesrgan) (1.4.2)
Requirement already satisfied: torchvision in ./env/lib/python3.10/site-packages (from realesrgan) (0.13.1)
Requirement already satisfied: scikit-image in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (0.19.3)
Requirement already satisfied: requests in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (2.25.1)
Requirement already satisfied: pyyaml in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (6.0)
Requirement already satisfied: scipy in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (1.9.1)
Requirement already satisfied: tb-nightly in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (2.11.0a20221007)
Requirement already satisfied: future in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (0.18.2)
Requirement already satisfied: lmdb in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (1.3.0)
Requirement already satisfied: yapf in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (0.32.0)
Requirement already satisfied: addict in ./env/lib/python3.10/site-packages (from basicsr>=1.4.2->realesrgan) (2.4.0)
Requirement already satisfied: numba in ./env/lib/python3.10/site-packages (from facexlib>=0.2.5->realesrgan) (0.56.2)
Requirement already satisfied: filterpy in ./env/lib/python3.10/site-packages (from facexlib>=0.2.5->realesrgan) (1.4.5)
Requirement already satisfied: typing-extensions in ./env/lib/python3.10/site-packages (from torch>=1.7->realesrgan) (4.4.0)
Requirement already satisfied: matplotlib in ./env/lib/python3.10/site-packages (from filterpy->facexlib>=0.2.5->realesrgan) (3.6.0)
Requirement already satisfied: llvmlite<0.40,>=0.39.0dev0 in ./env/lib/python3.10/site-packages (from numba->facexlib>=0.2.5->realesrgan) (0.39.1)
Requirement already satisfied: setuptools<60 in ./env/lib/python3.10/site-packages (from numba->facexlib>=0.2.5->realesrgan) (59.8.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./env/lib/python3.10/site-packages (from requests->basicsr>=1.4.2->realesrgan) (1.26.12)
Requirement already satisfied: certifi>=2017.4.17 in ./env/lib/python3.10/site-packages (from requests->basicsr>=1.4.2->realesrgan) (2022.9.24)
Requirement already satisfied: idna<3,>=2.5 in ./env/lib/python3.10/site-packages (from requests->basicsr>=1.4.2->realesrgan) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in ./env/lib/python3.10/site-packages (from requests->basicsr>=1.4.2->realesrgan) (4.0.0)
Requirement already satisfied: imageio>=2.4.1 in ./env/lib/python3.10/site-packages (from scikit-image->basicsr>=1.4.2->realesrgan) (2.22.1)
Requirement already satisfied: packaging>=20.0 in ./env/lib/python3.10/site-packages (from scikit-image->basicsr>=1.4.2->realesrgan) (21.3)
Requirement already satisfied: networkx>=2.2 in ./env/lib/python3.10/site-packages (from scikit-image->basicsr>=1.4.2->realesrgan) (2.8.7)
Requirement already satisfied: PyWavelets>=1.1.1 in ./env/lib/python3.10/site-packages (from scikit-image->basicsr>=1.4.2->realesrgan) (1.4.1)
Requirement already satisfied: tifffile>=2019.7.26 in ./env/lib/python3.10/site-packages (from scikit-image->basicsr>=1.4.2->realesrgan) (2022.8.12)
Requirement already satisfied: grpcio>=1.24.3 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (1.46.3)
Requirement already satisfied: google-auth<3,>=1.6.3 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (2.12.0)
Requirement already satisfied: markdown>=2.6.8 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (3.4.1)
Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (0.6.1)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (0.4.6)
Requirement already satisfied: protobuf<4,>=3.9.2 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (3.19.4)
Requirement already satisfied: absl-py>=0.4 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (1.2.0)
Requirement already satisfied: wheel>=0.26 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (0.37.1)
Requirement already satisfied: werkzeug>=1.0.1 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (2.2.2)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in ./env/lib/python3.10/site-packages (from tb-nightly->basicsr>=1.4.2->realesrgan) (1.8.1)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in ./env/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tb-nightly->basicsr>=1.4.2->realesrgan) (5.2.0)
Requirement already satisfied: six>=1.9.0 in ./env/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tb-nightly->basicsr>=1.4.2->realesrgan) (1.16.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in ./env/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tb-nightly->basicsr>=1.4.2->realesrgan) (0.2.8)
Requirement already satisfied: rsa<5,>=3.1.4 in ./env/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tb-nightly->basicsr>=1.4.2->realesrgan) (4.9)
Requirement already satisfied: requests-oauthlib>=0.7.0 in ./env/lib/python3.10/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tb-nightly->basicsr>=1.4.2->realesrgan) (1.3.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./env/lib/python3.10/site-packages (from packaging>=20.0->scikit-image->basicsr>=1.4.2->realesrgan) (3.0.9)
Requirement already satisfied: MarkupSafe>=2.1.1 in ./env/lib/python3.10/site-packages (from werkzeug>=1.0.1->tb-nightly->basicsr>=1.4.2->realesrgan) (2.1.1)
Requirement already satisfied: contourpy>=1.0.1 in ./env/lib/python3.10/site-packages (from matplotlib->filterpy->facexlib>=0.2.5->realesrgan) (1.0.5)
Requirement already satisfied: fonttools>=4.22.0 in ./env/lib/python3.10/site-packages (from matplotlib->filterpy->facexlib>=0.2.5->realesrgan) (4.37.4)
Requirement already satisfied: cycler>=0.10 in ./env/lib/python3.10/site-packages (from matplotlib->filterpy->facexlib>=0.2.5->realesrgan) (0.11.0)
Requirement already satisfied: python-dateutil>=2.7 in ./env/lib/python3.10/site-packages (from matplotlib->filterpy->facexlib>=0.2.5->realesrgan) (2.8.2)
Requirement already satisfied: kiwisolver>=1.0.1 in ./env/lib/python3.10/site-packages (from matplotlib->filterpy->facexlib>=0.2.5->realesrgan) (1.4.4)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in ./env/lib/python3.10/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tb-nightly->basicsr>=1.4.2->realesrgan) (0.4.8)
Requirement already satisfied: oauthlib>=3.0.0 in ./env/lib/python3.10/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tb-nightly->basicsr>=1.4.2->realesrgan) (3.2.1)
I turned the interface into a wrapper.
from stable_diffusion_videos import Interface
interface = Interface(pipeline)
interface.launch()
hmm...I gave this a try
from stable_diffusion_videos import Interface
interface = Interface(pipeline)
interface.launch()
still getting errors, any ideas?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In [6], line 1
----> 1 from stable_diffusion_videos import Interface
3 interface = Interface(pipeline)
4 interface.launch()
ImportError: cannot import name 'Interface' from 'stable_diffusion_videos' (/Users/somehuman/env/lib/python3.10/site-packages/stable_diffusion_videos/__init__.py)
this is what's in init.py
# ***********
# vendored from https://github.com/scientific-python/lazy_loader
import importlib
import importlib.util
import inspect
import os
import sys
import types
import warnings
class _LazyImportWarning(Warning):
pass
def _attach(package_name, submodules=None, submod_attrs=None):
"""Attach lazily loaded submodules, functions, or other attributes.
Typically, modules import submodules and attributes as follows:
```py
import mysubmodule
import anothersubmodule
from .foo import someattr
```
The idea is to replace a package's `__getattr__`, `__dir__`, and
`__all__`, such that all imports work exactly the way they would
with normal imports, except that the import occurs upon first use.
The typical way to call this function, replacing the above imports, is:
```python
__getattr__, __dir__, __all__ = lazy.attach(
__name__,
['mysubmodule', 'anothersubmodule'],
{'foo': ['someattr']}
)
```
This functionality requires Python 3.7 or higher.
Args:
package_name (`str`):
Typically use `__name__`.
submodules (`set`):
List of submodules to attach.
submod_attrs (`dict`):
Dictionary of submodule -> list of attributes / functions.
These attributes are imported as they are used.
Returns:
__getattr__, __dir__, __all__
"""
if submod_attrs is None:
submod_attrs = {}
if submodules is None:
submodules = set()
else:
submodules = set(submodules)
attr_to_modules = {attr: mod for mod, attrs in submod_attrs.items() for attr in attrs}
__all__ = list(submodules | attr_to_modules.keys())
def __getattr__(name):
if name in submodules:
return importlib.import_module(f"{package_name}.{name}")
elif name in attr_to_modules:
submod_path = f"{package_name}.{attr_to_modules[name]}"
submod = importlib.import_module(submod_path)
attr = getattr(submod, name)
# If the attribute lives in a file (module) with the same
# name as the attribute, ensure that the attribute and *not*
# the module is accessible on the package.
if name == attr_to_modules[name]:
pkg = sys.modules[package_name]
pkg.__dict__[name] = attr
return attr
else:
raise AttributeError(f"No {package_name} attribute {name}")
def __dir__():
return __all__
if os.environ.get("EAGER_IMPORT", ""):
for attr in set(attr_to_modules.keys()) | submodules:
__getattr__(attr)
return __getattr__, __dir__, list(__all__)
__getattr__, __dir__, __all__ = _attach(
__name__,
submodules=[],
submod_attrs={
"app": [
"Interface",
],
"image_generation": [
"generate_images",
"upload_folder_chunked",
],
"stable_diffusion_pipeline": [
"StableDiffusionWalkPipeline",
"make_video_pyav",
"get_timesteps_arr",
],
"upsampling": ["RealESRGANModel"],
},
)
__version__ = "0.6.0"
weird that import should be working just fine...not sure what's going on there. Can't reproduce in Colab
Believe this issue is resolved. Closing for now