TheLastBen / fast-stable-diffusion

fast-stable-diffusion + DreamBooth
MIT License
7.49k stars 1.31k forks source link

ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/usr/local/lib/python3.10/dist-packages/pydantic/fields.py) #2468

Open Jboby1 opened 1 year ago

Jboby1 commented 1 year ago

Traceback (most recent call last): File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 14, in from fastapi import FastAPI File "/usr/local/lib/python3.10/dist-packages/fastapi/init.py", line 7, in from .applications import FastAPI as FastAPI File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 15, in from fastapi import routing File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 21, in from fastapi import params File "/usr/local/lib/python3.10/dist-packages/fastapi/params.py", line 4, in from pydantic.fields import FieldInfo, Undefined ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/usr/local/lib/python3.10/dist-packages/pydantic/fields.py)

I'm still using the Collab, as everything was still working fine up until today. Tried a fresh install, but that didn't remove the error.

megagarra commented 1 year ago

too

mcqx4 commented 1 year ago

Same thing, last cell in Google Collab

Traceback (most recent call last): File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 14, in from fastapi import FastAPI File "/usr/local/lib/python3.10/dist-packages/fastapi/init.py", line 7, in from .applications import FastAPI as FastAPI File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 15, in from fastapi import routing File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 21, in from fastapi import params File "/usr/local/lib/python3.10/dist-packages/fastapi/params.py", line 4, in from pydantic.fields import FieldInfo, Undefined ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/usr/local/lib/python3.10/dist-packages/pydantic/fields.py)

megagarra commented 1 year ago

maybe need pydantic

Agidynae commented 1 year ago

Same here. It was working about a half hour ago. Now, it is returning this error too. I'm a Colab Pro user, btw.

Argentum2491 commented 1 year ago

Running into the same exact issue everyone here is reporting! Things were working last night, now they are no longer working, showing the same Pydantic error. Fresh install didn't change anything - something up with Pydantic?

TheLastBen commented 1 year ago

fixed, update to the latest notebook

hellopersonality commented 1 year ago

yep that fixed it for me, thank you!

shuhei-fujita commented 1 year ago

🤔 https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/12392

shuhei-fujita commented 1 year ago

@Jboby1 @mcqx4

pip install pydantic==1.10.11

or Latest version of 1.x series

pip install pydantic==1.8.2

I solved it this way 👌

TheLastBen commented 1 year ago

Just use the latest notebook

DohkoKlaus commented 1 year ago

Basta usar o notebook mais recente

I'm having the same problem for hours now with my google colab, the code just stops and gets stuck on that last line:

Installing pycloudflared

Launching Web UI with arguments: --share --disable-safe-unpickle --no-half-vae --xformers --enable-insecure-extension --gradio-queue 2023-08-12 00:24:09.592789: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-08-12 00:24:10.690399: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT Additional Network extension not installed, Only hijack built-in lora LoCon Extension hijack built-in lora successfully ** Error loading script: api.py Traceback (most recent call last): File "/content/microsoftexcel/modules/scripts.py", line 319, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/content/microsoftexcel/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/api.py", line 8, in from modules.api.models import File "/content/microsoftexcel/modules/api/models.py", line 112, in ).generate_model() File "/content/microsoftexcel/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_model_construction.py", line 205, in getattr raise AttributeError(item) AttributeError: config


** Error loading script: batch_hijack.py Traceback (most recent call last): File "/content/microsoftexcel/modules/scripts.py", line 319, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/content/microsoftexcel/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/batch_hijack.py", line 7, in from scripts import external_code File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/external_code.py", line 1, in from internal_controlnet.external_code import File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/internal_controlnet/external_code.py", line 9, in from modules.api import api File "/content/microsoftexcel/modules/api/api.py", line 19, in from modules.api import models File "/content/microsoftexcel/modules/api/models.py", line 112, in ).generate_model() File "/content/microsoftexcel/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_model_construction.py", line 205, in getattr raise AttributeError(item) AttributeError: config


