Skip to content

feature: domain specific task names. added sam-3, flux-2. Moved some runway models to replicate provider#46

Merged
JoeGaffney merged 10 commits intomainfrom
2025-11-22
Nov 27, 2025
Merged

feature: domain specific task names. added sam-3, flux-2. Moved some runway models to replicate provider#46
JoeGaffney merged 10 commits intomainfrom
2025-11-22

Conversation

@JoeGaffney
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a comprehensive update to the model infrastructure, introducing new models, standardizing task naming conventions, and improving provider integrations. The changes include migration of Runway models to Replicate, addition of new segmentation and image generation models, system prompt enhancements, and various video processing improvements.

Key Changes:

  • Standardized Celery task naming with domain prefixes (images., videos., texts.)
  • Added new models: FLUX 2, SAM 2, and SAM 3 for image generation and segmentation
  • Migrated runway-gen-4 and runway-upscale from Runway API to Replicate
  • Introduced NONE system prompt option for text models with empty default behavior
  • Enhanced video processing with compression, better duration handling, and resolution-aware logic

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
workers/images/tasks.py Added FLUX 2, SAM 2/3 tasks; standardized task naming with images. prefix
workers/images/schemas.py Updated model registry with FLUX 2, SAM 2/3 definitions; added task_name property
workers/images/local/flux_2.py New FLUX 2.0 implementation with multi-image support and inpainting
workers/images/local/sam_2.py Renamed from segment-anything-2; improved mask coloring logic
workers/images/local/sam_3.py New SAM 3 implementation with text-based segmentation
workers/videos/tasks.py Standardized task naming with videos. prefix
workers/videos/schemas.py Updated runway model providers to replicate; added task_name property
workers/videos/context.py Added video compression, resolution detection, duration calculation methods
workers/videos/external/runway_gen_4.py Refactored to use Replicate API with aspect ratio mapping
workers/videos/external/runway_upscale.py Migrated from Runway SDK to Replicate helpers
workers/videos/external/runway_act_two.py Minor video compression integration
workers/videos/external/openai_sora_2.py Updated duration logic from long_video() to duration_in_seconds()
workers/videos/external/minimax_hailuo_2.py Updated duration and resolution logic
workers/videos/external/kwaivgi_kling_2.py Updated duration logic to use duration_in_seconds()
workers/videos/external/google_veo_3.py Refactored duration and audio settings
workers/videos/external/bytedance_seedance_1.py Updated duration logic and added resolution parameter
workers/videos/local/ltx_video.py Improved frame count handling with min() logic
workers/texts/tasks.py Standardized task naming with texts. prefix
workers/texts/schemas.py Added NONE system prompt; condensed optimizer prompts
workers/texts/local/qwen_2.py Made system prompt optional with empty check
workers/texts/external/openai_gpt.py Added conditional system prompt handling
workers/utils/utils.py Added mp4_to_base64_decoded; updated load functions with model parameter; removed unused imports; increased max resolution to 4096
workers/common/pipeline_helpers.py Added offload parameter to get_quantized_model; improved optimize_pipeline with conditional safety checker; added documentation
workers/tests/images/local/test_*.py Renamed and added tests for SAM 2/3 and FLUX 2
workers/tests/images/helpers.py Updated model routing for renamed and new models
workers/requirements.txt Updated diffusers commit hash; added sam3 package
api/images/schemas.py Mirrored worker schema updates for FLUX 2, SAM 2/3
api/videos/schemas.py Mirrored worker schema updates for provider changes
api/texts/schemas.py Mirrored worker schema updates for NONE prompt and condensed text
clients/openapi.json Updated OpenAPI spec with new models and system prompts
clients/nuke/gizmos/dd_image.gizmo Updated model dropdown with SAM 2/3 replacements
README.md Updated documentation references from models/ to local/ and tasks/

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from images.local.segment_anything_2 import main
@typed_task(name="sam-2", queue="gpu")
def sam_2_image(request_dict):
from images.local.sam_2_image import main
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement references images.local.sam_2_image, but the actual file is named sam_2.py. This will cause an ImportError at runtime. The import should be:

from images.local.sam_2 import main
Suggested change
from images.local.sam_2_image import main
from images.local.sam_2 import main

Copilot uses AI. Check for mistakes.
model_id, text_encoder=text_encoder, transformer=transformer, torch_dtype=torch.bfloat16
)

# allways offload as heavy models
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "allways" should be "always".

Suggested change
# allways offload as heavy models
# always offload as heavy models

Copilot uses AI. Check for mistakes.

def get_flow_shift(self) -> float:
return 5.0 if self.get_is_720p() else 3.0
return 5.0 if self.get_resolution_type() == "720p" else 3.0
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The logic for get_flow_shift() only checks for 720p and defaults to 3.0 for both 480p and 1080p. If 1080p should have a different flow shift value than 480p, consider adding explicit handling:

