installer handler for numpy

Signed-off-by: Vladimir Mandic <[email protected]>
This commit is contained in:
Vladimir Mandic
2026-09-05 22:54:56 +02:00
parent 29de324ff7
commit f446cca02d
10 changed files with 23 additions and 1329 deletions
+1
View File
@@ -94,6 +94,7 @@ All-about-optimizations:
- log: ansi color handling
- compile: keep model compiled state
- prompt: cache checks when cfg changes
- lucida: handle requirements
## Update for 2026-08-26
-1
View File
@@ -1,3 +1,2 @@
fastapi==0.124.4
Pillow==12.2.0
# numpy==2.5.2
+16
View File
@@ -640,6 +640,22 @@ def check_onnx():
ts('onnx', t_start)
# check numpy version
def check_numpy():
t_start = time.time()
if args.skip_all or args.skip_requirements:
return
torch_ver = package_version('torch')
torch_minor = int(torch_ver.split('.')[1]) if torch_ver else 99
if torch_minor < 11:
if not installed('numpy==2.1.2', quiet=True):
install('numpy==2.1.2', 'numpy==2.1.2', ignore=True)
else:
if not installed('numpy==2.4.6', quiet=True):
install('numpy==2.4.6', 'numpy==2.4.6', ignore=True)
ts('numpy', t_start)
def install_cuda():
t_start = time.time()
log.info('CUDA: nVidia toolkit detected')
+1
View File
@@ -262,6 +262,7 @@ def main():
installer.install('uv', 'uv')
installer.install_gradio()
installer.check_torch()
installer.check_numpy()
installer.check_onnx()
installer.check_transformers()
installer.check_diffusers()
-24
View File
@@ -1,24 +0,0 @@
model = None
def remove(image, refine: bool = True):
global model # pylint: disable=global-statement
from modules import shared, devices
if model is None:
from huggingface_hub import hf_hub_download
from .ben2_model import BEN_Base
model = BEN_Base()
model_file = hf_hub_download(
repo_id='PramaLLC/BEN2',
filename='BEN2_Base.pth',
cache_dir=shared.opts.hfcache_dir)
model.loadcheckpoints(model_file)
model = model.to(device=devices.device, dtype=devices.dtype).eval()
model = model.to(device=devices.device)
foreground = model.inference(image, refine_foreground=refine)
model = model.to(device=devices.cpu)
if foreground is None:
return image
return foreground
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -263,7 +263,7 @@ def run_rembg(input_image: Image.Image, input_mask: np.ndarray):
if "U2NET_HOME" not in os.environ:
os.environ["U2NET_HOME"] = os.path.join(paths.models_path, "Rembg")
if opts.model == 'ben2':
from modules import ben2
from modules.rembg import ben2
args = {
'image': input_image,
'refine': True,
+2 -2
View File
@@ -3,7 +3,7 @@ from fastapi import Body
def dependencies():
from installer import install
for pkg in ["dctorch==0.1.2", "pymatting", "pooch", "rembg", "numba"]:
for pkg in ["dctorch==0.1.2", "pymatting", "pooch", "rembg", "numba", "kornia", "kornia-rs"]:
install(pkg, no_deps=True, ignore=False)
@@ -25,6 +25,7 @@ async def post_rembg(
if input_image is None:
return {}
dependencies()
if model == "ben2":
from modules.rembg import ben2
image = ben2.remove(input_image, refine=refine)
@@ -32,7 +33,6 @@ async def post_rembg(
from modules.rembg import lucida
image = lucida.remove(input_image)
else:
dependencies()
import rembg
image = rembg.remove( # pylint: disable=c-extension-no-member
input_image,
-1
View File
@@ -34,7 +34,6 @@ accelerate==1.14.0
einops==0.8.2
huggingface_hub==1.30.0
hf_xet==1.6.0
numpy==2.5.2
pandas==2.3.1
protobuf==7.36.1
pytorch_lightning==2.6.5
+2 -2
View File
@@ -20,7 +20,7 @@ models = [
def dependencies():
from installer import install
for pkg in ["dctorch==0.1.2", "pymatting", "pooch", "rembg", "numba"]:
for pkg in ["dctorch==0.1.2", "pymatting", "pooch", "rembg", "numba", "kornia", "kornia-rs"]:
install(pkg, no_deps=True, ignore=False)
@@ -78,6 +78,7 @@ class ScriptPostprocessingRembg(scripts_postprocessing.ScriptPostprocessing):
if image is None:
return pp
log.info(f'RemoveBackground: model={model} merge_alpha={merge_alpha} refine={refine} mask_only={mask_only} postprocess_mask={postprocess_mask} alpha_matting={alpha_matting} alpha_matting_foreground_threshold={alpha_matting_foreground_threshold} alpha_matting_background_threshold={alpha_matting_background_threshold} alpha_matting_erode_size={alpha_matting_erode_size}')
dependencies()
if model == 'ben2':
try:
from modules.rembg import ben2
@@ -96,7 +97,6 @@ class ScriptPostprocessingRembg(scripts_postprocessing.ScriptPostprocessing):
return pp
else:
try:
dependencies()
import rembg
if "U2NET_HOME" not in os.environ:
from modules.paths import models_path