Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly implement PARENT_DIR and remove unnecessary install.py code #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
.DS_Store
/projects
86 changes: 3 additions & 83 deletions install.py
Original file line number Diff line number Diff line change
@@ -1,84 +1,4 @@
import os
import sys
import subprocess
import launch

# Define the requirements for the extension
REQUIRED_PACKAGES = [
"gradio>=3.10.1",
"transparent-background==1.3.2",
"torch>=1.9.0",
"Pillow",
]

ASCII_ART = """
⣿⣿⣿⣿⣟⣿⣻⢿⡟⢿⡿⢿⣽⡌⣳⠀⠀⠀⠀⢻⢿⡷⢉⠛⠲⠶⠡⠀⢬⢅⠆⠤⢳⡄⠁⢆⠐⠈⢉⡙⢫⢟⡆⠀⠀⢈⠓⢉⢻⠀
⠹⣄⡀⢈⡋⠥⣉⠀⢌⡠⢉⠢⠙⣌⢒⣦⣐⣢⣀⣆⣤⣲⣌⣴⣰⣠⠄⠀⠀⠀⠀⠀⠁⠈⠑⢢⣶⣤⣦⣼⣦⣦⣼⣧⣶⣦⣾⣶⣶⠀
⣷⣶⣿⣶⣾⣷⣿⣿⣿⣿⡿⠋⠛⠛⠋⠉⠛⢿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⣀⣀⠀⠀⢀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀
⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠀⠀⠀⠀⠀⠀⡀⠀⠈⠙⢿⣿⣿⣿⠃⠀⠀⢾⡹⣷⣿⣦⡄⠀⠠⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⠀
⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⡰⣿⣿⣽⣷⣤⠀⠈⢿⣿⠏⠀⠀⠸⠒⠿⣞⠿⠿⠿⢆⠀⠂⠀⠀⠚⣿⣿⣿⣿⣿⣽⣷⣿⣿⣿⠀
⣿⣿⣿⣿⡿⡿⠏⠀⠀⠀⠀⠀⢴⡹⢾⣿⣿⣿⠿⠇⠀⠸⣿⡇⠀⠀⠀⠀⠈⣿⡀⠈⢍⣹⡆⠀⠀⢂⠀⠸⢿⣿⣿⣿⣿⣿⣿⣿⣿⠀
⣿⣿⣿⣿⣻⠟⠀⠀⠀⠀⠀⠰⠠⠐⢂⢀⢻⠷⠀⢉⡀⠀⢫⠁⠀⠘⡶⡞⠠⣿⣿⠻⣿⣿⣏⠀⠀⠀⠀⠀⢸⣽⣿⣿⣿⣿⣿⣿⣿⠀
⠛⢿⣿⠗⠩⠄⠀⠀⠀⠀⠀⠉⢷⣶⣾⡾⡍⣿⡿⢿⣷⠀⠸⡇⡀⠀⢨⠀⠂⢀⣚⡃⢈⣿⡏⠠⠀⠀⠀⠁⢂⢙⢻⣿⣿⣿⣿⣿⣿⠀
⠀⡠⠠⢍⠁⠀⠀⠀⠀⠀⠀⠈⠌⢻⠟⠦⠤⠜⠞⢊⡏⠀⠸⣯⠠⠀⠀⠂⣄⢒⣴⣿⡾⢏⡁⠀⠀⠀⠀⠀⠁⠹⢸⣿⣿⣿⣿⣿⣿⠀
⠀⢡⠜⠇⠀⠀⠀⠀⠀⠀⠀⠀⠈⡍⢶⡤⣉⠚⣣⡿⠁⠀⣿⣿⣷⡀⠀⠀⠈⠛⢛⢫⡾⣹⠆⠀⠀⠀⡀⠀⠀⠀⠠⢪⣿⣿⣿⣿⣿⠀
⠘⢦⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠌⠘⠻⠿⠟⠀⠀⢠⣻⣿⣿⣷⣤⠀⠀⠀⡘⠦⡹⣽⣻⣴⢦⡤⢄⣤⢤⢤⣤⣅⢿⣿⣿⣿⣿⠀
⣾⠗⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠐⡴⣢⣭⢿⡝⠀⠀⢀⠤⣿⠛⠍⡀⢱⠃⠀⠐⣀⠣⣕⢺⣱⣝⣴⣿⢣⣞⢯⣞⣿⣿⣷⡹⣿⣿⣿⠀
⡿⣹⠠⠀⢀⣀⣄⣤⣒⡶⡜⣶⣹⢶⣽⣾⣿⣅⣀⠠⣌⡿⠃⠈⢀⠔⡀⠀⠄⡇⢆⡰⣏⣿⣹⢿⣿⣿⣿⣾⣷⣾⣿⣿⣿⣿⣻⣿⣿⠀
⣿⠏⢄⠺⡽⣿⣿⣿⣿⣿⣿⣶⣿⣯⣿⣿⡿⣾⣼⣫⢻⣷⡁⠀⠎⠠⠀⠄⡘⡘⢦⣛⠾⣱⣫⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣏⣿⣿⠀
⣾⠎⣀⠲⣉⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣟⣮⢇⠀⠈⢄⠩⡐⠴⣉⠶⡩⢎⡱⣏⣾⣿⣿⣿⣿⣿⣏⠜⣯⣷⡿⣽⢿⣿⠀
⡿⢀⠢⡑⢮⡙⣞⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣄⠈⢦⠳⣍⠞⡌⢣⠱⣏⡵⣿⣿⣿⣿⣿⣿⣿⡅⠀⢏⣿⣻⣽⣾⣿⠀
⡇⠀⢆⡙⢦⠍⠀⠘⢧⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣎⢼⣛⣮⡟⠠⡁⣞⡴⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠈⢖⡿⣯⣧⣿⠀
⠀⠌⠰⣘⢧⠋⠀⠀⠀⢋⡾⣿⣿⣿⣿⣿⣿⣿⣟⣿⣿⣿⣿⣿⣿⣷⡽⣿⠇⢠⡱⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠌⢺⣿⣿⣹⠀
⠠⡈⠵⣩⠂⠁⠀⡐⢈⡐⣟⣿⣿⣿⣿⣿⣿⣿⣿⣟⡡⢿⣿⣿⣿⣿⡯⠙⠀⢆⡿⣽⡟⢭⣻⣿⣿⣿⣿⣿⣿⡇⠀⢠⠈⢂⠿⣿⡿⠀
⢠⡙⡼⡁⠀⠀⠀⠐⡀⠐⢎⡿⣿⣿⡟⠜⠾⣿⣿⣿⡆⢹⣻⣿⣿⣿⣯⠁⠀⠘⡼⣃⠀⠂⣿⣿⣿⣿⣿⣿⣿⠀⡱⡜⡆⠈⢞⡽⣿⠀
⢠⣛⠖⠅⠀⠀⠀⠀⡐⠈⠠⠙⡽⣻⣿⣄⣒⣽⣿⡿⣿⡄⠘⢿⣿⣿⡟⠀⠀⠈⠰⠩⡗⣿⣿⣿⣿⢿⣽⣿⡟⣰⣻⣶⣿⡈⢜⡲⢹⠀
⢢⠍⣜⠊⠀⠀⠀⠀⠠⢁⠂⡁⠐⡉⠞⡻⢿⠿⣛⣿⣿⣿⡄⠈⠘⠁⠀⡀⠂⠠⠀⠁⠈⠐⣉⣬⣵⣿⣿⡿⠵⢔⣿⣿⣿⣧⠈⢿⣡⠀
⠂⣼⡳⠡⠀⠀⠀⠠⠀⠂⠄⣑⢦⡠⣤⣴⣶⣾⣿⣿⣿⣿⣿⣦⠀⠀⠠⢈⡁⠀⠡⠙⣾⣹⣞⣧⡿⣿⣿⣧⠒⣽⣿⣿⣿⣿⣷⡀⢣⠀
⣇⣿⣧⣌⣠⣅⠧⠀⡀⢈⠰⡈⠦⡝⡶⣭⣿⣿⣿⣿⣿⣿⡿⡙⣆⠀⠀⢂⠐⠠⠁⠈⠄⢫⣟⡿⣽⣻⣿⣷⣾⣿⣿⣿⣿⣿⣿⣿⣄⠀
⣯⣿⣿⣽⣾⣿⣶⣽⠇⢀⠢⣑⢻⠲⣍⢯⢻⡽⣯⣿⣿⡳⡇⣹⣿⠆⠀⠀⠌⡐⠈⡐⢄⠂⢌⡱⢿⣿⣿⣿⣿⣯⢿⣿⣿⣿⣿⣿⣿⠀
⣿⣽⣿⣿⣿⣿⣿⢋⢢⡀⢵⣊⢧⡻⣜⢮⣳⣻⣽⣟⢾⣳⢁⣿⣿⡆⠀⠀⠐⡠⠐⠠⣊⣝⠢⡌⢣⢟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀
⣿⡧⣿⣿⣿⡿⢁⢎⢶⣙⠶⣽⣯⣿⣽⣳⢿⣿⣿⣞⣯⢷⢨⣿⣿⠃⠀⠀⠠⢑⠂⢀⠓⣎⠻⡄⢃⠎⡿⣿⣿⣿⣿⡓⠹⣿⣿⣿⣿⠀
⢺⣿⣹⣿⠏⠠⠐⠊⢷⣫⢿⣽⣿⣻⢾⡽⣿⣿⣯⣼⣟⠯⡰⣻⣿⠀⠀⠀⠀⠀⡁⠂⠉⡌⠓⡄⠂⠌⡱⢫⢿⣟⡇⠚⠧⠹⣿⣿⣿⠀
⠀⢿⣏⠋⠀⠀⠸⠴⠀⠍⡛⢿⣳⢯⣛⠾⣝⢯⣟⣟⢮⠃⠁⣿⡿⠀⠀⠀⠀⠀⠀⢀⠁⠄⢃⠐⠈⠀⣃⠨⡰⡣⣜⣲⠀⢜⣙⣿⣿⠀
⡈⠆⣿⣆⠮⠵⠃⠜⡪⣏⠛⣳⠨⣅⣫⠙⢊⡧⢙⠈⡃⢠⠖⢽⡧⠠⢁⡈⠁⠀⠀⢀⣤⢀⢐⡠⠀⠙⢛⠌⢀⣿⠟⣯⣴⣿⣿⡿⣿⠀
⣧⢈⠼⣿⣦⡒⣤⣐⣸⢼⣁⣉⣐⠿⠈⡳⠅⠰⡅⢁⢶⠟⠒⢿⣧⠀⠈⠐⠑⠠⠔⠈⡀⢀⣩⠭⠡⠀⡘⠀⠀⢀⣈⡽⣿⣿⣿⣿⣿⠀
⣿⠀⠺⣽⣿⢿⡰⣌⢯⡝⡬⠢⠁⠀⡊⣉⠀⠈⠛⢍⣭⣟⡷⢸⡯⠀⢀⠢⡐⣀⠀⠀⠀⠀⠁⠁⠀⠀⢀⠰⣘⣦⢷⣿⣿⣿⣿⣿⣿⠀
⣿⠂⡵⠺⣽⠑⣗⢽⣻⣿⣽⣭⠀⣆⡔⠾⡰⢐⢶⣯⣷⣯⢿⣼⣷⠀⠀⠦⣑⠦⡱⢀⠀⠀⠀⠀⠀⡐⡬⢯⣽⣾⣿⣿⣿⣿⣿⣿⣻⠀
⣷⠀⢈⡄⣾⠀⢥⣚⣿⣿⣿⣯⣷⠈⠀⢀⡴⣫⣾⢿⣷⣿⡿⣴⡷⠀⠈⠲⣍⠞⡥⢃⠂⠀⠀⠀⢠⠱⣽⣻⣿⣿⣿⣿⣿⣿⣿⢷⣿⠀
⣿⡄⠀⠃⠘⡆⣈⡟⣾⢿⣿⣿⣿⣇⠀⠮⣜⢷⣯⢿⣿⣿⣿⣹⣇⠀⠀⠓⣌⠛⠤⠁⠀⠀⠀⣀⢣⣛⣾⣿⣿⣿⣿⣿⣿⣿⢟⣾⣿⠀
⢿⣳⠀⠈⠀⠇⠼⡸⣝⣿⣿⣿⣿⣿⠀⠳⣘⢯⡞⣿⣿⣿⣷⠹⡿⠀⠀⠑⠨⠌⢀⠀⠀⠀⠠⣐⢧⣻⣾⣿⣿⣿⣿⣿⡿⢏⣾⣿⣿⠀
⣾⣿⣗⠀⠈⢠⢃⡓⠾⣼⣻⣿⣿⣿⠃⠠⠉⢖⡛⣛⣻⣛⡋⢀⣭⡄⠀⠀⠄⠂⠀⠀⠀⠀⡰⣉⠞⣻⣟⣿⣛⣿⣿⠛⠩⢸⣩⣯⣽⠀
"""

