donahowe / AutoStudio

AutoStudio: Crafting Consistent Subjects in Multi-turn Interactive Image Generation
https://arxiv.org/abs/2406.01388
385 stars 31 forks source link

numpy.core.multiarray failed to import #38

Open TheLegendOfKitty opened 1 month ago

TheLegendOfKitty commented 1 month ago

Getting this problem on an i9-9900k, RTX 2080 + RTX 3060 Ti system. Any suggestions to fix?

NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/home/parsa/HDD/machine learning/AutoStudio/run.py", line 19, in <module>
    import torch
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/torch/__init__.py", line 1382, in <module>
    from .functional import *  # noqa: F403
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/torch/functional.py", line 7, in <module>
    import torch.nn.functional as F
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
    from .transformer import TransformerEncoder, TransformerDecoder, \
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/home/parsa/HDD/machine learning/AutoStudio/model/pipeline_stable_diffusion.py:41: FutureWarning: Importing `DiffusionPipeline` or `ImagePipelineOutput` from diffusers.pipeline_utils is deprecated. Please import from diffusers.pipelines.pipeline_utils instead.
  from diffusers.pipeline_utils import DiffusionPipeline
/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/gradio_client/documentation.py:106: UserWarning: Could not get documentation group for <class 'gradio.mix.Parallel'>: No known documentation group for module 'gradio.mix'
  warnings.warn(f"Could not get documentation group for {cls}: {exc}")
/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/gradio_client/documentation.py:106: UserWarning: Could not get documentation group for <class 'gradio.mix.Series'>: No known documentation group for module 'gradio.mix'
  warnings.warn(f"Could not get documentation group for {cls}: {exc}")
Using box scale: (512, 512)

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/home/parsa/HDD/machine learning/AutoStudio/run.py", line 31, in <module>
    from model.autostudio import AUTOSTUDIO, AUTOSTUDIOPlus, AUTOSTUDIOXL, AUTOSTUDIOXLPlus
  File "/home/parsa/HDD/machine learning/AutoStudio/model/autostudio.py", line 16, in <module>
    from detectSam import process_image
  File "/home/parsa/HDD/machine learning/AutoStudio/DETECT_SAM/detectSam.py", line 14, in <module>
    import cv2
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/home/parsa/.pyenv/versions/3.10.6/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
AttributeError: _ARRAY_API not found
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/parsa/HDD/machine learning/AutoStudio/run.py:31 in <module>                                │
│                                                                                                  │
│    28                                                                                            │
│    29 from model.unet_2d_condition import UNet2DConditionModel                                   │
│    30 from model.utils import show_boxes, show_image, get_global_prompt                          │
│ ❱  31 from model.autostudio import AUTOSTUDIO, AUTOSTUDIOPlus, AUTOSTUDIOXL, AUTOSTUDIOXLPlus    │
│    32                                                                                            │
│    33 from detectSam import EFFICIENT_SAM_MODEL, GROUNDING_DINO_MODEL                            │
│    34                                                                                            │
│                                                                                                  │
│ /home/parsa/HDD/machine learning/AutoStudio/model/autostudio.py:16 in <module>                   │
│                                                                                                  │
│     13                                                                                           │
│     14 from PIL import Image                                                                     │
│     15 from typing import List                                                                   │
│ ❱   16 from detectSam import process_image                                                       │
│     17 from diffusers.pipelines.controlnet import MultiControlNetModel                           │
│     18 from safetensors import safe_open                                                         │
│     19 from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection                │
│                                                                                                  │
│ /home/parsa/HDD/machine learning/AutoStudio/DETECT_SAM/detectSam.py:14 in <module>               │
│                                                                                                  │
│    11 sys.path.append(f"{dpath}/YOLO-World/")                                                    │
│    12 sys.path.append(f"{dpath}/Grounding-DINO/")                                                │
│    13                                                                                            │
│ ❱  14 import cv2                                                                                 │
│    15 import time                                                                                │
│    16 import contextlib                                                                          │
│    17 import numpy as np                                                                         │
│                                                                                                  │
│ /home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/cv2/__init__.py:181 in  │
│ <module>                                                                                         │
│                                                                                                  │
│   178 │   if DEBUG: print('OpenCV loader: DONE')                                                 │
│   179                                                                                            │
│   180                                                                                            │
│ ❱ 181 bootstrap()                                                                                │
│   182                                                                                            │
│                                                                                                  │
│ /home/parsa/HDD/machine learning/AutoStudio/lib/python3.10/site-packages/cv2/__init__.py:153 in  │
│ bootstrap                                                                                        │
│                                                                                                  │
│   150 │                                                                                          │
│   151 │   py_module = sys.modules.pop("cv2")                                                     │
│   152 │                                                                                          │
│ ❱ 153 │   native_module = importlib.import_module("cv2")                                         │
│   154 │                                                                                          │
│   155 │   sys.modules["cv2"] = py_module                                                         │
│   156 │   setattr(py_module, "_native", native_module)                                           │
│                                                                                                  │
│ /home/parsa/.pyenv/versions/3.10.6/lib/python3.10/importlib/__init__.py:126 in import_module     │
│                                                                                                  │
│   123 │   │   │   if character != '.':                                                           │
│   124 │   │   │   │   break                                                                      │
│   125 │   │   │   level += 1                                                                     │
│ ❱ 126 │   return _bootstrap._gcd_import(name[level:], package, level)                            │
│   127                                                                                            │
│   128                                                                                            │
│   129 _RELOADING = {}                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: numpy.core.multiarray failed to import
shoefang commented 1 month ago

try pip install numpy==1.23.5

TheLegendOfKitty commented 1 month ago

Hi,

Now it works, but I run out of vram. I have 20 gb of vram, how much is necessary?