Skip to content

Instantly share code, notes, and snippets.

View rahatsantosh's full-sized avatar

Rahat Santosh rahatsantosh

  • Edinburgh
View GitHub Profile
@chauhan-utk
chauhan-utk / file.md
Created March 10, 2018 13:53
PyTorch replace pretrained model layers

This code snippet shows how we can change a layer in a pretrained model. In the following code, we change all the ReLU activation functions with SELU in a resnet18 model.

import torch
from torchvision import model

resnet18 = model.resnet18(pretrained=True)

def funct(list_mods):
@fabito
fabito / layers.txt
Last active January 21, 2022 21:20
YOLO v3 Layers
layer filters size input output
0 conv 32 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 32
1 conv 64 3 x 3 / 2 416 x 416 x 32 -> 208 x 208 x 64
2 conv 32 1 x 1 / 1 208 x 208 x 64 -> 208 x 208 x 32
3 conv 64 3 x 3 / 1 208 x 208 x 32 -> 208 x 208 x 64
4 Shortcut Layer: 1
5 conv 128 3 x 3 / 2 208 x 208 x 64 -> 104 x 104 x 128
6 conv 64 1 x 1 / 1 104 x 104 x 128 -> 104 x 104 x 64
7 conv 128 3 x 3 / 1 104 x 104 x 64 -> 104 x 104 x 128
8 Shortcut Layer: 5
@aplz
aplz / draw_text_with_background_opencv.py
Last active September 3, 2023 22:56
draw text with background // opencv
import cv2 # opencv
import numpy as np
font_scale = 1.5
font = cv2.FONT_HERSHEY_PLAIN
# set the rectangle background to white
rectangle_bgr = (255, 255, 255)
# make a black image
img = np.zeros((500, 500))