def install_package(package):
"""Installs a single package using pip."""
print(f"\033[94m[*] Installing {package}...\033[0m")
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
print(f"\033[92m[+] Successfully installed {package}.\033[0m")
except subprocess.CalledProcessError:
print(f"\033[91m[!] Failed to install {package}. Please try manually.\033[0m")

def main():
"""Installs all required packages."""
print("\033[95m" + "=" * 60)
print(" " * 12 + "✨ VFX Workflow Extension Installer ✨")
print("=" * 60 + "\033[0m")
print(ASCII_ART)
print("\033[94mThis script will install all required dependencies for the extension.\033[0m\n")

print("\033[92mRequirements:\033[0m")
for package in REQUIRED_PACKAGES:
print(f" ➡ {package}")

print("\n\033[93m[*] Starting installation...\033[0m\n")

for package in REQUIRED_PACKAGES:
install_package(package)

print("\n\033[92m[+] All dependencies have been installed successfully!\033[0m")
print("\033[94mYou can now launch the Stable Diffusion WebUI and use the extension.\033[0m")
print("\033[95m" + "=" * 60 + "\033[0m")

if __name__ == "__main__":
main()
if not launch.is_installed("transparent-background"):
launch.run_pip("install transparent-background==1.3.2", "installing transparent-background for VFX Workflow")
Empty file removed javascript/library_browser.js
Empty file.
Binary file removed scripts/.DS_Store
Binary file not shown.
38 changes: 24 additions & 14 deletions scripts/vfx_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
import torch
from PIL import Image
import gradio as gr
from modules import scripts, script_callbacks
from modules import scripts, script_callbacks, shared, util