** Error loading script: controlnet.py Traceback (most recent call last): File "/content/microsoftexcel/modules/scripts.py", line 319, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/content/microsoftexcel/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/controlnet.py", line 13, in from scripts import global_state, hook, external_code, processor, batch_hijack, controlnet_version, utils File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/external_code.py", line 1, in from internal_controlnet.external_code import File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/internal_controlnet/external_code.py", line 9, in from modules.api import api File "/content/microsoftexcel/modules/api/api.py", line 19, in from modules.api import models File "/content/microsoftexcel/modules/api/models.py", line 112, in ).generate_model() File "/content/microsoftexcel/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_model_construction.py", line 205, in getattr raise AttributeError(item) AttributeError: config


2023-08-12 00:24:21,667 - ControlNet - INFO - ControlNet v1.1.237 ** Error loading script: external_code.py Traceback (most recent call last): File "/content/microsoftexcel/modules/scripts.py", line 319, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/content/microsoftexcel/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/external_code.py", line 1, in from internal_controlnet.external_code import File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/internal_controlnet/external_code.py", line 9, in from modules.api import api File "/content/microsoftexcel/modules/api/api.py", line 19, in from modules.api import models File "/content/microsoftexcel/modules/api/models.py", line 112, in ).generate_model() File "/content/microsoftexcel/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_model_construction.py", line 205, in getattr raise AttributeError(item) AttributeError: config


** Error loading script: xyz_grid_support.py Traceback (most recent call last): File "/content/microsoftexcel/modules/scripts.py", line 319, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/content/microsoftexcel/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/xyz_grid_support.py", line 8, in from scripts.external_code import ResizeMode, ControlMode File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/scripts/external_code.py", line 1, in from internal_controlnet.external_code import File "/content/microsoftexcel/extensions/microsoftexcel-controlnet/internal_controlnet/external_code.py", line 9, in from modules.api import api File "/content/microsoftexcel/modules/api/api.py", line 19, in from modules.api import models File "/content/microsoftexcel/modules/api/models.py", line 112, in ).generate_model() File "/content/microsoftexcel/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_model_construction.py", line 205, in getattr raise AttributeError(item) AttributeError: config


