|
|
|
|
@ -8,6 +8,7 @@ import SpoutGL |
|
|
|
|
from OpenGL.GL import GL_RGBA |
|
|
|
|
import time |
|
|
|
|
import img2img |
|
|
|
|
from multiprocessing import Queue |
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
TARGET_FPS = 60 |
|
|
|
|
@ -19,6 +20,8 @@ def main(): |
|
|
|
|
timestamp = datetime.datetime.now() |
|
|
|
|
fps = 30.0 |
|
|
|
|
|
|
|
|
|
prompt_queue = Queue() |
|
|
|
|
|
|
|
|
|
print("Initializing StreamDiffusion pipeline...") |
|
|
|
|
global pipeline |
|
|
|
|
try: |
|
|
|
|
@ -39,6 +42,7 @@ def main(): |
|
|
|
|
async def update_prompt(update: PromptUpdate): |
|
|
|
|
global PROMPT |
|
|
|
|
PROMPT = update.prompt |
|
|
|
|
prompt_queue.put(PROMPT) |
|
|
|
|
print(f"Prompt updated to: {PROMPT}") |
|
|
|
|
return {"message": "Prompt updated successfully", "new_prompt": PROMPT} |
|
|
|
|
|
|
|
|
|
@ -77,11 +81,18 @@ def main(): |
|
|
|
|
if spout_receiver.isConnected() and SpoutGL.helpers.isBufferEmpty(image_bgra): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
image_rgb_array = image_bgra[:, :, [2,1,0]] |
|
|
|
|
input_image = Image.fromarray(image_rgb_array, 'RGB') |
|
|
|
|
image_rgb_array = image_bgra[:, :, [2,1,0]] |
|
|
|
|
# image_rgb_array = image_rgb_array.astype(np.float32) / 255.0 |
|
|
|
|
input_image = Image.fromarray(image_rgb_array, 'RGB') |
|
|
|
|
# input_image.save("debug_input.png") |
|
|
|
|
|
|
|
|
|
if not prompt_queue.empty(): |
|
|
|
|
new_prompt = prompt_queue.get(block=False) |
|
|
|
|
if new_prompt: |
|
|
|
|
print(f"Received new prompt from queue: {new_prompt}") |
|
|
|
|
PROMPT = new_prompt |
|
|
|
|
|
|
|
|
|
# print(f"current prompt: {PROMPT}") |
|
|
|
|
params = img2img.Pipeline.InputParams(prompt=PROMPT) |
|
|
|
|
output_image = pipeline.predict(image=input_image, params=params) |
|
|
|
|
# output_image.save("debug_output.png") |
|
|
|
|
|