Skip to content

Instantly share code, notes, and snippets.

View brunodoamaral's full-sized avatar

Bruno Guberfain do Amaral brunodoamaral

View GitHub Profile
@brunodoamaral
brunodoamaral / Table.java
Created March 1, 2015 20:59
A simple Table for Java
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
/**
* Created by Bruno on 01/03/2015.
*
* Table with type R for rows, C for columns and V for values
*
@brunodoamaral
brunodoamaral / rgbFloatToInt.java
Created March 14, 2015 21:55
Java code to convert a float RGB to int RGB
// Convert a float RGB to int RGB. Note: does not check for floats outside range (0..1)
public static int rgbFloatToInt(float r, float g, float b) {
return ((int) (0xff * b)) | (((int) (0xff * g)) << 8 ) | (((int) (0xff * r)) << 16 ) ;
}
@brunodoamaral
brunodoamaral / _dice.py
Last active March 16, 2024 18:00 — forked from JDWarner/_dice.py
Dice coefficient between two boolean NumPy arrays or array-like data. This is commonly used as a set similarity measurement (though note it is not a true metric; it does not satisfy the triangle inequality). The dimensionality of the input is completely arbitrary, but `im1.shape` and `im2.shape` much be equal. This Gist is licensed under the mod…
def dice(im1, im2, empty_score=1.0):
"""
Computes the Dice coefficient, a measure of set similarity.
Parameters
----------
im1 : array-like, bool
Any array of arbitrary size. If not boolean, will be converted.
im2 : array-like, bool
Any other array of identical size. If not boolean, will be converted.
Returns
from torch.autograd import Variable
import torch.nn as nn
import torch
# LSTM
hidden_size = 20
num_layers = 2
num_directions = 1
# Input
@brunodoamaral
brunodoamaral / cmake-build.sh
Created April 26, 2018 16:02
Compile OpenCV 3.1.0 on Centos 6.9 with Anaconda 3
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/path/to/anaconda3/ \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D BUILD_OPENCV_PYTHON3=OFF \
-D BUILD_OPENCV_PYTHON2=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_JPEG=ON \
@brunodoamaral
brunodoamaral / tensorboard_events_to_csv.py
Last active August 30, 2018 13:12 — forked from ptschandl/tensorboard_events_to_csv.py
Extract all tensorboard events files to pandas dataframe
import tensorflow as tf
from pathlib import Path
import pandas as pd
from tqdm import tqdm
from collections import defaultdict
# Get all event* runs from logging_dir subdirectories
logging_dir = Path('.', 'logs')
event_paths = logging_dir.glob('**/event*')