From 176ac924af83ce8df6a9cdad8cc3b16c64690cc0 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 23 Apr 2023 08:11:26 -0400 Subject: [PATCH] make tensorflow optional --- TODO.md | 1 + extensions-builtin/sd-webui-controlnet | 2 +- modules/lora | 2 +- modules/modelloader.py | 2 +- modules/shared.py | 7 +++++-- requirements.txt | 1 - setup.py | 6 ++++++ 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index e04d5a361..c9fd8e1d6 100644 --- a/TODO.md +++ b/TODO.md @@ -7,6 +7,7 @@ Stuff to be fixed... - ClipSkip not updated on read gen info - Usage of `sd_vae` in quick settings - Run VAE with hires at 1280 +- Make TensorFlow optional ## Features diff --git a/extensions-builtin/sd-webui-controlnet b/extensions-builtin/sd-webui-controlnet index 68e4acf7c..a8f45816e 160000 --- a/extensions-builtin/sd-webui-controlnet +++ b/extensions-builtin/sd-webui-controlnet @@ -1 +1 @@ -Subproject commit 68e4acf7c9ae899fd073df9cc3712cf0b7cb249d +Subproject commit a8f45816e340366dd212522e4c8dd63965d9848c diff --git a/modules/lora b/modules/lora index b824bbfce..25c8279f2 160000 --- a/modules/lora +++ b/modules/lora @@ -1 +1 @@ -Subproject commit b824bbfce6bdd83befab725ca4cdc1bfd43d2f65 +Subproject commit 25c8279f2692983f262f7e024b52defff852ae46 diff --git a/modules/modelloader.py b/modules/modelloader.py index f1c79ff4d..dce51549c 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -40,7 +40,7 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None for place in places: if os.path.exists(place): - for file in glob.iglob(place + '**/**', recursive=True): + for file in glob.iglob(os.path.join(place, '**/**'), recursive=True): full_path = file if os.path.isdir(full_path): continue diff --git a/modules/shared.py b/modules/shared.py index 22dc628d7..664620561 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -205,8 +205,11 @@ def list_samplers(): def list_themes(): if not os.path.exists(os.path.join('javascript', 'themes.json')): refresh_themes() - with open(os.path.join('javascript', 'themes.json'), mode='r', encoding='utf=8') as f: - res = json.loads(f.read()) + if os.path.exists(os.path.join('javascript', 'themes.json')): + with open(os.path.join('javascript', 'themes.json'), mode='r', encoding='utf=8') as f: + res = json.loads(f.read()) + else: + res = [] builtin = ["black-orange", "gradio/default", "gradio/base", "gradio/glass", "gradio/monochrome", "gradio/soft"] themes = builtin + [x['id'] for x in res if x['status'] == 'RUNNING' and 'test' not in x['id'].lower()] return themes diff --git a/requirements.txt b/requirements.txt index d4b437458..4519a69c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -59,7 +59,6 @@ numexpr==2.8.4 pandas==1.5.3 protobuf==3.20.3 pytorch_lightning==1.9.4 -tensorflow==2.12.0 transformers==4.26.1 timm==0.6.13 tomesd==0.1.2 diff --git a/setup.py b/setup.py index d3af2834b..87fabf5fc 100644 --- a/setup.py +++ b/setup.py @@ -214,6 +214,11 @@ def check_torch(): install(f'--no-deps {xformers_package}', ignore=True) except Exception as e: log.debug(f'Cannot install xformers package: {e}') + try: + tensorflow_package = os.environ.get('TENSORFLOW_PACKAGE', 'tensorflow==2.12.0') + install(f'--no-deps {tensorflow_package}', ignore=True) + except Exception as e: + log.debug(f'Cannot install tensorflow package: {e}') # install required packages @@ -363,6 +368,7 @@ def set_environment(): os.environ.setdefault('GRADIO_ANALYTICS_ENABLED', 'False') os.environ.setdefault('SAFETENSORS_FAST_GPU', '1') os.environ.setdefault('NUMEXPR_MAX_THREADS', '16') + os.environ.setdefault('PYTORCH_ENABLE_MPS_FALLBACK', '1') def check_extensions():