deforum-art / sd-webui-deforum

Deforum extension for AUTOMATIC1111's Stable Diffusion webui
https://deforum.github.io
Other
2.7k stars 390 forks source link

[Bug]: Cannot locate py3d_tools module when started with --nowebui parameter #831

Closed nberktumer closed 1 year ago

nberktumer commented 1 year ago

Have you read the latest version of the FAQ?

Is there an existing issue for this?

Are you using the latest version of the Deforum extension?

What happened?

I tried running deforum using the API endpoints with no webui. However, when I send a job to deforum_api/batches endpoint, I get the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_api.py", line 81, in run_deforum_batch
    run_deforum(*run_deforum_args)
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/run_deforum.py", line 82, in run_deforum
    from .render import render_animation
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/render.py", line 12, in <module>
    from .noise import add_noise
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/noise.py", line 6, in <module>
    from .animation import sample_to_cv2
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/animation.py", line 3, in <module>
    import py3d_tools as p3d # this is actually a file in our /src folder!
ModuleNotFoundError: No module named 'py3d_tools'

This exception only occurs when I start the webui launcher with--nowebui parameter.

Steps to reproduce the problem

  1. Start AUTOMATIC1111 with --nowebui parameter:
    • python launch.py --no-prepare --api --deforum-api --nowebui --listen --no-hashing --device-id 0 --port 7860 --opt-sdp-no-mem-attention
  2. Start any deforum job by sending a POST request to deforum_api/batches endpoint.

What should have happened/how would you fix it?

deforum_sys_extend() function is only called for the WebUI process and it is not called for the Deforum API processes. Hence, API processes cannot locate py3d_tools modules.

This function should also have been called during FastAPI initialization.

Torch version

2.0.1+cu117

On which platform are you launching the webui with the extension?

Local PC setup (Linux), Cloud server (Linux)

Deforum settings

https://gist.github.com/nberktumer/d169dae0f0dc538a73f22e74a1f0c19e

Webui core settings

https://gist.github.com/nberktumer/5660a9bcb5064ca6dd27d90b1421cf7a

Console logs

