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
import tensorflow as tf | |
from tensorflow import keras | |
class ColorJitter(keras.layers.Layer): | |
def __init__( | |
self, | |
brightness_factor=0.5, | |
contrast_factor=(0.5, 0.9), | |
saturation_factor=(0.5, 0.9), | |
hue_factor=0.5, |
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
import tensorflow as tf | |
from tensorflow import keras | |
class ChannelShuffle(keras.layers.Layer): | |
def __init__(self, groups=3, seed=None, **kwargs): | |
super().__init__(**kwargs) | |
self.groups = groups | |
self.seed = seed | |
def _channel_shuffling(self, images): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 repo: https://github.com/isears/tf_clahe | |
# check https://github.com/isears/tf_clahe/issues/1#issuecomment-1356676495 | |
!pip install -q --no-deps /kaggle/input/tfpackages/tf_clahe-0.1.0-py3-none-any.whl | |
``` | |
import tf_clahe | |
class CLAHE(keras.layers.Layer): | |
def __init__( |
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
import tensorflow as tf | |
def weighted_binary_loss(weight, from_logits=True, reduction="mean"): | |
def inverse_sigmoid(sigmoidal): | |
return - tf.math.log(1. / sigmoidal - 1.) | |
def weighted_loss(labels, predictions): | |
predictions = tf.convert_to_tensor(predictions) | |
labels = tf.cast(labels, predictions.dtype) | |
num_samples = tf.cast(tf.shape(labels)[-1], dtype=labels.dtype) |
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
# Base Image: Ubuntu + Cuda | |
FROM nvidia/cuda:11.0.3-devel-ubuntu20.04 AS python_base_cuda | |
# ENV SET | |
ENV PYTHONUNBUFFERED=1 \ | |
PYTHONFAULTHANDLER=1 \ | |
PYTHONHASHSEED=random \ | |
PYTHONDONTWRITEBYTECODE=1 \ | |
PIP_NO_CACHE_DIR=off \ | |
PIP_DISABLE_PIP_VERSION_CHECK=on \ |
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
""" | |
Reference | |
# https://github.com/fuenwang/PanoramaUtility | |
# https://github.com/fuenwang/Equirec2Perspec | |
# https://github.com/fuenwang/PanoramaUtility | |
# https://github.com/timy90022/Perspective-and-Equirectangular | |
""" | |
import os | |
import sys |
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
# RESTRICT TENSORFLOW TO 2GB OF GPU RAM | |
# SO THAT WE HAVE 14GB RAM free | |
LIMIT = 2.0 | |
gpus = tf.config.experimental.list_physical_devices('GPU') | |
if gpus: | |
try: | |
tf.config.experimental.set_virtual_device_configuration( | |
gpus[0], | |
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=1024*LIMIT)]) | |
logical_gpus = tf.config.experimental.list_logical_devices('GPU') |
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
class WarmupLearningRateSchedule(optimizers.schedules.LearningRateSchedule): | |
"""WarmupLearningRateSchedule a variety of learning rate | |
decay schedules with warm up.""" | |
def __init__( | |
self, | |
initial_lr, | |
steps_per_epoch=None, | |
lr_decay_type="exponential", | |
decay_factor=0.97, |