From 1f89d73e82a66e1fb196ddb32818efa113ebb669 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Sep 2024 19:43:16 +0800 Subject: [PATCH] set the directory right --- README.md | 12 ++++++++++-- nodes.py | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7f66a75..60c2281 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,13 @@ comfyui custom node for depthflow original depthflow website: https://github.com/BrokenSource/DepthFlow check this for installation: https://brokensrc.dev/get/ -I believe run commands below is enough: -python -m pip install depthflow \ No newline at end of file + +For Ubuntu system, I believe run commands below is enough: + +sudo apt-get update +sudo apt-get install libegl1-mesa libgl1-mesa-glx libgles2-mesa +apt install libasound2-dev +python -m pip install depthflow + +And run the workflow will download depth-anything/Depth-Anything-V2-base-hf from huggingface to your local directory automatically. +you can check it at directory: ~/.cache/huggingface/hub/models--depth-anything--Depth-Anything-V2-base-hf \ No newline at end of file diff --git a/nodes.py b/nodes.py index c61e351..bbdc1bd 100644 --- a/nodes.py +++ b/nodes.py @@ -6,11 +6,10 @@ import numpy as np import torch import os, shutil from PIL import Image +import folder_paths class DepthFlow: - NAME = "DepthFlow" - CATEGORY = "utils" def __init__(self): self.glob_estimator = None @@ -27,9 +26,9 @@ class DepthFlow: return { "required": { "images": ("IMAGE",), - "fps": ("INT",{"default": 24, "min": 8, "max": 100, "step": 1}), - "width": ("INT", {"default": 20, "min": 20, "max": 9999, "step": 1}), - "height": ("INT", {"default": 20, "min": 20, "max": 9999, "step": 1}), + "fps": ("INT",{"default": 24, "min": 8, "max": 60, "step": 1}), + "width": ("INT", {"default": 512, "min": 20, "max": 9999, "step": 1}), + "height": ("INT", {"default": 512, "min": 20, "max": 9999, "step": 1}), "filename_prefix": ("STRING", {"default": "depthflow"}), }, } @@ -41,8 +40,6 @@ class DepthFlow: CATEGORY = "DepthFlow" - def IS_CHANGED(s): - return False def doit(self, images, fps, width, height, filename_prefix): @@ -57,14 +54,20 @@ class DepthFlow: frame = img.convert('RGB') random_number = random.randint(0, 1073741824) - tmpfile_path = os.path.join(filename_prefix, 'in{}.png'.format(random_number)) + input_dir = folder_paths.get_input_directory() + tmpfile_path = os.path.join(input_dir, 'depthin{}.png'.format(random_number)) frame.save(tmpfile_path) depthflow.input(image=tmpfile_path) - save_path = os.path.join(filename_prefix, str(random_number)) + output_dir = folder_paths.get_output_directory() + full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, output_dir, width, height) + + file = f"{filename}_{counter:05}_.mp4" + save_path = os.path.join(full_output_folder, file) + depthflow.main(output=save_path, fps=fps, width=width, height=height) depthflow.window.destroy() # trick 2 to avoid vram leak shutil.os.remove(tmpfile_path) #del depthflow - return (filename_prefix) + return (save_path, )