make tensorflow optional

This commit is contained in:
Vladimir Mandic
2023-04-23 08:11:26 -04:00
parent bef352c233
commit 176ac924af
7 changed files with 15 additions and 6 deletions
+1
View File
@@ -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
+1 -1
View File
@@ -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
+5 -2
View File
@@ -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
-1
View File
@@ -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
+6
View File
@@ -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():