Merge pull request #12453 from AUTOMATIC1111/catch-float-ValueError-default-to--1

Catch float value error default to -1
This commit is contained in:
AUTOMATIC1111 2023-08-10 16:46:40 +03:00 committed by GitHub
commit 959404e0e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -51,7 +51,10 @@ class UiLoadsave:
if isinstance(x, gr.Textbox) and field == 'value': # due to an undersirable behavior of gr.Textbox, if you give it an int value instead of str, everything dies
saved_value = str(saved_value)
elif isinstance(x, gr.Number) and field == 'value':
saved_value = float(saved_value)
try:
saved_value = float(saved_value)
except ValueError:
saved_value = -1
setattr(obj, field, saved_value)
if init_field is not None: