moving stuff around

This commit is contained in:
saltacc
2024-02-01 10:22:41 -08:00
parent f36070f2c1
commit 135e9ff50c
13 changed files with 86 additions and 110 deletions
+2 -2
View File
@@ -16,6 +16,6 @@
[submodule "animation/rerender-lora/deps/gmflow"]
path = animation/rerender-lora/deps/gmflow
url = https://github.com/haofeixu/gmflow.git
[submodule "image_generation/ComfyUI"]
path = image_generation/ComfyUI
[submodule "workflows/comfy/ComfyUI"]
path = workflows/comfy/ComfyUI
url = https://github.com/comfyanonymous/ComfyUI
@@ -1,21 +0,0 @@
import asyncio
import os
import sys
comfy_path = os.path.dirname(os.path.abspath(__file__))
comfy_path = os.path.join(comfy_path, '..', 'ComfyUI')
# change to ComfyUI directory
os.chdir(comfy_path)
# add ComfyUI to path
sys.path.append(comfy_path)
from server import PromptServer
from execution import PromptQueue
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
server = PromptServer(loop)
q = PromptQueue(server)
@@ -1,86 +0,0 @@
{
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 8,
"denoise": 1,
"latent_image": [
"5",
0
],
"model": [
"4",
0
],
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"sampler_name": "euler",
"scheduler": "normal",
"seed": 8566257,
"steps": 20
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "v1-5-pruned-emaonly.ckpt"
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 512,
"width": 512
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "masterpiece best quality girl"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "bad hands"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
}
}
}
@@ -0,0 +1,68 @@
import asyncio
import json
import os
import sys
import threading
import signal
import aiohttp
current_script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(current_script_dir, 'prompt', 'prompt.json')
prompt = json.load(open(file_path))
comfy_path = os.path.dirname(os.path.abspath(__file__))
comfy_path = os.path.join(comfy_path, '..', 'ComfyUI')
# change to ComfyUI directory
os.chdir(comfy_path)
# add ComfyUI to path
sys.path.append(comfy_path)
from server import PromptServer
from execution import PromptQueue
from main import init_custom_nodes, cuda_malloc_warning, prompt_worker
import folder_paths
async def run():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
server = PromptServer(loop)
q = PromptQueue(server)
init_custom_nodes()
cuda_malloc_warning()
server.add_routes()
threading.Thread(target=prompt_worker, daemon=True, args=(q, server,)).start()
folder_paths.add_model_folder_path("checkpoints", os.path.join(folder_paths.get_output_directory(), "checkpoints"))
folder_paths.add_model_folder_path("clip", os.path.join(folder_paths.get_output_directory(), "clip"))
folder_paths.add_model_folder_path("vae", os.path.join(folder_paths.get_output_directory(), "vae"))
await server.start('127.0.0.1', 8188)
async def send_prompt_async():
# Load prompt
p = {"prompt": prompt}
data = json.dumps(p).encode('utf-8')
# Send HTTP post request
endpoint = "http://127.0.0.1:8188/prompt"
async with aiohttp.ClientSession() as session:
async with session.post(endpoint, data=data) as resp:
print(
await resp.text())
await send_prompt_async()
while server.prompt_queue.currently_running:
await asyncio.sleep(0.05)
if __name__ == "__main__":
asyncio.run(run())
+15
View File
@@ -0,0 +1,15 @@
## ComfyRunner
Run a single ComfyUI request from the command line.
### Usage
Put the request parameters into `prompt/prompt.json` and run `ComfyRunner.py`. The ComfyUI folder must be named "ComfyUI" and be in the same superdirectory
### Usage in backend
It must run with the ComfyUI venv, example:
```
COMFY_INFERENCE_ROOT_DIRECTORY="/home/salt/clone/storyteller-ml/image_generation/ComfyUI"
COMFY_INFERENCE_EXECUTABLE_OR_COMMAND="venv/bin/python ../ComfyLauncher/ComfyLauncher.py"
```