Skip to content

Commit

Permalink
Merge branch 'release/0.1.22'
Browse files Browse the repository at this point in the history
  • Loading branch information
ControlNet committed Nov 5, 2021
2 parents 7b99e20 + 574de3a commit 9061c23
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 26 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ clean-fid >= 0.1.12, < 0.1.14
pandas >= 1.3.1
ipython >= 7.26.0
pygments >= 2.9.0
pysoundfile >= 0.9.0; platform_system == "Windows"
6 changes: 5 additions & 1 deletion src/tensorneko/neko_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from pytorch_lightning.accelerators import Accelerator
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import TensorBoardLogger
from pytorch_lightning.plugins import Plugin
try:
from pytorch_lightning.plugins import Plugin # for pytorch_lightning < 1.5.x
except ImportError:
from pytorch_lightning.plugins import PLUGIN as Plugin # for pytorch_lightning >= 1.5.x

from pytorch_lightning.plugins.environments import ClusterEnvironment
from pytorch_lightning.profiler import BaseProfiler

Expand Down
21 changes: 13 additions & 8 deletions src/tensorneko/preprocess/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def resize_image(tensor: Tensor, size: Tuple[int, int], resize_method: Union[Res
return f(tensor)


def resize_video(tensor: Tensor, size: Tuple[int, int], resize_method: Union[ResizeMethod, str] = ResizeMethod.BICUBIC
def resize_video(tensor: Tensor, size: Tuple[int, int], resize_method: Union[ResizeMethod, str] = ResizeMethod.BICUBIC,
fast = False
) -> Tensor:
"""
Resizing a video to determined size.
Expand All @@ -80,17 +81,21 @@ def resize_video(tensor: Tensor, size: Tuple[int, int], resize_method: Union[Res
tensor (:class:`~torch.Tensor`): Video tensor (T, C, H, W)
size ((``int``, ``int``)): Target size (H, W)
resize_method (:class:`ResizeMethod`, optional): Resize method. Default bicubic.
fast (bool, optional): If True, use fast mode (pytorch F.interpolate). Default False.
Returns:
:class:`~torch.Tensor`: The resized video.
"""
resize_method = _get_enum_value(resize_method, ResizeMethod)
image_resizer = F(resize_image, size=size, resize_method=resize_method) \
>> F(rearrange, pattern="c h w -> 1 c h w")
f = F(map, image_resizer) \
>> list \
>> torch.vstack
return f(tensor)
if not fast:
resize_method = _get_enum_value(resize_method, ResizeMethod)
image_resizer = F(resize_image, size=size, resize_method=resize_method) \
>> F(rearrange, pattern="c h w -> 1 c h w")
f = F(map, image_resizer) \
>> list \
>> torch.vstack
return f(tensor)
else:
return func.interpolate(tensor, size, mode=_get_enum_value(resize_method, ResizeMethod), align_corners=False)


def _get_padding_pair(padding_size: int, padding_position: Union[PaddingPosition, str]) -> List[int]:
Expand Down
24 changes: 24 additions & 0 deletions src/tensorneko/visualization/color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from enum import Enum


class Colors(Enum):
GREEN = "#C3E88D"
YELLOW = "#FFCB6B"
RED = "#F07178"
BLUE = "#82AAFF"
PURPLE = "#C792EA"
ORANGE = "#F78C6C"
AZURE = "#467CDA"
SKY = "#89DDFF"
BLACK = "#2B2B2B"
GRAY = "#616161"
WHITE = "#EEFFFF"
BLANK = "#FFFFFF"


class ContinuousColors(Enum):
RED = "#d11141",
YELLOW = "#ffc425",
GREEN = "#00b159",
BLACK = "#2B2B2B",
WHITE = "#EEFFFF"
12 changes: 12 additions & 0 deletions src/tensorneko/visualization/seaborn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import seaborn as sns

from .color import Colors

palette = sns.color_palette([
Colors.BLUE.value,
Colors.ORANGE.value,
Colors.GREEN.value,
Colors.RED.value,
Colors.PURPLE.value,
Colors.AZURE.value,
Colors.GRAY.value,
Colors.YELLOW.value
])

barplot = sns.barplot
4 changes: 2 additions & 2 deletions src/tensorneko/visualization/watcher/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ def _run(self) -> None:
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT
)
print(f"Server started at port {self.port}, view \"{self.view_name}\".")
print(f"Server started at http://127.0.0.1:{self.port}/, view \"{self.view_name}\".")

def _run_blocking(self):
self.process = subprocess.run(["python", "-m", "http.server", "--directory",
os.path.join("watcher", self.view_name), str(self.port)])
print(f"Server started at port {self.port}, view \"{self.view_name}\".")
print(f"Server started at http://127.0.0.1:{self.port}/, view \"{self.view_name}\".")

def stop(self) -> None:
"""
Expand Down
5 changes: 4 additions & 1 deletion src/tensorneko/visualization/watcher/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def _to_json(self) -> None:
os.mkdir(view_path)

write.text.to_json(os.path.join("watcher", self.name, "data.json"),
list(map(lambda comp: comp.to_dict(), self.components))
{
"view": self.name,
"data": list(map(lambda comp: comp.to_dict(), self.components))
}
)

def add(self, *components: Component) -> View:
Expand Down
7 changes: 5 additions & 2 deletions src/tensorneko/visualization/watcher/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<h2 class="display-2">Tensorneko Web Watcher</h2>
<h2 class="display-2">Tensorneko Web Watcher::{{view}}</h2>
<div class="row mb-3">
<label class="col-sm-2 col-form-label" style="width: 200px">Update Rate (ms)</label>
<div class="col-sm-10" style="width: 200px;"><input type="number" class="form-control" placeholder="1000"
Expand Down Expand Up @@ -40,6 +40,7 @@ export default class App extends Vue {
readonly logs = logs
readonly lineCharts = lineCharts
updateDuration = 5000
view: string = null
$refs!: {
progressbar: ProgressBarTable,
Expand All @@ -65,7 +66,9 @@ export default class App extends Vue {
}
}
json.forEach((d: ComponentData) => {
this.view = json.view;
json.data.forEach((d: ComponentData) => {
if (d.type === "Variable") {
updateArray(d, this.variables);
} else if (d.type === "ProgressBar") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class LineChartCard extends Vue {
type: "line"
},
formatter: (params: CallbackDataParams) => {
return `${this.xLabel}: ${Math.round(params[0].data[0] * 10000) / 10000}\n` +
return `${this.xLabel}: ${Math.round(params[0].data[0] * 10000) / 10000}<br/>` +
`${this.yLabel}: ${Math.round(params[0].data[1] * 10000) / 10000}`
}
};
Expand Down
10 changes: 0 additions & 10 deletions src/tensorneko/visualization/watcher/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@ import { createApp } from 'vue'
import BootstrapVue3 from "bootstrap-vue-3";
import App from './App.vue'
import { App as AppRuntime } from "vue"
import { ComponentData, ProgressBarData, progressbars, VariableData, variables } from "@/data";
import "../node_modules/bootstrap/dist/css/bootstrap.min.css";


async function initApp(): Promise<AppRuntime<Element>> {
const response = await fetch(`data.json`);
const json = await response.json().catch(() => []);
json.forEach((d: ComponentData) => {
if (d.type === "Variable") {
variables[d.name] = d as VariableData;
} else if (d.type === "ProgressBar") {
progressbars[d.name] = d as ProgressBarData;
}
})
return createApp(App)
}

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.21
0.1.22

0 comments on commit 9061c23

Please sign in to comment.