Launching Web UI with arguments: --no-prepare --api --deforum-api --nowebui --listen --no-hashing --device-id 0 --port 7860 --opt-sdp-no-mem-attention --model-lru-cache-size 20
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
2023-08-08 09:24:21,953 - ControlNet - INFO - ControlNet v1.1.234
ControlNet preprocessor location: /home/ubuntu/app/extensions/sd-webui-controlnet/annotator/downloads
2023-08-08 09:24:22,172 - ControlNet - INFO - ControlNet v1.1.234
Loading weights [None] from /home/ubuntu/app/models/Stable-diffusion/SD_1.5.ckpt
Startup time: 17.6s (start: 0.3s, launcher: 4.7s, import torch: 4.7s, setup paths: 1.5s, other imports: 4.3s, setup codeformer: 0.1s, load scripts: 1.8s, launch.py: 0.1s).
INFO:     Started server process [5556]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
Creating model from config: /home/ubuntu/app/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, 4.48MB/s]
Downloading (…)olve/main/merges.txt: 100%|███| 525k/525k [00:00<00:00, 3.69MB/s]
Downloading (…)cial_tokens_map.json: 100%|█████| 389/389 [00:00<00:00, 2.53MB/s]
Downloading (…)okenizer_config.json: 100%|█████| 905/905 [00:00<00:00, 4.33MB/s]
Downloading (…)lve/main/config.json: 100%|█| 4.52k/4.52k [00:00<00:00, 24.9MB/s]
Applying attention optimization: sdp-no-mem... done.
Model loaded in 5.1s (load weights from disk: 1.3s, create model: 2.0s, apply weights to model: 1.0s, apply half(): 0.3s, move model to device: 0.3s).
INFO:     188.119.40.33:24561 - "GET /docs HTTP/1.1" 200 OK
INFO:     188.119.40.33:24561 - "GET /openapi.json HTTP/1.1" 200 OK
2023-08-08 09:27:46 INFO [deforum_api] Starting batch batch(162391475) in thread 139991611074112.
INFO:     188.119.40.33:24561 - "POST /deforum_api/batches HTTP/1.1" 202 Accepted
*Deforum ControlNet support: enabled*
started run_deforum
times_to_run: 1
Deforum extension for auto1111 webui
Git commit: ff0680bb
Starting job batch(162391475)-0...
reading custom settings from /tmp/tmpx6shdjvv
namespace(W=512, H=512, show_info_on_ui=True, tiling=False, restore_faces=False, seed_resize_from_w=0, seed_resize_from_h=0, seed=1, sampler='Euler a', steps=1, batch_name='Deforum_{timestring}', seed_behavior='iter', seed_iter_N=1, use_init=False, strength=0.8, strength_0_no_init=True, init_image='None', use_mask=False, use_alpha_as_mask=False, mask_file='', invert_mask=False, mask_contrast_adjust=1.0, mask_brightness_adjust=1.0, overlay_mask=True, mask_overlay_blur=4, fill=1, full_res_mask=True, full_res_mask_padding=4, reroll_blank_frames='ignore', reroll_patience=10.0) namespace(animation_mode='2D', max_frames=5, border='replicate', angle='0:(0)', zoom='0:(1.0025+0.002*sin(1.25*3.14*t/30))', translation_x='0:(0)', translation_y='0:(0)', translation_z='0:(0)', transform_center_x='0:(0.5)', transform_center_y='0:(0.5)', rotation_3d_x='0:(0)', rotation_3d_y='0:(0)', rotation_3d_z='0:(0)', enable_perspective_flip=False, perspective_flip_theta='0:(0)', perspective_flip_phi='0:(0)', perspective_flip_gamma='0:(0)', perspective_flip_fv='0:(53)', noise_schedule='0: (0.04)', strength_schedule='0: (0.65)', contrast_schedule='0: (1.0)', cfg_scale_schedule='0: (7)', enable_steps_scheduling=False, steps_schedule='0: (25)', fov_schedule='0: (70)', aspect_ratio_schedule='0: (1)', aspect_ratio_use_old_formula=False, near_schedule='0: (200)', far_schedule='0: (10000)', seed_schedule='0:(s), 1:(-1), "max_f-2":(-1), "max_f-1":(s)', pix2pix_img_cfg_scale_schedule='0:(1.5)', enable_subseed_scheduling=False, subseed_schedule='0:(1)', subseed_strength_schedule='0:(0)', enable_sampler_scheduling=False, sampler_schedule='0: ("Euler a")', use_noise_mask=False, mask_schedule='0: ("{video_mask}")', noise_mask_schedule='0: ("{video_mask}")', enable_checkpoint_scheduling=False, checkpoint_schedule='0: ("model1.ckpt"), 100: ("model2.safetensors")', enable_clipskip_scheduling=False, clipskip_schedule='0: (2)', enable_noise_multiplier_scheduling=False, noise_multiplier_schedule='0: (1.05)', resume_from_timestring=False, resume_timestring='20230707221541', enable_ddim_eta_scheduling=False, ddim_eta_schedule='0: (0)', enable_ancestral_eta_scheduling=False, ancestral_eta_schedule='0: (1)', amount_schedule='0: (0.05)', kernel_schedule='0: (5)', sigma_schedule='0: (1.0)', threshold_schedule='0: (0.0)', color_coherence='LAB', color_coherence_image_path='', color_coherence_video_every_N_frames=1, color_force_grayscale=False, legacy_colormatch=False, diffusion_cadence=1, optical_flow_cadence='None', cadence_flow_factor_schedule='0: (1)', optical_flow_redo_generation='None', redo_flow_factor_schedule='0: (1)', diffusion_redo=0, noise_type='perlin', perlin_w=8, perlin_h=8, perlin_octaves=4, perlin_persistence=0.5, use_depth_warping=True, depth_algorithm='Zoe', midas_weight=0.4, padding_mode='reflection', sampling_mode='bicubic', save_depth_maps=False, video_init_path='', extract_nth_frame=1, extract_from_frame=0, extract_to_frame=-1, overwrite_extracted_frames=False, use_mask_video=False, video_mask_path='', hybrid_comp_alpha_schedule='0:(0.5)', hybrid_comp_mask_blend_alpha_schedule='0:(0.5)', hybrid_comp_mask_contrast_schedule='0:(1)', hybrid_comp_mask_auto_contrast_cutoff_high_schedule='0:(100)', hybrid_comp_mask_auto_contrast_cutoff_low_schedule='0:(0)', hybrid_flow_factor_schedule='0:(1)', hybrid_generate_inputframes=False, hybrid_generate_human_masks='None', hybrid_use_first_frame_as_init_image=True, hybrid_motion='None', hybrid_motion_use_prev_img=False, hybrid_flow_consistency=False, hybrid_consistency_blur=2, hybrid_flow_method='RAFT', hybrid_composite='None', hybrid_use_init_image=False, hybrid_comp_mask_type='None', hybrid_comp_mask_inverse=False, hybrid_comp_mask_equalize='None', hybrid_comp_mask_auto_contrast=True, hybrid_comp_save_extra_frames=False) namespace(parseq_manifest='', parseq_use_deltas=True) namespace(use_looper=False, init_images='{\n    "0": "https://deforum.github.io/a1/Gi1.png",\n    "max_f/4-5": "https://deforum.github.io/a1/Gi2.png",\n    "max_f/2-10": "https://deforum.github.io/a1/Gi3.png",\n    "3*max_f/4-15": "https://deforum.github.io/a1/Gi4.jpg",\n    "max_f-20": "https://deforum.github.io/a1/Gi1.png"\n}', image_strength_schedule='0:(0.75)', blendFactorMax='0:(0.35)', blendFactorSlope='0:(0.25)', tweening_frames_schedule='0:(20)', color_correction_factor='0:(0.075)')
2023-08-08 09:27:47 WARNING [deforum_api] Error during batch execution: <class 'ModuleNotFoundError'> - No module named 'py3d_tools'
2023-08-08 09:27:47 ERROR [deforum_api] Batch batch(162391475) failed: No module named 'py3d_tools'
Traceback (most recent call last):
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_api.py", line 81, in run_deforum_batch
    run_deforum(*run_deforum_args)
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/run_deforum.py", line 82, in run_deforum
    from .render import render_animation
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/render.py", line 12, in <module>
    from .noise import add_noise
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/noise.py", line 6, in <module>
    from .animation import sample_to_cv2
  File "/home/ubuntu/app/extensions/deforum/scripts/deforum_helpers/animation.py", line 3, in <module>
    import py3d_tools as p3d # this is actually a file in our /src folder!
ModuleNotFoundError: No module named 'py3d_tools'

Additional information

No response

github-actions[bot] commented 1 year ago

This issue has been closed due to incorrect formatting. Please address the following mistakes and reopen the issue (click on the 'Reopen' button below):