Skip to content

Instantly share code, notes, and snippets.

View RodrigoCMoraes's full-sized avatar

RodrigoCMoraes RodrigoCMoraes

  • São Paulo, SP, Brazil
View GitHub Profile
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np
import PIL
def thumb_grid(im_list, grid_shape, fname_out, scale=1.0, axes_pad=0.07, figsize=(7, 7), dpi=900):
assert len(grid_shape) == 2 # Grid must be 2D:
assert np.prod(grid_shape) >= len(im_list) # Make sure all images can fit in grid:
plt.figure(figsize=figsize, dpi=dpi)
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np
import PIL
import cv2
import glob
import os
def apply_plot_style(xlim, ylim, xlabel, ylabel, grid):
plt.clf()
@RodrigoCMoraes
RodrigoCMoraes / siamese.py
Created March 1, 2019 01:50 — forked from vbalnt/siamese.py
train on siamese graph - custom mini batches
'''Train a Siamese MLP on pairs of digits from the MNIST dataset.
It follows Hadsell-et-al.'06 [1] by computing the Euclidean distance on the
output of the shared network and by optimizing the contrastive loss (see paper
for mode details).
[1] "Dimensionality Reduction by Learning an Invariant Mapping"
http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
Run on GPU: THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python mnist_siamese_graph.py
@RodrigoCMoraes
RodrigoCMoraes / docker-install-fedora30.md
Last active June 10, 2019 21:11
Docker installation on Fedora 30 (Unstable)

Run this commands

sudo dnf -y install dnf-plugins-core

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

sudo dnf config-manager --set-enabled docker-ce-test

sudo dnf config-manager --set-disabled docker-ce-stable

@RodrigoCMoraes
RodrigoCMoraes / load_file_from_gdrive.py
Created May 27, 2019 00:37
Getting file from Google Drive by PyDrive
#@title Dataset info { form-width: "800px" }
# e.g GOOGLE_DRIVE_FILE_URL: https://drive.google.com/open?id=1CZyDkHHjS8SUVBF7fBwoTAF6xSpLmD4P7
LinkFile = "GOOGLE_DRIVE_FILE_URL" #@param {type:"string"}
# e.g GOOGLE_DRIVE_FILENAME_WITH_EXTENSION: Local History.csv
Filename = "GOOGLE_DRIVE_FILENAME_WITH_EXTENSION" #@param {type:"string"}
Filename = Filename.replace(' ', '\ ')
@RodrigoCMoraes
RodrigoCMoraes / install-miniconda.sh
Created June 10, 2019 18:20
Install/Reinstall last Miniconda3
#!/bin/bash
if [ -d ~/miniconda3 ]
then
echo "Deleting directory ~/miniconda3..."
rm -rf ~/miniconda3 ~/.conda
@RodrigoCMoraes
RodrigoCMoraes / install-nvidia-docker.sh
Last active May 10, 2024 10:13
Install nvidia docker in Ubuntu 18.04
#1. Update system
sudo apt-get update
#2.Install packages to allow apt to use a repository over HTTPS:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
@RodrigoCMoraes
RodrigoCMoraes / install-docker.sh
Last active November 15, 2019 22:03
Install docker Ubuntu 18.04
wget http://get.docker.com -O docker-install.sh
sudo chmod +x docker-install.sh
./docker-install.sh
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl enable docker
sudo apt-get install -y install docker-compose
sudo reboot
@RodrigoCMoraes
RodrigoCMoraes / install-nvidia-driver.sh
Created June 11, 2019 18:16
install nvidia drivers Ubuntu 18.04
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo ubuntu-drivers autoinstall
sudo reboot
@RodrigoCMoraes
RodrigoCMoraes / spec-file-tensorflow-gpu.txt
Last active January 14, 2021 12:12
Conda environment specs TensorFlow GPU
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
@EXPLICIT
https://repo.anaconda.com/pkgs/main/linux-64/_tflow_select-2.1.0-gpu.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/blas-1.0-mkl.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/ca-certificates-2019.5.15-0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/cudatoolkit-10.0.130-0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/intel-openmp-2019.4-243.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/libgcc-ng-9.1.0-hdf63c60_0.tar.bz2