Forge Space and BiRefNet

This commit is contained in:
lllyasviel
2024-08-17 08:29:08 -07:00
committed by GitHub
parent 8a04293430
commit 93b40f355e
13 changed files with 390 additions and 13 deletions

View File

@@ -6,6 +6,8 @@ import warnings
import gradio.networking
import safetensors.torch
from tqdm import tqdm
def gradio_url_ok_fix(url: str) -> bool:
try:
@@ -55,7 +57,20 @@ def build_loaded(module, loader_name):
return
def always_show_tqdm(*args, **kwargs):
kwargs['disable'] = False
if 'name' in kwargs:
del kwargs['name']
return tqdm(*args, **kwargs)
def patch_all_basics():
import logging
from huggingface_hub import file_download
file_download.tqdm = always_show_tqdm
from transformers.dynamic_module_utils import logger
logger.setLevel(logging.ERROR)
gradio.networking.url_ok = gradio_url_ok_fix
build_loaded(safetensors.torch, 'load_file')
build_loaded(torch, 'load')