Error loading script: No module named 'timm.models.beit'
I used the script a few days ago on colab pro with no problem. Today I can't get it to work.
Maybe it has something to do with this Midas update yesterday?
They added this file which references the now missing module as a dependency.
Thats at least as far as I got. Might be completely off.
Here is the full error message:
Error loading script: depthmap_for_depth2img.py
Traceback (most recent call last):
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/scripts.py", line 195, in load_scripts
module = script_loading.load_module(scriptfile.path)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/script_loading.py", line 13, in load_module
exec(compiled, module.__dict__)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/depthmap2mask/scripts/depthmap_for_depth2img.py", line 11, in <module>
from repositories.midas.midas.dpt_depth import DPTDepthModel
File "/content/gdrive/MyDrive/sd/stablediffusion/repositories/midas/midas/dpt_depth.py", line 5, in <module>
from .blocks import (
File "/content/gdrive/MyDrive/sd/stablediffusion/repositories/midas/midas/blocks.py", line 4, in <module>
from .backbones.beit import (
File "/content/gdrive/MyDrive/sd/stablediffusion/repositories/midas/midas/backbones/beit.py", line 9, in <module>
from timm.models.beit import gen_relative_position_index
ModuleNotFoundError: No module named 'timm.models.beit'
Thanks for the awesome script btw! :D
install timm version 0.6.12 !pip install timm==0.6.12. this extension works with the latest version, SD webui uses a old version.
pip install timm==0.6.12
I've tried "pip install timm" without mentioning a specific version, but from inside the Midas file, it still does not detect the timm module.
then the way I solved it was to manually clone the midas and checkout into before Midas v3.1.
cd stable-diffusion-webui/repositories && git clone https://github.com/isl-org/MiDaS midas && cd midas && git checkout b845b78 .
Then just install depthmap2mask from webui extensioms menu or git clone it into extensions folder
then the way I solved it was to manually clone the midas and checkout into before Midas v3.1.
that did it for me. thanks
pip install timm==0.6.12
I've tried "pip install timm" without mentioning a specific version, but from inside the Midas file, it still does not detect the timm module.
then the way I solved it was to manually clone the midas and checkout into before Midas v3.1.
cd stable-diffusion-webui/repositories && git clone https://github.com/isl-org/MiDaS midas && cd midas && git checkout b845b78.Then just install depthmap2mask from webui extensioms menu or git clone it into extensions folder
Ive tried doing this but still get the error, could you explain a bit more for a novice like me?
%cd stable-diffusion-webui/repositories
!git clone https://github.com/isl-org/MiDaS midas
%cd midas
!git checkout b845b78
I did this straight after installing requirements.
%cd stable-diffusion-webui/repositories !git clone https://github.com/isl-org/MiDaS midas %cd midas !git checkout b845b78
Strange... but that should work. Consider removing the Midas folder and retry.
%cd stable-diffusion-webui/repositories !git clone https://github.com/isl-org/MiDaS midas %cd midas !git checkout b845b78
Strange... but that should work. Consider removing the Midas folder and retry.
Not a clue to be honest its beyond my expertise! Is the idea to run everything from within the MIDAS folder? I changed up directory to launch and still get no module found, despite installing timm to start with. I think I will have to wait for a general fix as I probably have a different setup to you. Im going to try and move the sd web ui folder into midas and see if that works..out of ideas otherwise.
Launching Web UI with arguments: --share --theme=dark --listen --gradio-debug --xformers --gradio-img2img-tool color-sketch --gradio-inpaint-tool color-sketch --enable-insecure-extension-access
Error loading script: depthmap_for_depth2img.py
Traceback (most recent call last):
File "/content/stable-diffusion-webui/modules/scripts.py", line 195, in load_scripts
module = script_loading.load_module(scriptfile.path)
File "/content/stable-diffusion-webui/modules/script_loading.py", line 13, in load_module
exec(compiled, module.__dict__)
File "/content/stable-diffusion-webui/extensions/depthmap2mask/scripts/depthmap_for_depth2img.py", line 11, in <module>
from repositories.midas.midas.dpt_depth import DPTDepthModel
File "/content/stable-diffusion-webui/repositories/midas/midas/dpt_depth.py", line 5, in <module>
from .blocks import (
File "/content/stable-diffusion-webui/repositories/midas/midas/blocks.py", line 4, in <module>
from .backbones.beit import (
File "/content/stable-diffusion-webui/repositories/midas/midas/backbones/beit.py", line 9, in <module>
from timm.models.beit import gen_relative_position_index
ModuleNotFoundError: No module named 'timm.models.beit'
It works! I understand how hard it is when not being used to this. Do this instead for a manual fix: Go to this link, click the green button labeled "Code", download the zip, go to your stable diffusion webui directory then go to repositories/Midas folder and unzip the contents in that folder. It will overwrite some of the contents, allow it and you are good to go! https://github.com/isl-org/MiDaS/tree/b845b7839c89567c123b06dddfff8d5e708834b7
This PR fixes the issue https://github.com/Extraltodeus/depthmap2mask/pull/44
Any other ideas on fixing this? I've done every 'fix' I can find on this thread and the related ones, I've re-added midas more times than I can count, installed scads of different timm versions, and also rebuilt the venv folder. SD is the very latest as of today and so are all extensions including depthmap2mask. This exact dang error happens every single SD start unless I disable depthmap2mask. The only difference I can tell whatsoever at this point is that upon start SD says it's checking out midas with hash 1645b7e , which is the latest as of today. So that means it's probably overwritten midas every time I've tried to downgrade it anyhow. I've tried adding --skip-install to the CL arguments but it still does the git pull. I must've solved 200 SD install and git/python errors over the past week but I'm absolutely stuck on this one.
Actually I did sort of figure out a temporary fix late last night. I commented out the prepare_environment() line in SD's launch.py which effectively kills all updates upon launch. THEN I git an older version of midas into the repository folder. Without SD updating/overwriting midas the error went away. Of course, this isn't a long term solution. Hopefully someone can come up with an actual fix.
Well the whole point of my PR was to make it always pull the older version. Pretty much automating what you say. I don't know if when it was merged they changed the commit it was pointing at or something? I don't use this extension anymore.
yeah just looked at the code and someone updated it to he be the latest commit rather than the intentional older one I had in my PR. Don't know why they did that :(
Any other ideas on fixing this? I've done every 'fix' I can find on this thread and the related ones, I've re-added midas more times than I can count, installed scads of different timm versions, and also rebuilt the venv folder. SD is the very latest as of today and so are all extensions including depthmap2mask. This exact dang error happens every single SD start unless I disable depthmap2mask. The only difference I can tell whatsoever at this point is that upon start SD says it's checking out midas with hash 1645b7e , which is the latest as of today. So that means it's probably overwritten midas every time I've tried to downgrade it anyhow. I've tried adding --skip-install to the CL arguments but it still does the git pull. I must've solved 200 SD install and git/python errors over the past week but I'm absolutely stuck on this one.
I did but cant remember it and fairly sure another fault popped up not so long after so I now use thygates which has a very similar depthmap and is based on the same midas repo. Can use rembg online too.
I was having this same issue with both depthmap2mask and thygate/stable-diffusion-webui-depthmap-script since they both apparently need the updated timm. I'm somewhat new to how python and git/requirements work, but after hours of troubleshooting the past few days I found what may be the issue. The timm version in SD's requirements.txt is 0.6.7. But if you look in \venv\Lib\site-packages at the actual timm being installed, it's 0.4.12. Updating timm through pip with "pip install timm==0.6.13" upgrades it temporarily, but as soon as SD starts and it goes through preparing the environment and installing requirements, it downgrades it back to 0.4.12 and so yields the same issues and errors that an updated timm is supposed to solve. Took me ages to realize SD keeps overwriting/installing the old timm - no wonder no pip upgrade of any version actually worked. I searched through all other .txt files and found the culprit: \stable-diffusion-webui-master\repositories\BLIP\requirements.txt This file calls for timm==0.4.12 and apparently supersedes any other call for timm. Once I changed that file to call for timm==0.6.13 , the updated timm installation finally stuck! SD can go through all its prepare_environment and install requirements as it needs and this issue went away for both of these depth plugins/gits. Note: I didn't have to do anything to midas - it's the default that installs normally with the rest of this.
I guess that's one round about way of fixing it, but now you modified your copy of stable diffusion and will make updating harder. My fix was much simpler, just making sure the extension used the older Midas which works fine for this extension. The problem was fixed. Then someone for no reason that I can discern, and they've not replied to my queries, decided to change it to point back to the wrong version again. I could fix it again but whats to stop someone from just breaking it again? You can fix it yourself easily enough, just change the hash in install.py back to what I had set it at.
Yes - I understand. However, I never could get the install.py method to work either. launch.git_clone("https://github.com/isl-org/MiDaS.git", "repositories/midas", "midas", "xxxxxxx") I got an error every time like: "did not match any file(s) known to git". I tried with a number of other commit hashes on that, too. I know technically this isn't the best/long term way of fixing the issue, but it's the ONLY way out of hundreds of tries that works and still lets SD install requirements as needed. To me, the question now is really why do the requirements installed not reflect the newer SD requirement, but instead go according to BLIP's? Shouldn't the newer version take precedent, and/or the one listed in the main package's requirements instead of a dependency?
launch.git_clone("https://github.com/isl-org/MiDaS.git", "repositories/midas", "midas", "b845b78")
That should work unless something else is out of whack. Once you start messing with the environment it can make debugging things very hard. Not accusing just stating a fact :)
The above worked fine at the time I did it anyway with a clean install of everything. I know for a fact because I was using it at the time (not just a drive-by fix)
Hi, After installation using depthmap2mask I always get Error., Some different one. It deepens on what kind of model I use. Three types of Errors:
- TypeError: argument of type 'NoneType' is not iterable
- AttributeError: 'Block' object has no attribute 'drop_path'
- RuntimeError: Error(s) in loading state_dict for DPTDepthModel: Missing key(s) in state_dict: "pretrained.model.layers.3.downsample.reduction.weight", I already try to remove folder with depthmap2mask and installed it back, but it doesn't help. it was advise to download dpt_large_384.pt but I don't know where to put that thing in if I have to. I tried to do it with SD 1.5 and with SDXL base 1.0 with the same result. I use Stability Matrix. Please help me!
Hi, After installation using depthmap2mask I always get Error., Some different one. It deepens on what kind of model I use. Three types of Errors:
- TypeError: argument of type 'NoneType' is not iterable
- AttributeError: 'Block' object has no attribute 'drop_path'
- RuntimeError: Error(s) in loading state_dict for DPTDepthModel: Missing key(s) in state_dict: "pretrained.model.layers.3.downsample.reduction.weight", I already try to remove folder with depthmap2mask and installed it back, but it doesn't help. it was advise to download dpt_large_384.pt but I don't know where to put that thing in if I have to. I tried to do it with SD 1.5 and with SDXL base 1.0 with the same result. I use Stability Matrix. Please help me!
I have the same issue, but in my case midas_v21_384 work.