-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor `kimm.blocks` * Update * Export model apis * Update apis * Fix version * Update CI * Update CI * Update `release.yml` * Update tests * Speed up tests * Update keras version * Update keras version
- Loading branch information
1 parent
6309e06
commit 2160b3e
Showing
109 changed files
with
1,325 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import namex | ||
|
||
from kimm._src.version import __version__ | ||
|
||
namex.generate_api_files(package="kimm", code_directory="_src") | ||
|
||
# Add version string | ||
|
||
with open("kimm/__init__.py", "r") as f: | ||
contents = f.read() | ||
with open("kimm/__init__.py", "w") as f: | ||
contents += f'__version__ = "{__version__}"\n' | ||
f.write(contents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
"""DO NOT EDIT. | ||
This file was autogenerated. Do not edit it by hand, | ||
since your modifications would be overwritten. | ||
""" | ||
|
||
from kimm import blocks | ||
from kimm import export | ||
from kimm import layers | ||
from kimm import models | ||
from kimm import timm_utils | ||
from kimm import utils | ||
from kimm.utils.model_registry import list_models | ||
from kimm._src.utils.model_registry import list_models | ||
from kimm._src.version import version | ||
|
||
__version__ = "0.2.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import typing | ||
|
||
from keras import backend | ||
from keras import layers | ||
|
||
from kimm._src.kimm_export import kimm_export | ||
from kimm._src.utils.make_divisble import make_divisible | ||
|
||
|
||
@kimm_export(parent_path=["kimm.blocks"]) | ||
def apply_se_block( | ||
inputs, | ||
se_ratio: float = 0.25, | ||
activation: typing.Optional[str] = "relu", | ||
gate_activation: typing.Optional[str] = "sigmoid", | ||
make_divisible_number: typing.Optional[int] = None, | ||
se_input_channels: typing.Optional[int] = None, | ||
name: str = "se_block", | ||
): | ||
channels_axis = -1 if backend.image_data_format() == "channels_last" else -3 | ||
input_channels = inputs.shape[channels_axis] | ||
if se_input_channels is None: | ||
se_input_channels = input_channels | ||
if make_divisible_number is None: | ||
se_channels = round(se_input_channels * se_ratio) | ||
else: | ||
se_channels = make_divisible( | ||
se_input_channels * se_ratio, make_divisible_number | ||
) | ||
|
||
x = inputs | ||
x = layers.GlobalAveragePooling2D( | ||
data_format=backend.image_data_format(), | ||
keepdims=True, | ||
name=f"{name}_mean", | ||
)(x) | ||
x = layers.Conv2D( | ||
se_channels, 1, use_bias=True, name=f"{name}_conv_reduce" | ||
)(x) | ||
if activation is not None: | ||
x = layers.Activation(activation, name=f"{name}_act1")(x) | ||
x = layers.Conv2D( | ||
input_channels, 1, use_bias=True, name=f"{name}_conv_expand" | ||
)(x) | ||
if activation is not None: | ||
x = layers.Activation(gate_activation, name=f"{name}_gate")(x) | ||
x = layers.Multiply(name=name)([inputs, x]) | ||
return x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.