# Define the base directory for project folders
PARENT_DIR = "/path/to/project" # Update this path to your project base directory
extension_root = scripts.basedir()
default_projects_dir = util.truncate_path(os.path.join(extension_root, 'projects'))
shared.options_templates.update(shared.options_section(('saving-paths', 'Paths for saving'), {
'vfx_workflow_projects_dir': shared.OptionInfo(
'', 'Projects directory for VFS Workflow', component_args=shared.hide_dirs).info(
f'if empty use {default_projects_dir}'
),
}))


def projects_dir() -> str:
return shared.opts.vfx_workflow_projects_dir.strip() or default_projects_dir


# Frame Extraction Function
Expand All @@ -17,10 +27,10 @@ def extract_frames(project_title, video_file):
if not project_title:
return [], "Error: Project Title is required."

frame_dir = os.path.join(PARENT_DIR, project_title, "video_frames")
frame_dir = os.path.join(projects_dir(), project_title, "video_frames")
os.makedirs(frame_dir, exist_ok=True)

fps_file = os.path.join(PARENT_DIR, project_title, "fps.txt")
fps_file = os.path.join(projects_dir(), project_title, "fps.txt")
video_path = video_file.name

try:
Expand Down Expand Up @@ -61,8 +71,8 @@ def create_masks(project_title, use_fast_mode=False, use_jit=True):
if not project_title:
return [], "Error: Project Title is required."

frame_dir = os.path.join(PARENT_DIR, project_title, "video_frames")
mask_dir = os.path.join(PARENT_DIR, project_title, "video_masks")
frame_dir = os.path.join(projects_dir(), project_title, "video_frames")
mask_dir = os.path.join(projects_dir(), project_title, "video_masks")
os.makedirs(mask_dir, exist_ok=True)

try:
Expand Down Expand Up @@ -95,8 +105,8 @@ def extract_keyframes(project_title, include_first_last=False, max_keyframes_per
if not project_title:
return [], "Error: Project Title is required."

frame_dir = os.path.join(PARENT_DIR, project_title, "video_frames")
keyframe_dir = os.path.join(PARENT_DIR, project_title, "keyframes")
frame_dir = os.path.join(projects_dir(), project_title, "video_frames")
keyframe_dir = os.path.join(projects_dir(), project_title, "keyframes")

if not os.path.exists(frame_dir):
return [], "Error: Ensure 'video_frames' directory exists in the project folder."
Expand All @@ -119,7 +129,7 @@ def extract_keyframes(project_title, include_first_last=False, max_keyframes_per
if total_keyframes > max_keyframes_per_folder:
subfolder_count = (total_keyframes - 1) // max_keyframes_per_folder + 1
for folder_idx in range(subfolder_count):
subfolder_path = os.path.join(PARENT_DIR, project_title, str(folder_idx + 1))
subfolder_path = os.path.join(projects_dir(), project_title, str(folder_idx + 1))
os.makedirs(subfolder_path, exist_ok=True)

sub_frame_dir = os.path.join(subfolder_path, "video_frames")
Expand Down Expand Up @@ -153,7 +163,7 @@ def rename_img2img_output(project_title):
if not project_title:
return "Error: Project Title is required."

img2img_output_dir = os.path.join(PARENT_DIR, project_title, "img2img_output")
img2img_output_dir = os.path.join(projects_dir(), project_title, "img2img_output")
if not os.path.exists(img2img_output_dir):
return f"Error: img2img_output directory not found: {img2img_output_dir}"

Expand All @@ -178,8 +188,8 @@ def generate_zip(project_title):
if not project_title:
return None, "Error: Project Title is required."

project_path = os.path.join(PARENT_DIR, project_title)
zip_path = os.path.join(project_path, f"{project_title}.zip")
project_path = os.path.join(projects_dir(), project_title)
zip_path = os.path.join(projects_dir(), f"{project_title}.zip")

try:
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
Expand All @@ -204,7 +214,7 @@ def get_batch_instructions(project_title):
if not project_title:
return "Error: Project Title is required."

project_path = os.path.join(PARENT_DIR, project_title)
project_path = os.path.join(projects_dir(), project_title)
keyframe_dir = os.path.join(project_path, "keyframes")
output_dir = os.path.join(project_path, "img2img_output")
mask_dir = os.path.join(project_path, "video_masks")
Expand Down