for Windows support

This commit is contained in:
Sam Khoze
2024-06-16 16:32:33 +05:30
committed by GitHub
parent 2d95749eec
commit 30d1f65d37
+33 -10
View File
@@ -22,7 +22,7 @@ from pydub import AudioSegment
from .utils import BIGMAX, DIMMAX, calculate_file_hash, get_sorted_dir_files_from_directory, get_audio, lazy_eval, hash_path, validate_path, strip_path from .utils import BIGMAX, DIMMAX, calculate_file_hash, get_sorted_dir_files_from_directory, get_audio, lazy_eval, hash_path, validate_path, strip_path
from PIL import Image, ImageOps from PIL import Image, ImageOps
from comfy.utils import common_upscale, ProgressBar from comfy.utils import common_upscale, ProgressBar
from sys import platform
from scipy.io.wavfile import write from scipy.io.wavfile import write
import folder_paths import folder_paths
from .utils import ffmpeg_path, get_audio, hash_path, validate_path, requeue_workflow, gifski_path, calculate_file_hash, strip_path from .utils import ffmpeg_path, get_audio, hash_path, validate_path, requeue_workflow, gifski_path, calculate_file_hash, strip_path
@@ -954,7 +954,10 @@ class DeepFuzeFaceSwap:
if device=="gpu": if device=="gpu":
command.extend(['--execution-providers',"coreml"]) command.extend(['--execution-providers',"coreml"])
print(command) print(command)
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
# audio_file = os.path.join(audio_dir,str(time.time()).replace(".","")+".wav") # audio_file = os.path.join(audio_dir,str(time.time()).replace(".","")+".wav")
# subprocess.run(["ffmpeg","-i",faceswap_filename, audio_file, '-y']) # subprocess.run(["ffmpeg","-i",faceswap_filename, audio_file, '-y'])
# ffmpeg -i sample.avi -q:a 0 -map a sample.mp3 # ffmpeg -i sample.avi -q:a 0 -map a sample.mp3
@@ -976,7 +979,10 @@ class DeepFuzeFaceSwap:
if device=="gpu": if device=="gpu":
command.extend(['--execution-providers',"coreml"]) command.extend(['--execution-providers',"coreml"])
print(command) print(command)
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
if frame_enhancer!="None": if frame_enhancer!="None":
command = [ command = [
@@ -995,7 +1001,10 @@ class DeepFuzeFaceSwap:
print(command) print(command)
if device=="gpu": if device=="gpu":
command.extend(['--execution-providers',"coreml"]) command.extend(['--execution-providers',"coreml"])
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
# temp_file = "/".join(faceswap_filename.split("/")[:-1]) + "_"+faceswap_filename.split("/")[-1] # temp_file = "/".join(faceswap_filename.split("/")[:-1]) + "_"+faceswap_filename.split("/")[-1]
# subprocess.run(["ffmpeg","-i",faceswap_filename,"-i",audio_file,"-c","copy","-map","0:v:0","-map","1:a:0",temp_file,'-y']) # subprocess.run(["ffmpeg","-i",faceswap_filename,"-i",audio_file,"-c","copy","-map","0:v:0","-map","1:a:0",temp_file,'-y'])
# faceswap_filename = temp_file # faceswap_filename = temp_file
@@ -1345,7 +1354,10 @@ class DeepFuzeAdavance:
if device=="gpu": if device=="gpu":
command.extend(['--execution-providers',"coreml"]) command.extend(['--execution-providers',"coreml"])
print(command) print(command)
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
# print(result.stdout.splitlines()[-1]) # print(result.stdout.splitlines()[-1])
if enhancer!="None": if enhancer!="None":
command = [ command = [
@@ -1364,7 +1376,10 @@ class DeepFuzeAdavance:
if device=="gpu": if device=="gpu":
command.extend(['--execution-providers',"coreml"]) command.extend(['--execution-providers',"coreml"])
print(command) print(command)
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
filename = enhanced_filename filename = enhanced_filename
if frame_enhancer!="None": if frame_enhancer!="None":
@@ -1384,7 +1399,10 @@ class DeepFuzeAdavance:
print(command) print(command)
if device=="gpu": if device=="gpu":
command.extend(['--execution-providers',"coreml"]) command.extend(['--execution-providers',"coreml"])
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
temp_file = "/".join(enhanced_filename.split("/")[:-1]) + "_"+enhanced_filename.split("/")[-1] temp_file = "/".join(enhanced_filename.split("/")[:-1]) + "_"+enhanced_filename.split("/")[-1]
subprocess.run(["ffmpeg","-i",enhanced_filename,"-i",audio_file,"-c","copy","-map","0:v:0","-map","1:a:0",temp_file,'-y']) subprocess.run(["ffmpeg","-i",enhanced_filename,"-i",audio_file,"-c","copy","-map","0:v:0","-map","1:a:0",temp_file,'-y'])
filename = temp_file filename = temp_file
@@ -1488,7 +1506,10 @@ class TTS_generation:
'--output_file', file_path, '--output_file', file_path,
'--device', device '--device', device
] ]
result = subprocess.run(command, cwd="custom_nodes/ComfyUI-DeepFuze",capture_output=True, text=True) if platform == "win32:
result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command, cwd="custom_nodes/ComfyUI-DeepFuze",capture_output=True, text=True)
print("stdout:", result.stdout) print("stdout:", result.stdout)
print("stderr:", result.stderr) print("stderr:", result.stderr)
@@ -1553,8 +1574,10 @@ class DeepfuzePreview:
'--headless' '--headless'
] ]
print(command) print(command)
# result = subprocess.Popen(" ".join(command),cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) if platform == "win32:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE) result = subprocess.run(command,cwd="ComfyUI/custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
else:
result = subprocess.run(command,cwd="custom_nodes/ComfyUI-DeepFuze",stdout=subprocess.PIPE)
print(result.stdout) print(result.stdout)
results.append({ results.append({
"filename": "_"+file, "filename": "_"+file,