Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Make everyone's life more fun using AI

Junho Kim taki0112

:octocat:
Make everyone's life more fun using AI
View GitHub Profile
@yunjey
yunjey / contextual_loss.py
Created Sep 20, 2018
pytorch implementation of contextual loss: https://arxiv.org/abs/1803.02077
View contextual_loss.py
def contextual_loss(x, y, h=0.5):
"""Computes contextual loss between x and y.
Args:
x: features of shape (N, C, H, W).
y: features of shape (N, C, H, W).
Returns:
cx_loss = contextual loss between x and y (Eq (1) in the paper)
"""
View safe_queue_runners.py
import tensorflow as tf
import numpy as np
import os
import matplotlib.pyplot as plt
%matplotlib inline
file_dir = os.path.join(os.getcwd(), "dataset/test_dataset_png")
image_paths = [os.path.join(file_dir, i) for i in os.listdir(file_dir)]
View cnn_with_tensorboard.py
import tensorflow as tf
import matplotlib.pyplot as plt
import os
%matplotlib inline
tf.reset_default_graph()
images = "dataset/test_dataset_png/"
image_dir = os.path.join(os.getcwd(), images)
imagenames = [os.path.join(image_dir, f) for f in os.listdir(image_dir)]