Calculating sha256 for /content/microsoftexcel/models/Stable-diffusion/chilloutmixni.safetensors: Traceback (most recent call last): File "/content/microsoftexcel/launch.py", line 39, in main() File "/content/microsoftexcel/launch.py", line 35, in main start() File "/content/microsoftexcel/modules/launch_utils.py", line 394, in start webui.webui() File "/content/microsoftexcel/webui.py", line 393, in webui shared.demo = modules.ui.create_ui() File "/content/microsoftexcel/modules/ui.py", line 504, in create_ui modules.scripts.scripts_txt2img.setup_ui_for_section(category) File "/content/microsoftexcel/modules/scripts.py", line 433, in setup_ui_for_section self.create_script_ui(script) File "/content/microsoftexcel/modules/scripts.py", line 383, in create_script_ui import modules.api.models as api_models File "/content/microsoftexcel/modules/api/models.py", line 112, in ).generate_model() File "/content/microsoftexcel/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/usr/local/lib/python3.10/dist-packages/pydantic/_internal/_model_construction.py", line 205, in getattr raise AttributeError(item) AttributeError: config fc2511737a54c5e80b89ab03e0ab4b98d051ab187f92860f3cd664dc9d08b271 Loading weights [fc2511737a] from /content/microsoftexcel/models/Stable-diffusion/chilloutmixni.safetensors Creating model from config: /content/microsoftexcel/configs/v1-inference.yaml LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. Downloading (…)olve/main/vocab.json: 100% 961k/961k [00:00<00:00, 1.14MB/s] Downloading (…)olve/main/merges.txt: 100% 525k/525k [00:00<00:00, 49.8MB/s] Downloading (…)cial_tokens_map.json: 100% 389/389 [00:00<00:00, 1.24MB/s] Downloading (…)okenizer_config.json: 100% 905/905 [00:00<00:00, 4.97MB/s] Downloading (…)lve/main/config.json: 100% 4.52k/4.52k [00:00<00:00, 19.2MB/s] Applying attention optimization: xformers... done. Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/charturnerv2.pt: a91b570185766ff71f242f83d5beb6d658348900edb706a2092ba23d6e1e2cf8 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad-picture-chill-75v.pt: 7d9cc5f549d7972f24803a3a9880a923fb9a1b68c1443da3ce1ff2f7eff25ae9 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad_prompt.pt: f9dfe1c982e2a1917054fa827ee1f981c6e6102984f981c691e4f8c817e292cb Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/ulzzang-6500.pt: 66d481a222ee4638e254a411890f2a8716e4ce5c3e1b1957891c7628bbdeac78 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad-artist.pt: 2d356134903e8f47bf6cf519bdf577cdcee42fc717ef264498162e94f130843a Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/pureerosface_v1.pt: dedb4322e42e360fe01775ba817be03ac6a6c307744562bb0d6759368bc681da Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad-image-v2-39000.pt: 5b9281d7c6adc221b8ea9067b678f4b6ff4cc94735e2d50885070380d5496037 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/21charturnerv2.pt: f253abb016c22dd426d6e482f4f8c3960766de6e4c02f151478bfb98f6985383 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/ng_deepnegative_v1_75t.pt: 54e7e4826d53949a3d0dde40aea023b1e456a618c608a7630e3999fd38f93245 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/epiCNegative.pt: 88b8f468357be0d90b993b6b5b4763b603244089b426f40fddcf96b070002f38 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad-hands-5.pt: aa7651be154c46a2f4868788ef84a92b3083b0c0c5c46f5012a56698bfd2a1ba Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/negative_hand-neg.pt: 73b524a2da121eb1b7ad04dea11da286277813120700ff8f1d8522516f7b30ab Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/nfixer.pt: aa5a14f467a8cb8660e92e97ca647ab90ef3aa00dc6da842ab735170347f78c7 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/Asian-Less-Neg.pt: 22d2f003e76f94dcf891b821a3f447f25c73b2e0542f089427b33ff344070a96 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/EasyNegativeV2.safetensors: 339cc9210f70ef842b716588373d95b52351d7e6d111b858e133e3b1e3bd8088 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/UnrealisticDream.pt: a77451e7ea075c7f72d488d2b740b3d3970c671c0ac39dd3155f3c3b129df959 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/rmadanegative402_sd15-neg.pt: ad488e18aa29f12e8fc18d1d2ccc041ff0052d4657c96f1b06cab880f4ba4f40 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad_pictures.pt: 522ac70ba997df4a911e4977e6a9790e7d15236596e8e0c8318330f2af4ab095 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/nartfixer.pt: a0504f05844290ac4d2de41d0338fb642548fb18efd8c6de7bb571ab1d60af89 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/nrealfixer.pt: d1193a5ecddb3b5b052f5efb1a74062dcd130a4060884eed439a605b9731c0ad Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/epiCRealism.pt: 3719288307e4183d01f3aa7737ce952d15fc9e21da13fa0ecea1be4e8c166b10 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/BadDream.pt: 758aac44351557ccfae2fc6bdf3a29670464e4e4eabb61f08c5b8531c221649c Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/FastNegativeEmbedding.pt: 687b669d8234a418005ca9bfda93464b1721285b0a6a8d92490df0f02124ab7c Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/HyperStylizeV6.pt: a09539451c9161038c9ac0a322ad8ffafffb097a70874b65e31eb06f0bb2e412 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/CyberRealistic_Negative-neg.pt: 65f3ea567c04c22f92024c5b55cbeca580bc330c4290aeb647ebd86273b3ffb8 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad_prompt_version2.pt: 6f35e7dd816ae04bb3f774a9a17ebfbc50c0e3a53f69a9a40bed05936d3a3812 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/easynegative.safetensors: c74b4e810b030f6b75fde959e2db678c268d07115b85356d3c0138ba5eb42340 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/ulzzang-6500-v1.1.bin: 8c1af299c7e8c2283892a7ad61a5fe5574e88c9c2ee77cd0cdfc0615155fa315 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/badhandv4.pt: 5e40d722fc3d0c2decb62debfaf8058db30ccdae9ab00ff64b183907b435708e Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/verybadimagenegative_v1.3.pt: d70463f87042e2b5951c303542f3e171cf49af9b7df53b2f20779493786eb143 Calculating sha256 for /content/microsoftexcel/embeddings/embeddings/bad-artist-anime.pt: 5f7bea88750c97a0b8c9ba9f5bc0d13648c3a17a69aaac855903229d5f58c34b Model loaded in 41.8s (calculate hash: 26.6s, load weights from disk: 0.6s, create model: 5.2s, apply weights to model: 5.1s, apply half(): 1.7s, move model to device: 1.8s, load textual inversion embeddings: 0.2s, calculate empty prompt: 0.5s).

