Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
c0ee1488
Commit
c0ee1488
authored
Jan 03, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for running with gradio 3.9 installed
parent
fda1ed18
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
generation_parameters_copypaste.py
modules/generation_parameters_copypaste.py
+2
-2
ui_tempdir.py
modules/ui_tempdir.py
+21
-2
No files found.
modules/generation_parameters_copypaste.py
View file @
c0ee1488
...
...
@@ -7,7 +7,7 @@ from pathlib import Path
import
gradio
as
gr
from
modules.shared
import
script_path
from
modules
import
shared
from
modules
import
shared
,
ui_tempdir
import
tempfile
from
PIL
import
Image
...
...
@@ -39,7 +39,7 @@ def quote(text):
def
image_from_url_text
(
filedata
):
if
type
(
filedata
)
==
dict
and
filedata
[
"is_file"
]:
filename
=
filedata
[
"name"
]
is_in_right_dir
=
any
([
filename
in
fileset
for
fileset
in
shared
.
demo
.
temp_file_sets
]
)
is_in_right_dir
=
ui_tempdir
.
check_tmp_file
(
shared
.
demo
,
filename
)
assert
is_in_right_dir
,
'trying to open image file outside of allowed directories'
return
Image
.
open
(
filename
)
...
...
modules/ui_tempdir.py
View file @
c0ee1488
import
os
import
tempfile
from
collections
import
namedtuple
from
pathlib
import
Path
import
gradio
as
gr
...
...
@@ -12,10 +13,28 @@ from modules import shared
Savedfile
=
namedtuple
(
"Savedfile"
,
[
"name"
])
def
register_tmp_file
(
gradio
,
filename
):
if
hasattr
(
gradio
,
'temp_file_sets'
):
# gradio 3.15
gradio
.
temp_file_sets
[
0
]
=
gradio
.
temp_file_sets
[
0
]
|
{
os
.
path
.
abspath
(
filename
)}
if
hasattr
(
gradio
,
'temp_dirs'
):
# gradio 3.9
gradio
.
temp_dirs
=
gradio
.
temp_dirs
|
{
os
.
path
.
abspath
(
os
.
path
.
dirname
(
filename
))}
def
check_tmp_file
(
gradio
,
filename
):
if
hasattr
(
gradio
,
'temp_file_sets'
):
return
any
([
filename
in
fileset
for
fileset
in
gradio
.
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
)
return
False
def
save_pil_to_file
(
pil_image
,
dir
=
None
):
already_saved_as
=
getattr
(
pil_image
,
'already_saved_as'
,
None
)
if
already_saved_as
and
os
.
path
.
isfile
(
already_saved_as
):
shared
.
demo
.
temp_file_sets
[
0
]
=
shared
.
demo
.
temp_file_sets
[
0
]
|
{
os
.
path
.
abspath
(
already_saved_as
)}
register_tmp_file
(
shared
.
demo
,
already_saved_as
)
file_obj
=
Savedfile
(
already_saved_as
)
return
file_obj
...
...
@@ -45,7 +64,7 @@ def on_tmpdir_changed():
os
.
makedirs
(
shared
.
opts
.
temp_dir
,
exist_ok
=
True
)
shared
.
demo
.
temp_file_sets
[
0
]
=
shared
.
demo
.
temp_file_sets
[
0
]
|
{
os
.
path
.
abspath
(
shared
.
opts
.
temp_dir
)}
register_tmp_file
(
shared
.
demo
,
os
.
path
.
join
(
shared
.
opts
.
temp_dir
,
"x"
))
def
cleanup_tmpdr
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment