Closed pravdomil closed 3 months ago
what do you think?
here is the intended usage:
config = config_from_directory( style_path = "styles", input_path = "input", edge_method = "Classic", flow_method = "RAFT", model_name = "sintel", ) guides = create_guides(config) sequences = create_sequences(config) images = process(config, guides, sequences) output_folder = "output" os.makedirs(output_folder, exist_ok = True) for i, image in enumerate(images): cv2.imwrite(os.path.join(output_folder, "output" + str(i).zfill(3) + ".png"), image)
@dataclass class Config: styles: List[tuple[int, numpy.ndarray]] images: List[tuple[int, numpy.ndarray]] edge_method: Literal["PAGE", "PST", "Classic"] flow_method: Literal["RAFT", "DeepFlow"] model_name: Literal["sintel", "kitti", "chairs"] @dataclass class Guides: edge: List[numpy.ndarray] flow_rev: List[numpy.ndarray] flow_fwd: List[numpy.ndarray] positional_rev: List[numpy.ndarray] positional_fwd: List[numpy.ndarray]
I like it--- separates concerns and makes a bit clearer.
Not sure if its something you had planned on messing about with, but I do see it being useful combining Ezsynth and ImageSynth classes into one class, and possibly being able to use/manipulate it as you've shown above.
Another good point on your changes, I think it will make it easier to integrate custom guides into the process, a feature I've been wanting to add for extra customization. I guess this would also allow users to perform different processing steps and such without having to necessarily start and run the entire process in one go?
Outside of that, I apologize for my naivety, but from what I can tell, these changes are primarily centered around readability/maintainability and separation of concerns?
I'm still learning around all of this-- I had refactored once already (previous lib versions were disgustingly mismatched and spread all over the place.) I'm guessing that doing so not only helps with maintaining and reusing the code, but also as we work towards improving performance?
Thanks for all of your support so far!
discord
proposal...
import cv2
from ezsynth.ebsynth import Ebsynth, Config
ebsynth = Ebsynth()
config = Config(style_image = "input/000.jpg", guides = [("input/000.jpg", "styles/style000.jpg", 0.5)])
image, error = ebsynth(config)
cv2.imwrite("output/000.jpg", image)
import cv2
from ezsynth.visynth import Visynth, Config, image_sequence_from_directory
visynth = Visynth()
config = Config(
frames = image_sequence_from_directory("input"),
style_frames = image_sequence_from_directory("styles"),
)
images = visynth(config)
for i, image in images:
cv2.imwrite("output/output" + str(i).zfill(3) + ".jpg", image)
what do you think?
here is the intended usage: