(self, script)
| 652 | def create_script_ui_inner(self, script): |
| 653 | import modules.api.models as api_models |
| 654 | |
| 655 | controls = wrap_call(script.ui, script.filename, "ui", script.is_img2img) |
| 656 | script.controls = controls |
| 657 | |
| 658 | if controls is None: |
| 659 | return |
| 660 | |
| 661 | script.name = wrap_call(script.title, script.filename, "title", default=script.filename).lower() |
| 662 | |
| 663 | api_args = [] |
| 664 | |
| 665 | for control in controls: |
| 666 | control.custom_script_source = os.path.basename(script.filename) |
| 667 | |
| 668 | arg_info = api_models.ScriptArg(label=control.label or "") |
| 669 | |
| 670 | for field in ("value", "minimum", "maximum", "step"): |
| 671 | v = getattr(control, field, None) |
| 672 | if v is not None: |
| 673 | setattr(arg_info, field, v) |
| 674 | |
| 675 | choices = getattr(control, 'choices', None) # as of gradio 3.41, some items in choices are strings, and some are tuples where the first elem is the string |
| 676 | if choices is not None: |
| 677 | arg_info.choices = [x[0] if isinstance(x, tuple) else x for x in choices] |
| 678 | |
| 679 | api_args.append(arg_info) |
| 680 | |
| 681 | script.api_info = api_models.ScriptInfo( |
| 682 | name=script.name, |
| 683 | is_img2img=script.is_img2img, |
| 684 | is_alwayson=script.alwayson, |
| 685 | args=api_args, |
| 686 | ) |
| 687 | |
| 688 | if script.infotext_fields is not None: |
| 689 | self.infotext_fields += script.infotext_fields |
| 690 | |
| 691 | if script.paste_field_names is not None: |
| 692 | self.paste_field_names += script.paste_field_names |
| 693 | |
| 694 | self.inputs += controls |
| 695 | script.args_to = len(self.inputs) |
| 696 | |
| 697 | def setup_ui_for_section(self, section, scriptlist=None): |
| 698 | if scriptlist is None: |
| 699 | scriptlist = self.alwayson_scripts |
| 700 |
no test coverage detected