Skip to content

Instantly share code, notes, and snippets.

@GuillaumeDua
GuillaumeDua / 13_valuable_things_I_learned_using_CMake.md
Last active August 3, 2024 20:02
13 valuable things I learned using CMake

13 valuable things I learned using CMake

Author : Dua Guillaume
Date : 04-26-2020

Requirement : A first experience with CMake

Intro

As a modern C++ specialist, my job is to focus on software development, from a performance and quality perspective.

@raulqf
raulqf / Install_OpenCV4_CUDA12.6_CUDNN8.9.md
Last active September 10, 2024 08:07
How to install OpenCV 4.10 with CUDA 12 in Ubuntu 24.04

Install OpenCV 4.10 with CUDA 12.6 and CUDNN 8.9 in Ubuntu 24.04

First of all install update and upgrade your system:

    $ sudo apt update
    $ sudo apt upgrade

Then, install required libraries:

@Mahedi-61
Mahedi-61 / cuda_11.8_installation_on_Ubuntu_22.04
Last active September 18, 2024 16:04
Instructions for CUDA v11.8 and cuDNN 8.9.7 installation on Ubuntu 22.04 for PyTorch 2.1.2
#!/bin/bash
### steps ####
# Verify the system has a cuda-capable gpu
# Download and install the nvidia cuda toolkit and cudnn
# Setup environmental variables
# Verify the installation
###
### to verify your gpu is cuda enable check
@peteflorence
peteflorence / pytorch_bilinear_interpolation.md
Last active June 30, 2024 01:26
Bilinear interpolation in PyTorch, and benchmarking vs. numpy

Here's a simple implementation of bilinear interpolation on tensors using PyTorch.

I wrote this up since I ended up learning a lot about options for interpolation in both the numpy and PyTorch ecosystems. More generally than just interpolation, too, it's also a nice case study in how PyTorch magically can put very numpy-like code on the GPU (and by the way, do autodiff for you too).

For interpolation in PyTorch, this open issue calls for more interpolation features. There is now a nn.functional.grid_sample() feature but at least at first this didn't look like what I needed (but we'll come back to this later).

In particular I wanted to take an image, W x H x C, and sample it many times at different random locations. Note also that this is different than upsampling which exhaustively samples and also doesn't give us fle

@mbinna
mbinna / effective_modern_cmake.md
Last active September 16, 2024 15:44
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@bartolsthoorn
bartolsthoorn / multilabel_example.py
Created April 29, 2017 12:13
Simple multi-laber classification example with Pytorch and MultiLabelSoftMarginLoss (https://en.wikipedia.org/wiki/Multi-label_classification)
import torch
import torch.nn as nn
import numpy as np
import torch.optim as optim
from torch.autograd import Variable
# (1, 0) => target labels 0+2
# (0, 1) => target labels 1
# (1, 1) => target labels 3
train = []
@oeway
oeway / imageUtils.py
Last active May 8, 2024 14:21
Improved image transform functions for dense predictions (for pytorch, keras etc.)
import numpy as np
import scipy
import scipy.ndimage
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.interpolation import map_coordinates
import collections
from PIL import Image
import numbers
__author__ = "Wei OUYANG"
@felixgwu
felixgwu / fc_densenet.py
Created April 2, 2017 05:22
FC-DenseNet Implementation in PyTorch
import torch
from torch import nn
__all__ = ['FCDenseNet', 'fcdensenet_tiny', 'fcdensenet56_nodrop',
'fcdensenet56', 'fcdensenet67', 'fcdensenet103',
'fcdensenet103_nodrop']
class DenseBlock(nn.Module):
@Starl1ght
Starl1ght / main.cpp
Created March 26, 2017 21:32
Console
#include <vector>
#include <sstream>
#include <iostream>
#include <iterator>
#include <tuple>
template <typename T>
std::vector<std::string> Split(T&& input) {
std::stringstream ss{ std::forward<T>(input) };
return std::vector<std::string> {std::istream_iterator<std::string>(ss), std::istream_iterator<std::string>{} };
@meetps
meetps / computeIoU.py
Created February 11, 2017 14:02
Intersection over Union for Python [ Keras ]
import numpy as np
def computeIoU(y_pred_batch, y_true_batch):
return np.mean(np.asarray([pixelAccuracy(y_pred_batch[i], y_true_batch[i]) for i in range(len(y_true_batch))]))
def pixelAccuracy(y_pred, y_true):
y_pred = np.argmax(np.reshape(y_pred,[N_CLASSES_PASCAL,img_rows,img_cols]),axis=0)
y_true = np.argmax(np.reshape(y_true,[N_CLASSES_PASCAL,img_rows,img_cols]),axis=0)
y_pred = y_pred * (y_true>0)