This commit is contained in:
AUTOMATIC1111 2024-03-02 08:43:46 +03:00
parent 50699ce112
commit b63dda3f45
2 changed files with 10 additions and 11 deletions

View File

@ -11,7 +11,6 @@ import subprocess as sp
from PIL import Image
from modules import call_queue, shared, ui_tempdir
from modules.infotext_utils import image_from_url_text
import modules.images
from modules.ui_components import ToolButton
import modules.infotext_utils as parameters_copypaste

View File

@ -14,30 +14,30 @@ from modules import shared
Savedfile = namedtuple("Savedfile", ["name"])
def register_tmp_file(gradio, filename):
if hasattr(gradio, 'temp_file_sets'): # gradio 3.15
def register_tmp_file(gradio_app, filename):
if hasattr(gradio_app, 'temp_file_sets'): # gradio 3.15
if hasattr(gr.utils, 'abspath'): # gradio 4.19
filename = gr.utils.abspath(filename)
else:
filename = os.path.abspath(filename)
gradio.temp_file_sets[0] = gradio.temp_file_sets[0] | {filename}
gradio_app.temp_file_sets[0] = gradio_app.temp_file_sets[0] | {filename}
if hasattr(gradio, 'temp_dirs'): # gradio 3.9
gradio.temp_dirs = gradio.temp_dirs | {os.path.abspath(os.path.dirname(filename))}
if hasattr(gradio_app, 'temp_dirs'): # gradio 3.9
gradio_app.temp_dirs = gradio_app.temp_dirs | {os.path.abspath(os.path.dirname(filename))}
def check_tmp_file(gradio, filename):
if hasattr(gradio, 'temp_file_sets'):
def check_tmp_file(gradio_app, filename):
if hasattr(gradio_app, 'temp_file_sets'):
if hasattr(gr.utils, 'abspath'): # gradio 4.19
filename = gr.utils.abspath(filename)
else:
filename = os.path.abspath(filename)
return any(filename in fileset for fileset in gradio.temp_file_sets)
return any(filename in fileset for fileset in gradio_app.temp_file_sets)
if hasattr(gradio, 'temp_dirs'):
return any(Path(temp_dir).resolve() in Path(filename).resolve().parents for temp_dir in gradio.temp_dirs)
if hasattr(gradio_app, 'temp_dirs'):
return any(Path(temp_dir).resolve() in Path(filename).resolve().parents for temp_dir in gradio_app.temp_dirs)
return False