Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: TypeError: load() missing 1 required positional argument: 'map_location' #2764

Closed
1 task done
ride5k opened this issue Apr 18, 2024 · 4 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working Not reproducable The issue cannot be reproduced

Comments

@ride5k
Copy link

ride5k commented Apr 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits of both this extension and the webui

What happened?

controlnet no longer works, console shows
TypeError: load() missing 1 required positional argument: 'map_location'

this occurs even when previewing CN output, as well as during image generation

Steps to reproduce the problem

  1. Go to txt2img
  2. enable controlnet / openpose / allow preview
  3. upload image
  4. click preview process button
  5. gui displays ERROR

What should have happened?

controlnet should process the uploaded image and return a preview openpose

Commit where the problem happens

webui: v1.9.0-5-g74787236
python: 3.10.11
torch: 2.0.0+cpu
xformers: N/A
gradio: 3.41.2
ControlNet v1.1.444

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

--listen --no-half --precision full --theme=dark --disable-nan-check --disable-safe-unpickle --medvram --sub-quad-q-chunk-size 128 --sub-quad-kv-chunk-size 128 --sub-quad-chunk-threshold 20 --skip-torch-cuda-test --use-directml --api --cors-allow-origins=http://127.0.0.1:3456 --enable-insecure-extension-access --ckpt-dir=U:/extraSDstuff/U_models --skip-version-check --use-cpu gfpgan codeformer

List of enabled extensions

only built-in

Console logs

venv "T:\auto1111\stable-diffusion-webui-directml\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Version: v1.9.0-5-g74787236
Commit hash: 74787236d0ff94dc37506d198f3b2562991b8702
Installing sd-webui-controlnet requirement: changing albumentations version from 1.4.2 to 1.4.3
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\pytorch_lightning\utilities\distributed.py:258: LightningDeprecationWarning: `pytorch_lightning.utilities.distributed.rank_zero_only` has been deprecated in v1.8.1 and will be removed in v2.0.0. You can import it from `pytorch_lightning.utilities` instead.
  rank_zero_deprecation(
Launching Web UI with arguments: --listen --no-half --precision full --theme=dark --disable-nan-check --disable-safe-unpickle --medvram --sub-quad-q-chunk-size 128 --sub-quad-kv-chunk-size 128 --sub-quad-chunk-threshold 20 --skip-torch-cuda-test --use-directml --api --cors-allow-origins=http://127.0.0.1:3456 --enable-insecure-extension-access --ckpt-dir=U:/extraSDstuff/U_models --skip-version-check --use-cpu gfpgan codeformer
ONNX: selected=DmlExecutionProvider, available=['DmlExecutionProvider', 'CPUExecutionProvider']
ControlNet preprocessor location: T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\annotator\downloads
2024-04-18 12:50:57,381 - ControlNet - INFO - ControlNet v1.1.444
2024-04-18 12:50:57,557 - ControlNet - INFO - ControlNet v1.1.444
Loading weights [15d2100594] from U:\extraSDstuff\U_models\.HDD\5done\amIReal_V44.safetensors
2024-04-18 12:50:57,786 - ControlNet - INFO - ControlNet UI callback registered.
Creating model from config: T:\auto1111\stable-diffusion-webui-directml\configs\v1-inference.yaml
Running on local URL:  http://0.0.0.0:7860
Applying attention optimization: V1... done.
Model loaded in 2.5s (load weights from disk: 0.5s, create model: 0.5s, apply weights to model: 0.4s, apply float(): 0.6s, calculate empty prompt: 0.5s).

To create a public link, set `share=True` in `launch()`.
Startup time: 13.3s (prepare environment: 11.4s, initialize shared: 1.1s, load scripts: 1.4s, create ui: 0.4s, gradio launch: 4.4s, add APIs: 0.3s).
2024-04-18 12:51:33,863 - ControlNet - INFO - Preview Resolution = 512
Traceback (most recent call last):
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "T:\auto1111\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\scripts\controlnet_ui\controlnet_ui_group.py", line 933, in run_annotator
    result = preprocessor.cached_call(
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\scripts\utils.py", line 81, in decorated_func
    return cached_func(*args, **kwargs)
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\scripts\utils.py", line 65, in cached_func
    return func(*args, **kwargs)
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\scripts\supported_preprocessor.py", line 170, in cached_call
    return self(*args, **kwargs)
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\scripts\preprocessor\legacy\legacy_preprocessors.py", line 97, in __call__
    result, is_image = self.call_function(
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\scripts\preprocessor\legacy\processor.py", line 274, in run_model
    return remove_pad(self.model_openpose(
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\annotator\openpose\__init__.py", line 447, in __call__
    poses = self.detect_poses(oriImg, include_hand, include_face)
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\annotator\openpose\__init__.py", line 333, in detect_poses
    self.load_model()
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\annotator\openpose\__init__.py", line 220, in load_model
    self.body_estimation = Body(body_modelpath)
  File "T:\auto1111\stable-diffusion-webui-directml\extensions\sd-webui-controlnet\annotator\openpose\body.py", line 19, in __init__
    model_dict = util.transfer(self.model, torch.load(model_path))
TypeError: load() missing 1 required positional argument: 'map_location'

Additional information

AMD build

@huchenlei huchenlei added the bug Something isn't working label Apr 18, 2024
@huchenlei huchenlei self-assigned this Apr 18, 2024
@huchenlei huchenlei added the Not reproducable The issue cannot be reproduced label Apr 18, 2024
@huchenlei
Copy link
Collaborator

torch.load does not have map_location as a required positional argument. It defaults to None according to https://github.com/pytorch/pytorch/blob/7a6edb0b6644eb2b28650ea3be1c806e4a57e351/torch/serialization.py#L865-L873.

@huchenlei
Copy link
Collaborator

A1111's torch.load wrapper also only takes 1 positional arg according to https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/adadb4e3c7382bf3e4f7519126cd6c70f4f8557b/modules/safe.py#L107-L108.

@ride5k
Copy link
Author

ride5k commented Apr 18, 2024

@huchenlei i am running on lshqqytiger's directML fork. Do you think that could be contributing?

@huchenlei
Copy link
Collaborator

You probably want to file an issue in https://github.com/lshqqytiger/stable-diffusion-webui-directml. I do see all torch.load call in that repo having map_location arg specified, but I don't see a location where the change was made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Not reproducable The issue cannot be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants