ArtVentureX / sd-webui-agent-scheduler

629 stars 66 forks source link

Enqueue Does Nothing #59

Closed Vendaciousness closed 1 year ago

Vendaciousness commented 1 year ago

I added the extension, the closed Auto1111 (not Vlad's) and restarted it. The Enqueue button showed up, so I started changing settings and clicking 'Enqueue' instead of generate and after about 12-15 different jobs, I went to the Agent Scheduler tabs and it was completely blank.

Clicking "refresh' does nothing. The preview window works, as does the ETA progress bar.

image

I'm assuming your extension doesn't work with some other extension I always use, like roop, although I don't see why an extension like this would have problems just saving the job that would otherwise be sent to SD, regardless of the extensions used, but I'm no programmer.

Versions: version: v1.2.1  •  python: 3.10.9  •  torch: 2.0.0+cu118  •  xformers: 0.0.17  •  gradio: 3.32.0  •  checkpoint: 1b0dc651e8

Extensions: image

artventuredev commented 1 year ago

@Vendaciousness Have you check the Task History tab? The Task Queue tab is only for pending tasks, those that are completed are in the history tab.

By default the extension processes the task right after it's queued. You can check the Disable Queue Auto-Processing checkbox in Settings -> Agent Scheduler to stop auto processing.

medledan commented 1 year ago

I was having the same issue. Task Queue was empty. However, after installation I restarted my aitomatic1111 and it worked.

Vendaciousness commented 1 year ago

@artventuredev They were both empty. I should've known there was an issue when it didn't immediately start the jobs, but I was thinking it queued them up, then you went to the Agent Scheduler to run them all.

I apologize, I wasn't looking at the CMD window when I clicked the Enqeueue button, or I would have seen there were errors. Here's my Traceback when I hit 'Enqueue' today on a job, going back to when I started the WebUI:

venv "G:\Code\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
Version: v1.4.0
Commit hash: 394ffa7b0a7fff3ec484bcd084e673a8b301ccc8
Installing requirements

Checking roop requirements
Install insightface==0.7.3
Installing sd-webui-roop requirement: insightface==0.7.3
Install onnx==1.14.0
Installing sd-webui-roop requirement: onnx==1.14.0
Install onnxruntime==1.15.0
Installing sd-webui-roop requirement: onnxruntime==1.15.0
Install opencv-python==4.7.0.72
Installing sd-webui-roop requirement: opencv-python==4.7.0.72

Launching Web UI with arguments: --opt-sdp-attention --no-gradio-queue --medvram --xformers --api
Civitai Helper: Get Custom Model Folder
Civitai Helper: Load setting from: G:\Code\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\setting.json
Civitai Helper: No setting file, use default
2023-07-02 17:23:13,201 - ControlNet - INFO - ControlNet v1.1.227
ControlNet preprocessor location: G:\Code\automatic\models
2023-07-02 17:23:13,320 - ControlNet - INFO - ControlNet v1.1.227
2023-07-02 17:23:13,904 - roop - INFO - roop v0.0.2-uncensored
2023-07-02 17:23:13,905 - roop - INFO - roop v0.0.2-uncensored
Loading weights [64a21449d7] from G:\Code\stable-diffusion-webui\models\Stable-diffusion\dreamscapesDragonfireNEWV20_dsDv20.safetensors
*Deforum ControlNet support: enabled*
Loading general settings...
reading custom settings from deforum_settings.txt
Creating model from config: G:\Code\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
[AgentScheduler] Task queue is empty
[AgentScheduler] Registering APIs
Startup time: 12.3s (import torch: 2.8s, import gradio: 1.8s, import ldm: 0.8s, other imports: 1.5s, setup codeformer: 0.1s, load scripts: 3.1s, create ui: 1.1s, gradio launch: 0.7s, app_started_callback: 0.2s).
DiffusionWrapper has 859.52 M params.
preload_extensions_git_metadata for 15 extensions took 2.00s
Applying attention optimization: xformers... done.
Textual inversion embeddings loaded(16): bad_pictures, bad_prompt_version2-neg, easynegative, FastNegativeEmbedding, FastNegativeEmbeddingStrong, logo-with-face-on-shield, negative_hand-neg, Negfeet-neg, poly-hd (1), useembeddingname, verybadimagenegative_v1.3
Model loaded in 21.0s (load weights from disk: 1.3s, create model: 1.3s, apply weights to model: 17.3s, apply half(): 0.8s, calculate empty prompt: 0.2s).
serialize sampler index: 16 as DPM++ 2M Karras
Traceback (most recent call last):
  File "G:\Code\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "G:\Code\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "G:\Code\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "G:\Code\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "G:\Code\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "G:\Code\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "G:\Code\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\scripts\task_scheduler.py", line 210, in f
    task_runner.register_ui_task(
  File "G:\Code\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\task_runner.py", line 211, in register_ui_task
    params = self.__serialize_ui_task_args(is_img2img, *args, checkpoint=checkpoint)
  File "G:\Code\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\task_runner.py", line 120, in __serialize_ui_task_args
    return json.dumps(
  File "C:\Users\Joel_K\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Users\Joel_K\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\Joel_K\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\Joel_K\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Image is not JSON serializable

Sounds like it doesn't like one of my extensions. I tried 'Enqueue' on a job without roop or ControlNet enabled and still got the same error, but I found if I closed the WebUI completely and restarted it, I could run ControlNet jobs, so that's something.

I would love to be able to use this extension to queue up my jobs, but I use roop on everything except Deforum, so I can't. It's too bad things don't work as simply as we'd like. In my mind, making an extension that simply grabs the JSON as it's being sent to SD and queues it up sounds super simple, but I'm sure it's more complicated than that. I also thought the State extension would be able to save the state of your Automatic1111, regardless of what extensions you use, since it's just a JSON and I was wrong about that, as well. I suspect it's similar.

Let me know if there's anything else I can provide.

-V

artventuredev commented 1 year ago

In my mind, making an extension that simply grabs the JSON as it's being sent to SD and queues it up sounds super simple, but I'm sure it's more complicated than that

You are right, the basic idea is to capture the JSON data that is sent to SD and queue it up for later use. However, this is not as simple as it sounds, because not all parameters are JSON serializable. Some parameters may be images, class objects, pandas data frames, or other types of data that cannot be directly converted to JSON. These types of data require special methods of serialization and deserialization to be stored as JSON.

You can try the latest commit, the issue should be fixed.

Vendaciousness commented 1 year ago

That sounds really complicated and I don't envy you guys for having to deal with issues like this.

IT WORKS!!! Sweet! There was no preview for the first job, but it was fine after that.

I've been writing up bugs for months on different SD extensions and no one's ever fixed anything this quickly and with so little fuss. Thank you so much! You're gonna save me a lot of time, something I value over anything else in the world. I hope you have a ko-fi.com account, so I can buy you a coffee!

artventuredev commented 1 year ago

Your comment made my day! Thanks a million for your kind words and the coffee offer - seriously, it means a lot. But honestly, I'm just glad to be able to help you out and make things better.

Cheers!