monkeypatch numpy for gradio

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-07-07 19:45:30 -04:00
parent b625884031
commit e6d97f4d44
5 changed files with 19 additions and 7 deletions
+2 -1
View File
@@ -93,7 +93,8 @@ Although upgrades and existing installations are tested and should work fine!
- override `gradio` installer
- major refactoring of requirements and dependencies to unblock `numpy>=2.1.0`
- patch `insightface`
- patch `facelib`
- patch `facelib`
- patch `numpy`
- stronger lint rules
add separate `npm run lint`, `npm run todo`, `npm run test`, `npm run format` macros
+4 -3
View File
@@ -4,16 +4,15 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma
## Current
- Bug: FramePack with SQND
## Future Candidates
- Feature: Common repo for `T5` and `CLiP`
- Feature: LoRA add OMI format support for SD35/FLUX.1
- Feature: Merge FramePack into core
- Refactor: sampler options
- Refactor: cleanup `/repositories/codeformer`
- Remove: Agent Scheduler
- Video: API support
- ModernUI: Lite vs Expert mode
### Blocked items
@@ -32,6 +31,8 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma
- [Nunchaku PulID](https://github.com/mit-han-lab/nunchaku/pull/274)
- [Dream0 guidance](https://huggingface.co/ByteDance/DreamO)
- [SUPIR upscaler](https://github.com/Fanghua-Yu/SUPIR)
- Remove: Agent Scheduler
- ModernUI: Lite vs Expert mode
### Future Considerations
- [TensorRT](https://github.com/huggingface/diffusers/pull/11173)
+8 -1
View File
@@ -18,10 +18,16 @@ np = None
try:
import numpy as np # pylint: disable=W0611,C0411
import numpy.random # pylint: disable=W0611,C0411 # this causes failure if numpy version changed
def obj2sctype(obj):
return np.dtype(obj).type
np.obj2sctype = obj2sctype # noqa: NPY201
np.bool8 = np.bool
np.float_ = np.float64 # noqa: NPY201
except Exception as e:
errors.log.error(f'Loader: numpy=={np.__version__ if np is not None else None} {e}')
errors.log.error('Please restart the app to fix this issue')
sys.exit(1)
timer.startup.record("numpy")
try:
import scipy # pylint: disable=W0611,C0411
@@ -29,6 +35,7 @@ except Exception as e:
errors.log.error(f'Loader: scipy=={np.__version__ if np is not None else None} {e}')
errors.log.error('Please restart the app to fix this issue')
sys.exit(1)
timer.startup.record("scipy")
import torch # pylint: disable=C0411
if torch.__version__.startswith('2.5.0'):
@@ -64,12 +71,12 @@ if ".dev" in torch.__version__ or "+git" in torch.__version__:
torch.__version__ = re.search(r'[\d.]+[\d]', torch.__version__).group(0)
timer.startup.record("torch")
try:
import bitsandbytes # pylint: disable=W0611,C0411
except Exception:
from diffusers.utils import import_utils
import_utils._bitsandbytes_available = False # pylint: disable=protected-access
timer.startup.record("bnb")
import transformers # pylint: disable=W0611,C0411
from transformers import logging as transformers_logging # pylint: disable=W0611,C0411
+4 -1
View File
@@ -54,7 +54,10 @@ def sdnq_quantize_layer(layer, weights_dtype="int8", torch_dtype=None, group_siz
else:
is_linear_type = True
reduction_axes = -1
output_channel_size, channel_size = layer.weight.shape
try:
output_channel_size, channel_size = layer.weight.shape
except Exception as e:
raise ValueError(f"SDNQ: layer_class_name={layer_class_name} layer_weight_shape={layer.weight.shape} weights_dtype={weights_dtype} unsupported") from e
if use_quantized_matmul:
use_quantized_matmul = weights_dtype in quantized_matmul_dtypes and channel_size >= 32 and output_channel_size >= 32
if use_quantized_matmul:
+1 -1
Submodule wiki updated: 5f74166499...0cd1d57c1d