shuhei-fujita commented 1 year ago

@DohkoKlaus Just use the latest notebook 😄 This commit seems to have resolved the issue.

https://github.com/TheLastBen/fast-stable-diffusion/commit/29b93fe5177246da92bab813e38c6044c36c8e89

darixsamani commented 11 months ago

i have this error with pydantic in virtual env

File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/darix/.local/lib/python3.9/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started target(sockets=sockets) File "/home/darix/.local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete File "/home/darix/.local/lib/python3.9/site-packages/uvicorn/server.py", line 67, in serve config.load() File "/home/darix/.local/lib/python3.9/site-packages/uvicorn/config.py", line 477, in load self.loaded_app = import_from_string(self.app) File "/home/darix/.local/lib/python3.9/site-packages/uvicorn/importer.py", line 24, in import_from_string raise exc from None File "/home/darix/.local/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string module = importlib.import_module(module_str) File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 855, in exec_module File "", line 228, in _call_with_frames_removed File "/home/darix/Documents/fastapi-microservice/./orders/app.py", line 1, in from fastapi import FastAPI File "/home/darix/.local/lib/python3.9/site-packages/fastapi/init.py", line 7, in from .applications import FastAPI as FastAPI File "/home/darix/.local/lib/python3.9/site-packages/fastapi/applications.py", line 15, in from fastapi import routing File "/home/darix/.local/lib/python3.9/site-packages/fastapi/routing.py", line 22, in from fastapi import params File "/home/darix/.local/lib/python3.9/site-packages/fastapi/params.py", line 4, in from pydantic.fields import FieldInfo, Undefined ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/home/darix/.local/lib/python3.9/site-packages/pydantic/fields.py)

newbiebunchu commented 5 months ago

@Jboby1 @mcqx4

pip install pydantic==1.10.11

or Latest version of 1.x series

pip install pydantic==1.8.2

I solved it this way 👌

this error happens after installed the controlnet extension, and this method cannot fix it for me, do you have any suggestion?

PhantomBeast3 commented 5 months ago

@Jboby1 @mcqx4

pip install pydantic==1.10.11

or Latest version of 1.x series

pip install pydantic==1.8.2

I solved it this way 👌

this error happens after installed the controlnet extension, and this method cannot fix it for me, do you have any suggestion?

same, I am also getting this error after installing control net in automatic 1111, any help is appreciated

WillsyNZ commented 5 months ago

Hi guys, sorry in advance, I'm very much a noob to all this, is there a simple fix for this? I've spent hours trying fix this for this error:

ImportError: cannot import name 'Undefined' from 'pydantic.fields'

I've tried the fix above, and many other fixes involving modifying the 'requirements.txt' file, replacing the 'webui.py' file with fixed version, and I'm still banging my head against a wall with this error.

Can someone please advise what I might be missing? I have A1111 installed, and it works fine. Forge on the otherhand doesn't.

Cheers Mark

Raynor07 commented 5 months ago

ImportError: cannot import name 'Undefined' from 'pydantic.fields'

I've tried the fix above, and many other fixes involving modifying the 'requirements.txt' file, replacing the 'webui.py' file with fixed version, and I'm still banging my head against a wall with this error.

Can someone please advise what I might be missing? I have A1111 installed, and it works fine. Forge on the otherhand doesn't.

I'm having the exact same issue anytime I try to open Forge. Likewise, A1111 works fine.

alpha-wavelet commented 3 months ago

This worked for me...

C:\ABSOLUTE_PATH_TO_INSTALLATION_ROOT\venv\Scripts\pip install fastapi==0.111.0