Skip to content

Instantly share code, notes, and snippets.

View ksugar's full-sized avatar

Sugawara Ko ksugar

  • RIKEN BDR
View GitHub Profile
@ksugar
ksugar / keras_weighted_binary_crossentropy.py
Last active February 9, 2019 14:27
Custom loss function for weighted binary crossentropy in Keras with Tensorflow
# code picked up from https://github.com/keras-team/keras/blob/master/keras/backend/tensorflow_backend.py
# Just used tf.nn.weighted_cross_entropy_with_logits instead of tf.nn.sigmoid_cross_entropy_with_logits with input pos_weight in calculation
import tensorflow as tf
from keras import backend as K
""" Weighted binary crossentropy between an output tensor and a target tensor.
# Arguments
pos_weight: A coefficient to use on the positive examples.
# Returns
#!/usr/bin/env python
import argparse
from pathlib import Path
from timagetk.io import imread
from timagetk.io import imsave
def main(args):
pin = Path(args.input)
@ksugar
ksugar / elephant_detection.py
Last active August 22, 2023 16:33
Run inference with an ELEPHANT detection model and export the results in CTC format
#! /usr/bin/env python
# ==============================================================================
# Copyright (c) 2023, Ko Sugawara
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.