From f0603b3baafd27d8a96aceacd07bd00a758fd260 Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Thu, 25 Jan 2024 22:31:06 -0800 Subject: [PATCH] Update gradio_compile.py --- modules_forge/gradio_compile.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/modules_forge/gradio_compile.py b/modules_forge/gradio_compile.py index 7c6e6a1b..c5470125 100644 --- a/modules_forge/gradio_compile.py +++ b/modules_forge/gradio_compile.py @@ -1,14 +1,24 @@ def gradio_compile(items, prefix): for k, v in items["required"].items(): - if len(v) == 2: - t, d = v - if t == 'INT': - name = (prefix + '_' + k).replace(' ', '_').lower() - title = name.replace('_', ' ').capitalize() - default = int(d['default']) - min = int(d['min']) - max = int(d['max']) - step = int(d.get('step', 1)) - print(f'{name} = gr.Slider(label=\'{title}\', minimum={min}, maximum={max}, step={step}, value={default})') + t = v[0] + d = v[1] if len(v) > 1 else None + name = (prefix + '_' + k).replace(' ', '_').lower() + title = name.replace('_', ' ').capitalize() + + if t == 'INT': + default = int(d['default']) + min = int(d['min']) + max = int(d['max']) + step = int(d.get('step', 1)) + print(f'{name} = gr.Slider(label=\'{title}\', minimum={min}, maximum={max}, step={step}, value={default})') + elif t == 'FLOAT': + default = float(d['default']) + min = float(d['min']) + max = float(d['max']) + step = float(d.get('step', 0.001)) + print(f'{name} = gr.Slider(label=\'{title}\', minimum={min}, maximum={max}, step={step}, value={default})') + else: + print('error ' + t) + return