Skip to content

Commit ced0463

Browse files
authored
Merge pull request #9 from esologic/remove_complexity_change
Remove complexity change
2 parents cbedbc8 + fc84f65 commit ced0463

6 files changed

Lines changed: 436 additions & 317 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
0.20.0 - (2022-03-29)
4+
------------------
5+
6+
* In `music_into_models.py projection-file-blend`, the notion of connecting overlay appearances
7+
with audio activity has been removed, meaning `--complexity-change-rolling-sum-window` and
8+
`--complexity-change-threshold` are disabled. This functionality was underdeveloped, and didn't
9+
really work in a predictable way. The functionality will still be there in
10+
`projection_file_blend_api`, just not accessible via the CLI.
11+
* In the same script, if `--phash-distance`, `--bbox-distance` and `--track-length` aren't provided,
12+
overlays won't be computed in the resulting videos.
13+
14+
315
0.19.0 - (2022-03-06)
416
------------------
517

gance/image_sources/video_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def write_frame(frame: RGBInt8ImageType) -> None:
278278
temp_video_path = Path(file.name)
279279
yield from setup_iteration(temp_video_path)
280280
file.flush()
281+
LOGGER.info(f"Finalizing {video_path}")
281282
add_wavs_to_video(
282283
video_path=temp_video_path, audio_paths=audio_paths, output_path=video_path
283284
)

gance/network_interface/network_functions.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Functions to be able to load networks from disk and interact with them.
33
Working with these networks can be messy and this module tries to only expose the important things.
44
"""
5-
5+
import json
66
import logging
77
import multiprocessing
88
import os
@@ -17,6 +17,8 @@
1717

1818
import numpy as np
1919
import PIL
20+
import pydantic
21+
from pydantic import BaseModel, FilePath
2022
from typing_extensions import Protocol
2123

2224
from gance import process_common
@@ -623,3 +625,61 @@ def network_indices(self: "MultiNetwork") -> List[int]:
623625
:return: Indices
624626
"""
625627
return [index for index, _ in enumerate(self._network_paths)]
628+
629+
@property
630+
def network_paths(self: "MultiNetwork") -> List[Path]:
631+
"""
632+
Exposes the network paths for reading.
633+
:return: Paths to the network files
634+
"""
635+
return self._network_paths
636+
637+
638+
def parse_network_paths(
639+
networks_directory: Optional[str], networks: Optional[List[str]], networks_json: Optional[str]
640+
) -> List[Path]:
641+
"""
642+
Given the user's input from the CLI, get a list of the networks to be used in the run.
643+
:param networks_directory: A string representing a path to a directory that contains network
644+
files. Optionally given.
645+
:param networks: Paths (as strings) leading directly to networks. Optionally given.
646+
:param networks_json: Path to a json file with a list of network paths.
647+
:return: Path objects leading to the networks. Sorted by filename.
648+
:raises ValueError: If something goes wrong with a parse.
649+
"""
650+
651+
all_networks = []
652+
653+
if networks_directory is not None:
654+
networks_directory_path = Path(networks_directory)
655+
all_networks += sorted_networks_in_directory(networks_directory=networks_directory_path)
656+
657+
if networks is not None:
658+
all_networks += list(map(Path, networks))
659+
660+
if networks_json is not None:
661+
LOGGER.info(f"Loading network JSON: {networks_json}")
662+
try:
663+
with open(networks_json) as f:
664+
all_networks += list(map(Path, NetworksFile(**json.load(f)).networks))
665+
except pydantic.error_wrappers.ValidationError as e:
666+
raise ValueError("Ran into formatting problem with networks JSON.") from e
667+
except Exception as e:
668+
raise ValueError("Couldn't open networks JSON.") from e
669+
670+
if not all_networks:
671+
raise ValueError("No networks given, cannot continue.")
672+
673+
LOGGER.info("Discovered networks: ")
674+
for path in all_networks:
675+
LOGGER.info(f"\t{path}")
676+
677+
return all_networks
678+
679+
680+
class NetworksFile(BaseModel):
681+
"""
682+
Describes a `NetworksFile`, a .json file full paths to pickled StyleGAN networks.
683+
"""
684+
685+
networks: List[FilePath]

0 commit comments

Comments
 (0)