def get_flow_shift(self) -> float:
    resolution = self.get_resolution_type()
    if resolution == "720p":
        return 5.0
    elif resolution == "1080p":
        return 3.0  # or appropriate value for 1080p
    return 3.0  # 480p
Suggested change
return 5.0 if self.get_resolution_type() == "720p" else 3.0
resolution = self.get_resolution_type()
if resolution == "720p":
return 5.0
elif resolution == "1080p":
return 3.0 # or set to a different value if needed
return 3.0 # 480p

Copilot uses AI. Check for mistakes.
from accelerate.hooks import CpuOffload
from cachetools.keys import hashkey
from diffusers import GGUFQuantizationConfig
from diffusers import DiffusionPipeline, GGUFQuantizationConfig
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'DiffusionPipeline' is not used.

Suggested change
from diffusers import DiffusionPipeline, GGUFQuantizationConfig
from diffusers import GGUFQuantizationConfig

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,119 @@
import os
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'os' is not used.

Suggested change
import os

Copilot uses AI. Check for mistakes.
import os
import random

import numpy as np
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'np' is not used.

Suggested change
import numpy as np

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,70 @@
from typing import List, Literal
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Literal' is not used.

Suggested change
from typing import List, Literal
from typing import List

Copilot uses AI. Check for mistakes.
if disable_safety_checker:
try:
pipe.vae.enable_slicing() # Enable VAE slicing to reduce memory usage
except:
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except block directly handles BaseException.

Suggested change
except:
except Exception:

Copilot uses AI. Check for mistakes.
@JoeGaffney JoeGaffney requested a review from Copilot November 27, 2025 10:01
@JoeGaffney JoeGaffney changed the title 2025 11 22 feature: domain specific task names. added sam-3, flux-2. Moved some runway models to replicate provider Nov 27, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

workers/texts/external/openai_gpt.py:4

  • Import of 'Omit' is not used.
from openai import Omit, OpenAI

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +46 to +51
if self.width >= 1280 or self.height >= 1280:
return True
return False

def is_1080p_or_higher(self) -> bool:
if self.width >= 1920 or self.height >= 1920:
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for determining 720p or higher resolution may be incorrect. Using or means a 1280x480 video would be considered 720p+ because width >= 1280, even though the total pixel count is much less than 720p (1280x720 = 921,600 pixels). Consider using and instead: if self.width >= 1280 and self.height >= 720: to ensure both dimensions meet the threshold.

Suggested change
if self.width >= 1280 or self.height >= 1280:
return True
return False
def is_1080p_or_higher(self) -> bool:
if self.width >= 1920 or self.height >= 1920:
if self.width >= 1280 and self.height >= 720:
return True
return False
def is_1080p_or_higher(self) -> bool:
if self.width >= 1920 and self.height >= 1080:

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +51
if self.width >= 1280 or self.height >= 1280:
return True
return False

def is_1080p_or_higher(self) -> bool:
if self.width >= 1920 or self.height >= 1920:
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the 720p check, the logic for determining 1080p or higher resolution may be incorrect. Using or means a 1920x480 video would be considered 1080p+ even though it doesn't meet the 1080p standard (1920x1080). Consider using and instead: if self.width >= 1920 and self.height >= 1080: to ensure both dimensions meet the threshold.

Suggested change
if self.width >= 1280 or self.height >= 1280:
return True
return False
def is_1080p_or_higher(self) -> bool:
if self.width >= 1920 or self.height >= 1920:
if self.width >= 1280 and self.height >= 720:
return True
return False
def is_1080p_or_higher(self) -> bool:
if self.width >= 1920 and self.height >= 1080:

Copilot uses AI. Check for mistakes.
from typing import Any, Dict

from openai import OpenAI
from openai import Omit, OpenAI
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Omit import from openai is added but never used in this file. Consider removing it to keep the imports clean.

Suggested change
from openai import Omit, OpenAI
from openai import OpenAI

Copilot uses AI. Check for mistakes.
path = export_to_video(self.video_frames, output_video_path=tmp_path, fps=fps, quality=9)
logger.info(f"Compressed video saved at {path}")

# convert and check size once more abort if still too large
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "abort" should be "and abort" or the comment should read "convert and check size once more; abort if still too large".

Suggested change
# convert and check size once more abort if still too large
# convert and check size once more; abort if still too large

Copilot uses AI. Check for mistakes.
@JoeGaffney JoeGaffney merged commit 71b7817 into main Nov 27, 2025
1 check passed
@JoeGaffney JoeGaffney deleted the 2025-11-22 branch November 28, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants