Repository: stable-diffusion-webui
Issue: [Bug]: Installing controlnet extension breaks WebUI
Labels: bug-report

### Checklist

- [X] The issue exists after disabling all extensions
- [ ] The issue exists on a clean installation of webui
- [X] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [X] The issue exists in the current version of the webui
- [X] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

After installing the extension "sd-webui-controlnet" this error comes up in cmd "ImportError: cannot import name 'Undefined' from 'pydantic.fields' (S:\AI\StableDiffusion\system\python\lib\site-packages\pydantic\fields.py)" and WebUI does not start at all. Deleting controlnet extension in extensions folder does not help. The only thing that helps is deleting the contents of system folder and installing it again via sd.webui.zip and run.bat

### Steps to reproduce the problem

1) Go to Extensions tab in WebUI
2)  Find the extension and press Install
3)  Apply and restart WebUI


### What should have happened?

WebUI should start normally

### What browsers do you use to access the UI ?

Mozilla Firefox

### Sysinfo

[sysinfo-2024-04-17-15-37.json](https://github.com/AUTOMATIC1111/stable-diffusion-webui/files/15013272/sysinfo-2024-04-17-15-37.json)


### Console logs

```Shell
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.9.0
Commit hash: adadb4e3c7382bf3e4f7519126cd6c70f4f8557b
Launching Web UI with arguments: --theme dark --xformers
Traceback (most recent call last):
  File "S:\AI\StableDiffusion\webui\launch.py", line 48, in <module>
    main()
  File "S:\AI\StableDiffusion\webui\launch.py", line 44, in main
    start()
  File "S:\AI\StableDiffusion\webui\modules\launch_utils.py", line 465, in start
    import webui
  File "S:\AI\StableDiffusion\webui\webui.py", line 13, in <module>
    initialize.imports()
  File "S:\AI\StableDiffusion\webui\modules\initialize.py", line 23, in imports
    import gradio  # noqa: F401
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\gradio\__init__.py", line 3, in <module>
    import gradio.components as components
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\gradio\components\__init__.py", line 1, in <module>
    from gradio.components.annotated_image import AnnotatedImage
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\gradio\components\annotated_image.py", line 13, in <module>
    from gradio.components.base import IOComponent, _Keywords
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\gradio\components\base.py", line 20, in <module>
    from fastapi import UploadFile
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\fastapi\__init__.py", line 7, in <module>
    from .applications import FastAPI as FastAPI
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\fastapi\applications.py", line 15, in <module>
    from fastapi import routing
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\fastapi\routing.py", line 22, in <module>
    from fastapi import params
  File "S:\AI\StableDiffusion\system\python\lib\site-packages\fastapi\params.py", line 4, in <module>
    from pydantic.fields import FieldInfo, Undefined
ImportError: cannot import name 'Undefined' from 'pydantic.fields' (S:\AI\StableDiffusion\system\python\lib\site-packages\pydantic\fields.py)
```


### Additional information

_No response_