mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
Formatting
This commit is contained in:
@@ -18,7 +18,7 @@ class GenerationContext:
|
||||
assetsengine,
|
||||
settingsengine,
|
||||
backgroundengine,
|
||||
progress
|
||||
progress,
|
||||
) -> None:
|
||||
self.progress = progress
|
||||
|
||||
@@ -64,8 +64,8 @@ class GenerationContext:
|
||||
# ⚠️ IMPORTANT NOTE: All methods called here are expected to be defined as abstract methods in the base classes, if not there is an issue with the engine implementation.
|
||||
|
||||
# we start by loading the settings
|
||||
|
||||
self.progress(0.1,"Loading settings...")
|
||||
|
||||
self.progress(0.1, "Loading settings...")
|
||||
self.settingsengine.load()
|
||||
|
||||
self.setup_dir()
|
||||
|
||||
@@ -23,7 +23,11 @@ class SimpleBackgroundEngine(BaseBackgroundEngine):
|
||||
@classmethod
|
||||
def get_options(cls) -> list:
|
||||
assets = cls.get_assets(type="bcg_video")
|
||||
choices=[asset.data["name"] for asset in assets] if len(assets) > 0 else ["No videos available"]
|
||||
choices = (
|
||||
[asset.data["name"] for asset in assets]
|
||||
if len(assets) > 0
|
||||
else ["No videos available"]
|
||||
)
|
||||
|
||||
return [
|
||||
gr.Dropdown(
|
||||
@@ -35,9 +39,7 @@ class SimpleBackgroundEngine(BaseBackgroundEngine):
|
||||
]
|
||||
|
||||
def get_background(self) -> mp.VideoClip:
|
||||
background = mp.VideoFileClip(
|
||||
f"{self.background_video}", audio=False
|
||||
)
|
||||
background = mp.VideoFileClip(f"{self.background_video}", audio=False)
|
||||
background_max_start = background.duration - self.ctx.duration
|
||||
if background_max_start < 0:
|
||||
raise ValueError(
|
||||
@@ -46,7 +48,13 @@ class SimpleBackgroundEngine(BaseBackgroundEngine):
|
||||
start = random.uniform(0, background_max_start)
|
||||
clip = background.subclip(start, start + self.ctx.duration)
|
||||
w, h = clip.size
|
||||
return crop(clip, width=self.ctx.width, height=self.ctx.height, x_center=w / 2, y_center=h / 2)
|
||||
return crop(
|
||||
clip,
|
||||
width=self.ctx.width,
|
||||
height=self.ctx.height,
|
||||
x_center=w / 2,
|
||||
y_center=h / 2,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_settings(cls) -> list:
|
||||
|
||||
@@ -47,7 +47,7 @@ class BaseEngine(ABC):
|
||||
.scalars()
|
||||
.all()
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_asset(cls, *, path: str, metadata: dict, type: str = None):
|
||||
with SessionLocal() as db:
|
||||
|
||||
@@ -3,14 +3,16 @@ from typing import TypedDict
|
||||
|
||||
from .. import BaseEngine
|
||||
|
||||
|
||||
class MetadataEngineSettings(TypedDict):
|
||||
title: str
|
||||
description: str
|
||||
|
||||
|
||||
class BaseMetadataEngine(BaseEngine):
|
||||
def __init__(self, **kwargs) -> None:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def get_metadata(self, input: str) -> MetadataEngineSettings:
|
||||
...
|
||||
...
|
||||
|
||||
@@ -2,15 +2,20 @@ from . import BaseMetadataEngine
|
||||
|
||||
from ...utils.prompting import get_prompt
|
||||
|
||||
|
||||
class ShortsMetadataEngine(BaseMetadataEngine):
|
||||
def __init__(self, **kwargs) -> None:
|
||||
...
|
||||
|
||||
def get_metadata(self):
|
||||
sytsem_prompt, chat_prompt = get_prompt("ShortsMetadata", by_file_location=__file__)
|
||||
sytsem_prompt, chat_prompt = get_prompt(
|
||||
"ShortsMetadata", by_file_location=__file__
|
||||
)
|
||||
chat_prompt = chat_prompt.replace("{script}", self.ctx.script)
|
||||
|
||||
return self.ctx.simplellmengine.generate(chat_prompt=chat_prompt, system_prompt=sytsem_prompt, json_mode=True)
|
||||
return self.ctx.simplellmengine.generate(
|
||||
chat_prompt=chat_prompt, system_prompt=sytsem_prompt, json_mode=True
|
||||
)
|
||||
|
||||
def get_options(self):
|
||||
return []
|
||||
return []
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
from .BaseMetadataEngine import BaseMetadataEngine
|
||||
from .ShortsMetadataEngine import ShortsMetadataEngine
|
||||
from .ShortsMetadataEngine import ShortsMetadataEngine
|
||||
|
||||
@@ -10,6 +10,7 @@ from . import SettingsEngine
|
||||
from . import BackgroundEngine
|
||||
from . import MetadataEngine
|
||||
|
||||
|
||||
class EngineDict(TypedDict):
|
||||
classes: list[BaseEngine]
|
||||
multiple: bool
|
||||
|
||||
Reference in New Issue
Block a user