format and imports

This commit is contained in:
Tanishq Dubey 2023-03-17 22:36:21 -04:00
parent d83aeba336
commit ddb53c1111
3 changed files with 25 additions and 14 deletions

12
main.py
View File

@ -13,15 +13,19 @@ from src.utils.prereq import check_ffmpeg
check_ffmpeg()
from src.editors.amplitude.editor import AmplitudeEditor
from src.editors.sentiment.editor import SentimentEditor
from src.editors.passthrough.editor import PassthroughEditor
from src.editors.sentiment.editor import SentimentEditor
from src.math.cost import quadratic_loss
from src.mediautils.audio import extract_audio_from_video
from src.mediautils.video import render_moments
log = structlog.get_logger()
EDITORS = {"amplitude": AmplitudeEditor, "sentiment": SentimentEditor, "passthrough": PassthroughEditor}
EDITORS = {
"amplitude": AmplitudeEditor,
"sentiment": SentimentEditor,
"passthrough": PassthroughEditor,
}
ERROR_FUNCS = {"quadratic": quadratic_loss}
@ -95,7 +99,9 @@ def main(args):
sys.exit(-1)
if len(result) == 0:
log.fatal("no viable edit was found for the provided parameters, please try again with different values")
log.fatal(
"no viable edit was found for the provided parameters, please try again with different values"
)
sys.exit(-2)
log.info(

View File

@ -1,13 +1,14 @@
import concurrent.futures
import random
import numpy as np
import structlog
import random
import concurrent.futures
from ...math.average import np_moving_average
from ...math.distribution import create_distribution
from ...mediautils.audio import process_audio, resample
from ..common import find_moving_average_highlights
from ...mediautils.video import filter_moments
from ..common import find_moving_average_highlights
class AmplitudeEditor:
@ -51,7 +52,7 @@ class AmplitudeEditor:
# The decay rate, or how quickly our spread multiplier decreases as we approach the center of the gradient
spread_decay = random.uniform(0.000001, 0.0001)
parallelism = params['parallelism']
parallelism = params["parallelism"]
# The main loop of the program starts here
# we first create distributions
@ -100,7 +101,9 @@ class AmplitudeEditor:
durations = []
for result in moment_results:
total_duration = 0
result[0] = filter_moments(result[0], params['mindur'], params['maxdur'])
result[0] = filter_moments(
result[0], params["mindur"], params["maxdur"]
)
for moment in result[0]:
total_duration = total_duration + moment.get_duration()
costs.append(costfunc(desired, total_duration))

View File

@ -1,10 +1,9 @@
import concurrent.futures
import json
import random
import tempfile
from dataclasses import dataclass
from pathlib import Path
import random
import concurrent.futures
from ...math.distribution import create_distribution
import numpy as np
import structlog
@ -13,8 +12,9 @@ from flair.data import Sentence
from flair.models import TextClassifier
from ...math.average import np_moving_average
from ..common import find_moving_average_highlights
from ...math.distribution import create_distribution
from ...mediautils.video import filter_moments
from ..common import find_moving_average_highlights
@dataclass
@ -87,7 +87,7 @@ class SentimentEditor:
# The decay rate, or how quickly our spread multiplier decreases as we approach the center of the gradient
spread_decay = random.uniform(0.000001, 0.0001)
parallelism = params['parallelism']
parallelism = params["parallelism"]
# The main loop of the program starts here
# we first create distributions
@ -136,7 +136,9 @@ class SentimentEditor:
durations = []
for result in moment_results:
total_duration = 0
result[0] = filter_moments(result[0], params['mindur'], params['maxdur'])
result[0] = filter_moments(
result[0], params["mindur"], params["maxdur"]
)
for moment in result[0]:
total_duration = total_duration + moment.get_duration()
costs.append(costfunc(desired, total_duration))