mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 01:06:19 +00:00
Formatting
This commit is contained in:
@@ -2,10 +2,12 @@ import os
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import gradio as gr
|
||||||
import moviepy.editor as mp
|
import moviepy.editor as mp
|
||||||
|
|
||||||
from .. import engines
|
from .. import engines
|
||||||
from ..models import Video, SessionLocal
|
from ..models import Video, SessionLocal
|
||||||
|
from ..utils.prompting import get_prompt
|
||||||
|
|
||||||
|
|
||||||
class GenerationContext:
|
class GenerationContext:
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
from abc import abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import TypedDict
|
||||||
|
|
||||||
|
from moviepy.editor import ImageClip, VideoFileClip
|
||||||
|
|
||||||
from ..BaseEngine import BaseEngine
|
from ..BaseEngine import BaseEngine
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
import base64
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
from typing import Literal, TypedDict
|
from typing import Literal, TypedDict
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import os
|
import base64
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from typing import TypedDict
|
import time
|
||||||
|
from typing import Literal, TypedDict
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import moviepy.editor as mp
|
import moviepy.editor as mp
|
||||||
|
import requests
|
||||||
from google_images_search import GoogleImagesSearch
|
from google_images_search import GoogleImagesSearch
|
||||||
from moviepy.video.fx.resize import resize
|
from moviepy.video.fx.resize import resize
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from abc import abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from moviepy.editor import VideoClip
|
||||||
|
|
||||||
from ..BaseEngine import BaseEngine
|
from ..BaseEngine import BaseEngine
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import time
|
|||||||
import gradio as gr
|
import gradio as gr
|
||||||
import moviepy.editor as mp
|
import moviepy.editor as mp
|
||||||
from moviepy.video.fx.crop import crop
|
from moviepy.video.fx.crop import crop
|
||||||
|
from moviepy.video.fx.resize import resize
|
||||||
|
|
||||||
from . import BaseBackgroundEngine
|
from . import BaseBackgroundEngine
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
import gradio as gr
|
||||||
import moviepy.editor as mp
|
import moviepy.editor as mp
|
||||||
from sqlalchemy.future import select
|
from sqlalchemy.future import select
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from abc import abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from moviepy.editor import TextClip
|
||||||
|
|
||||||
from ..BaseEngine import BaseEngine
|
from ..BaseEngine import BaseEngine
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import gradio as gr
|
import gradio as gr
|
||||||
|
from PIL import ImageFont
|
||||||
from moviepy.editor import TextClip
|
from moviepy.editor import TextClip
|
||||||
|
|
||||||
from . import BaseCaptioningEngine
|
from . import BaseCaptioningEngine
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from abc import abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
import openai
|
||||||
|
|
||||||
from ..BaseEngine import BaseEngine
|
from ..BaseEngine import BaseEngine
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import openai
|
import openai
|
||||||
import orjson
|
import orjson
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
from typing import TypedDict
|
||||||
|
|
||||||
from .. import BaseEngine
|
from .. import BaseEngine
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from abc import abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from ..BaseEngine import BaseEngine
|
from ..BaseEngine import BaseEngine
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
|
|
||||||
from ..BaseEngine import BaseEngine
|
from ..BaseEngine import BaseEngine
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from abc import abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
|
|
||||||
import moviepy.editor as mp
|
import moviepy.editor as mp
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import gradio as gr
|
|||||||
import torch
|
import torch
|
||||||
from TTS.api import TTS
|
from TTS.api import TTS
|
||||||
|
|
||||||
from .BaseTTSEngine import BaseTTSEngine
|
from .BaseTTSEngine import BaseTTSEngine, Word
|
||||||
|
from ...utils.prompting import get_prompt
|
||||||
|
|
||||||
|
|
||||||
class CoquiTTSEngine(BaseTTSEngine):
|
class CoquiTTSEngine(BaseTTSEngine):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import Session, sessionmaker
|
||||||
|
|
||||||
from . import Base
|
from . import Base
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import String, Column, JSON, Integer
|
from sqlalchemy import String, Column, JSON, Integer
|
||||||
from sqlalchemy.ext.mutable import MutableDict
|
from sqlalchemy.ext.mutable import MutableDict
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import String, Column, JSON, Integer
|
from sqlalchemy import String, Column, JSON, Integer
|
||||||
from sqlalchemy.ext.mutable import MutableDict
|
from sqlalchemy.ext.mutable import MutableDict
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import String, Column, JSON, Integer, DateTime
|
from sqlalchemy import String, Column, JSON, Integer, DateTime
|
||||||
from sqlalchemy.ext.mutable import MutableList
|
from sqlalchemy.ext.mutable import MutableList
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import orjson
|
import orjson
|
||||||
|
import sys
|
||||||
|
|
||||||
from src.chore import GenerationContext
|
|
||||||
from src.engines import ENGINES, BaseEngine
|
from src.engines import ENGINES, BaseEngine
|
||||||
|
from src.chore import GenerationContext
|
||||||
|
|
||||||
class GenerateUI:
|
class GenerateUI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -14,7 +12,6 @@ class GenerateUI:
|
|||||||
font-size: 5rem !important
|
font-size: 5rem !important
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_presets(self):
|
def get_presets(self):
|
||||||
with open("local/presets.json", "r") as f:
|
with open("local/presets.json", "r") as f:
|
||||||
return orjson.loads(f.read())
|
return orjson.loads(f.read())
|
||||||
@@ -56,7 +53,6 @@ class GenerateUI:
|
|||||||
def get_settings_interface(self) -> gr.Blocks:
|
def get_settings_interface(self) -> gr.Blocks:
|
||||||
with gr.Blocks() as interface:
|
with gr.Blocks() as interface:
|
||||||
reload_ui = gr.Button("Reload UI", variant="primary")
|
reload_ui = gr.Button("Reload UI", variant="primary")
|
||||||
|
|
||||||
def reload():
|
def reload():
|
||||||
self.ui.close()
|
self.ui.close()
|
||||||
sys.exit("Reload")
|
sys.exit("Reload")
|
||||||
@@ -119,7 +115,6 @@ class GenerateUI:
|
|||||||
value=None
|
value=None
|
||||||
)
|
)
|
||||||
preset_button = gr.Button("Load")
|
preset_button = gr.Button("Load")
|
||||||
|
|
||||||
def load_preset(preset_name, *inputs) -> list[gr.update]:
|
def load_preset(preset_name, *inputs) -> list[gr.update]:
|
||||||
with open("local/presets.json", "r") as f:
|
with open("local/presets.json", "r") as f:
|
||||||
presets = orjson.loads(f.read())
|
presets = orjson.loads(f.read())
|
||||||
@@ -133,8 +128,7 @@ class GenerateUI:
|
|||||||
for engine in engines:
|
for engine in engines:
|
||||||
if engine.name in preset.get(engine_type, {}).keys():
|
if engine.name in preset.get(engine_type, {}).keys():
|
||||||
values[0].append(engine.name)
|
values[0].append(engine.name)
|
||||||
values.extend(
|
values.extend(gr.update(value=value) for value in preset[engine_type][engine.name])
|
||||||
gr.update(value=value) for value in preset[engine_type][engine.name])
|
|
||||||
else:
|
else:
|
||||||
values.extend(gr.update() for _ in range(engine.num_options))
|
values.extend(gr.update() for _ in range(engine.num_options))
|
||||||
returnable.extend(values)
|
returnable.extend(values)
|
||||||
@@ -159,8 +153,7 @@ class GenerateUI:
|
|||||||
presets[preset_name] = new_preset
|
presets[preset_name] = new_preset
|
||||||
f.write(orjson.dumps(presets))
|
f.write(orjson.dumps(presets))
|
||||||
return [gr.update(value=presets.keys()), *returnable]
|
return [gr.update(value=presets.keys()), *returnable]
|
||||||
preset_button.click(load_preset, inputs=[preset_dropdown, *inputs],
|
preset_button.click(load_preset, inputs=[preset_dropdown, *inputs], outputs=[preset_dropdown,*inputs])
|
||||||
outputs=[preset_dropdown, *inputs])
|
|
||||||
output_gallery = gr.Markdown("aaa", render=False)
|
output_gallery = gr.Markdown("aaa", render=False)
|
||||||
button.click(
|
button.click(
|
||||||
self.run_generate_interface,
|
self.run_generate_interface,
|
||||||
@@ -204,8 +197,8 @@ class GenerateUI:
|
|||||||
options[engine_type].append(
|
options[engine_type].append(
|
||||||
engine(options=args[: engine.num_options])
|
engine(options=args[: engine.num_options])
|
||||||
)
|
)
|
||||||
args = args[engine.num_options:]
|
args = args[engine.num_options :]
|
||||||
else:
|
else:
|
||||||
# we don't care about this, it's not the selected engine, we throw it away
|
# we don't care about this, it's not the selected engine, we throw it away
|
||||||
args = args[engine.num_options:]
|
args = args[engine.num_options :]
|
||||||
return options
|
return options
|
||||||
Reference in New Issue
Block a user