prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  FileNotFoundError after new update
  Getting a FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\admin\\stable-diffusion-webui\\scripts' after the new update. 
  
  Not exactly good at all the coding stuff, using it just fine yesterday but I downloaded the repo instead of git clone, for the sake of easier update I started a new installation by git cloning into user folder and the installation went well but ran into this while launching through webui.py.
  
  Python 3.10.6
  venv C:\Users\admin\stable-diffusion-webui\venv\Scripts\Python.exe
  Launching webui.py...
  Loading model from C:\Users\admin\stable-diffusion-webui\model.ckpt
  Global Step: 470000
  LatentDiffusion: Running in eps-prediction mode
  DiffusionWrapper has 859.52 M params.
  making attention of type 'vanilla' with 512 in_channels
  Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
  making attention of type 'vanilla' with 512 in_channels
  Traceback (most recent call last):
    File "C:\Users\admin\stable-diffusion-webui\webui.py", line 135, in <module>
      modules.scripts.load_scripts(os.path.join(script_path, "scripts"))
    File "C:\Users\admin\stable-diffusion-webui\modules\scripts.py", line 32, in load_scripts
      for filename in os.listdir(basedir):
  FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\admin\\stable-diffusion-webui\\scripts'
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `modules/scripts.py`
  Content:
  ```
  1 import os
  2 import sys
  3 import traceback
  4 
  5 import modules.ui as ui
  6 import gradio as gr
  7 
  8 from modules.processing import StableDiffusionProcessing
  9 
  10 class Script:
  11     filename = None
  12     args_from = None
  13     args_to = None
  14 
  15     def title(self):
  16         raise NotImplementedError()
  17 
  18     def ui(self, is_img2img):
  19         pass
  20 
  21     def run(self, *args):
  22         raise NotImplementedError()
  23 
  24     def describe(self):
  25         return ""
  26 
  27 
  28 scripts = []
  29 
  30 
  31 def load_scripts(basedir):
  32     for filename in os.listdir(basedir):
  33         path = os.path.join(basedir, filename)
  34 
  35         if not os.path.isfile(path):
  36             continue
  37 
  38         with open(path, "r", encoding="utf8") as file:
  39             text = file.read()
  40 
  41         from types import ModuleType
  42         compiled = compile(text, path, 'exec')
  43         module = ModuleType(filename)
  44         exec(compiled, module.__dict__)
  45 
  46         for key, script_class in module.__dict__.items():
  47             if type(script_class) == type and issubclass(script_class, Script):
  48                 obj = script_class()
  49                 obj.filename = path
  50 
  51                 scripts.append(obj)
  52 
  53 
  54 def wrap_call(func, filename, funcname, *args, default=None, **kwargs):
  55     try:
  56         res = func(*args, **kwargs)
  57         return res
  58     except Exception:
  59         print(f"Error calling: {filename}/{funcname}", file=sys.stderr)
  60         print(traceback.format_exc(), file=sys.stderr)
  61 
  62     return default
  63 
  64 
  65 def setup_ui(is_img2img):
  66     titles = [wrap_call(script.title, script.filename, "title") or f"{script.filename} [error]" for script in scripts]
  67 
  68     dropdown = gr.Dropdown(label="Script", choices=["None"] + titles, value="None", type="index")
  69 
  70     inputs = [dropdown]
  71 
  72     for script in scripts:
  73         script.args_from = len(inputs)
  74         controls = script.ui(is_img2img)
  75 
  76         for control in controls:
  77             control.visible = False
  78 
  79         inputs += controls
  80         script.args_to = len(inputs)
  81 
  82     def select_script(index):
  83         if index > 0:
  84             script = scripts[index-1]
  85             args_from = script.args_from
  86             args_to = script.args_to
  87         else:
  88             args_from = 0
  89             args_to = 0
  90 
  91         return [ui.gr_show(True if i == 0 else args_from <= i < args_to) for i in range(len(inputs))]
  92 
  93     dropdown.change(
  94         fn=select_script,
  95         inputs=[dropdown],
  96         outputs=inputs
  97     )
  98 
  99     return inputs
  100 
  101 
  102 def run(p: StableDiffusionProcessing, *args):
  103     script_index = args[0] - 1
  104 
  105     if script_index < 0 or script_index >= len(scripts):
  106         return None
  107 
  108     script = scripts[script_index]
  109 
  110     script_args = args[script.args_from:script.args_to]
  111     processed = script.run(p, *script_args)
  112 
  113     return processed
  114
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/modules/scripts.py b/modules/scripts.py
  --- a/modules/scripts.py
  +++ b/modules/scripts.py
  @@ -29,6 +29,9 @@
   
   
   def load_scripts(basedir):
  +    if not os.path.exists(basedir):
  +        return
  +
       for filename in os.listdir(basedir):
           path = os.path.join(basedir, filename)
  
verification_info: {"golden_diff": "diff --git a/modules/scripts.py b/modules/scripts.py\n--- a/modules/scripts.py\n+++ b/modules/scripts.py\n@@ -29,6 +29,9 @@\n \r\n \r\n def load_scripts(basedir):\r\n+    if not os.path.exists(basedir):\r\n+        return\r\n+\r\n     for filename in os.listdir(basedir):\r\n         path = os.path.join(basedir, filename)\n", "issue": "FileNotFoundError after new update\nGetting a FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\\\Users\\\\admin\\\\stable-diffusion-webui\\\\scripts' after the new update. \r\n\r\nNot exactly good at all the coding stuff, using it just fine yesterday but I downloaded the repo instead of git clone, for the sake of easier update I started a new installation by git cloning into user folder and the installation went well but ran into this while launching through webui.py.\r\n\r\nPython 3.10.6\r\nvenv C:\\Users\\admin\\stable-diffusion-webui\\venv\\Scripts\\Python.exe\r\nLaunching webui.py...\r\nLoading model from C:\\Users\\admin\\stable-diffusion-webui\\model.ckpt\r\nGlobal Step: 470000\r\nLatentDiffusion: Running in eps-prediction mode\r\nDiffusionWrapper has 859.52 M params.\r\nmaking attention of type 'vanilla' with 512 in_channels\r\nWorking with z of shape (1, 4, 32, 32) = 4096 dimensions.\r\nmaking attention of type 'vanilla' with 512 in_channels\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\admin\\stable-diffusion-webui\\webui.py\", line 135, in <module>\r\n    modules.scripts.load_scripts(os.path.join(script_path, \"scripts\"))\r\n  File \"C:\\Users\\admin\\stable-diffusion-webui\\modules\\scripts.py\", line 32, in load_scripts\r\n    for filename in os.listdir(basedir):\r\nFileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\\\Users\\\\admin\\\\stable-diffusion-webui\\\\scripts'\n", "before_files": [{"content": "import os\r\nimport sys\r\nimport traceback\r\n\r\nimport modules.ui as ui\r\nimport gradio as gr\r\n\r\nfrom modules.processing import StableDiffusionProcessing\r\n\r\nclass Script:\r\n    filename = None\r\n    args_from = None\r\n    args_to = None\r\n\r\n    def title(self):\r\n        raise NotImplementedError()\r\n\r\n    def ui(self, is_img2img):\r\n        pass\r\n\r\n    def run(self, *args):\r\n        raise NotImplementedError()\r\n\r\n    def describe(self):\r\n        return \"\"\r\n\r\n\r\nscripts = []\r\n\r\n\r\ndef load_scripts(basedir):\r\n    for filename in os.listdir(basedir):\r\n        path = os.path.join(basedir, filename)\r\n\r\n        if not os.path.isfile(path):\r\n            continue\r\n\r\n        with open(path, \"r\", encoding=\"utf8\") as file:\r\n            text = file.read()\r\n\r\n        from types import ModuleType\r\n        compiled = compile(text, path, 'exec')\r\n        module = ModuleType(filename)\r\n        exec(compiled, module.__dict__)\r\n\r\n        for key, script_class in module.__dict__.items():\r\n            if type(script_class) == type and issubclass(script_class, Script):\r\n                obj = script_class()\r\n                obj.filename = path\r\n\r\n                scripts.append(obj)\r\n\r\n\r\ndef wrap_call(func, filename, funcname, *args, default=None, **kwargs):\r\n    try:\r\n        res = func(*args, **kwargs)\r\n        return res\r\n    except Exception:\r\n        print(f\"Error calling: {filename}/{funcname}\", file=sys.stderr)\r\n        print(traceback.format_exc(), file=sys.stderr)\r\n\r\n    return default\r\n\r\n\r\ndef setup_ui(is_img2img):\r\n    titles = [wrap_call(script.title, script.filename, \"title\") or f\"{script.filename} [error]\" for script in scripts]\r\n\r\n    dropdown = gr.Dropdown(label=\"Script\", choices=[\"None\"] + titles, value=\"None\", type=\"index\")\r\n\r\n    inputs = [dropdown]\r\n\r\n    for script in scripts:\r\n        script.args_from = len(inputs)\r\n        controls = script.ui(is_img2img)\r\n\r\n        for control in controls:\r\n            control.visible = False\r\n\r\n        inputs += controls\r\n        script.args_to = len(inputs)\r\n\r\n    def select_script(index):\r\n        if index > 0:\r\n            script = scripts[index-1]\r\n            args_from = script.args_from\r\n            args_to = script.args_to\r\n        else:\r\n            args_from = 0\r\n            args_to = 0\r\n\r\n        return [ui.gr_show(True if i == 0 else args_from <= i < args_to) for i in range(len(inputs))]\r\n\r\n    dropdown.change(\r\n        fn=select_script,\r\n        inputs=[dropdown],\r\n        outputs=inputs\r\n    )\r\n\r\n    return inputs\r\n\r\n\r\ndef run(p: StableDiffusionProcessing, *args):\r\n    script_index = args[0] - 1\r\n\r\n    if script_index < 0 or script_index >= len(scripts):\r\n        return None\r\n\r\n    script = scripts[script_index]\r\n\r\n    script_args = args[script.args_from:script.args_to]\r\n    processed = script.run(p, *script_args)\r\n\r\n    return processed\r\n", "path": "modules/scripts.py"}], "after_files": [{"content": "import os\r\nimport sys\r\nimport traceback\r\n\r\nimport modules.ui as ui\r\nimport gradio as gr\r\n\r\nfrom modules.processing import StableDiffusionProcessing\r\n\r\nclass Script:\r\n    filename = None\r\n    args_from = None\r\n    args_to = None\r\n\r\n    def title(self):\r\n        raise NotImplementedError()\r\n\r\n    def ui(self, is_img2img):\r\n        pass\r\n\r\n    def run(self, *args):\r\n        raise NotImplementedError()\r\n\r\n    def describe(self):\r\n        return \"\"\r\n\r\n\r\nscripts = []\r\n\r\n\r\ndef load_scripts(basedir):\r\n    if not os.path.exists(basedir):\r\n        return\r\n\r\n    for filename in os.listdir(basedir):\r\n        path = os.path.join(basedir, filename)\r\n\r\n        if not os.path.isfile(path):\r\n            continue\r\n\r\n        with open(path, \"r\", encoding=\"utf8\") as file:\r\n            text = file.read()\r\n\r\n        from types import ModuleType\r\n        compiled = compile(text, path, 'exec')\r\n        module = ModuleType(filename)\r\n        exec(compiled, module.__dict__)\r\n\r\n        for key, script_class in module.__dict__.items():\r\n            if type(script_class) == type and issubclass(script_class, Script):\r\n                obj = script_class()\r\n                obj.filename = path\r\n\r\n                scripts.append(obj)\r\n\r\n\r\ndef wrap_call(func, filename, funcname, *args, default=None, **kwargs):\r\n    try:\r\n        res = func(*args, **kwargs)\r\n        return res\r\n    except Exception:\r\n        print(f\"Error calling: {filename}/{funcname}\", file=sys.stderr)\r\n        print(traceback.format_exc(), file=sys.stderr)\r\n\r\n    return default\r\n\r\n\r\ndef setup_ui(is_img2img):\r\n    titles = [wrap_call(script.title, script.filename, \"title\") or f\"{script.filename} [error]\" for script in scripts]\r\n\r\n    dropdown = gr.Dropdown(label=\"Script\", choices=[\"None\"] + titles, value=\"None\", type=\"index\")\r\n\r\n    inputs = [dropdown]\r\n\r\n    for script in scripts:\r\n        script.args_from = len(inputs)\r\n        controls = script.ui(is_img2img)\r\n\r\n        for control in controls:\r\n            control.visible = False\r\n\r\n        inputs += controls\r\n        script.args_to = len(inputs)\r\n\r\n    def select_script(index):\r\n        if index > 0:\r\n            script = scripts[index-1]\r\n            args_from = script.args_from\r\n            args_to = script.args_to\r\n        else:\r\n            args_from = 0\r\n            args_to = 0\r\n\r\n        return [ui.gr_show(True if i == 0 else args_from <= i < args_to) for i in range(len(inputs))]\r\n\r\n    dropdown.change(\r\n        fn=select_script,\r\n        inputs=[dropdown],\r\n        outputs=inputs\r\n    )\r\n\r\n    return inputs\r\n\r\n\r\ndef run(p: StableDiffusionProcessing, *args):\r\n    script_index = args[0] - 1\r\n\r\n    if script_index < 0 or script_index >= len(scripts):\r\n        return None\r\n\r\n    script = scripts[script_index]\r\n\r\n    script_args = args[script.args_from:script.args_to]\r\n    processed = script.run(p, *script_args)\r\n\r\n    return processed\r\n", "path": "modules/scripts.py"}]}