Skip to content

Instantly share code, notes, and snippets.

View iraadit's full-sized avatar

Renaud Bouckenooghe iraadit

View GitHub Profile
@iraadit
iraadit / augmentation.py
Created February 22, 2018 14:25 — forked from mlgruby/augmentation.py
code snippet for image augmentation
from skimage.transform import rotate
from skimage.transform import warp
from skimage.transform import ProjectiveTransform
def rotate(Xb, intensity, batch_size):
"""
Random Rotation to Image
"""
for i in Xb.shape[0]:
@iraadit
iraadit / gist:b8ca1e502ba6fe62a0d2ead2953c3069
Created February 22, 2018 14:26 — forked from Grabber/gist:de8a2b7de587cf8e58f4e3f6bb55cf23
calculating priori anchors with k-means
# -*- coding: utf-8 -*-
import time
import numpy as np
from random import randint
iou_vals = []
iou_count = 0
class Test:
@iraadit
iraadit / tensorflow_confusion_metrics.py
Created February 22, 2018 14:28 — forked from Mistobaan/tensorflow_confusion_metrics.py
Confusion Metrics written in tensorflow format
# from https://cloud.google.com/solutions/machine-learning-with-financial-time-series-data
def tf_confusion_metrics(model, actual_classes, session, feed_dict):
predictions = tf.argmax(model, 1)
actuals = tf.argmax(actual_classes, 1)
ones_like_actuals = tf.ones_like(actuals)
zeros_like_actuals = tf.zeros_like(actuals)
ones_like_predictions = tf.ones_like(predictions)
zeros_like_predictions = tf.zeros_like(predictions)
@iraadit
iraadit / README-Template.md
Created February 22, 2018 14:28 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

ffmpeg -i shame-run.mov -r 24/1 test/output%03d.jpg
@iraadit
iraadit / reinstall.sh
Created February 23, 2018 15:51 — forked from 8enmann/reinstall.sh
Reinstall NVIDIA drivers without opengl Ubuntu 16.04 GTX 1080ti
# Download installers
mkdir ~/Downloads/nvidia
cd ~/Downloads/nvidia
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/384.59/NVIDIA-Linux-x86_64-384.59.run
sudo chmod +x NVIDIA-Linux-x86_64-384.59.run
sudo chmod +x cuda_8.0.61_375.26_linux-run
./cuda_8.0.61_375.26_linux-run -extract=~/Downloads/nvidia/
# Uninstall old stuff
sudo apt-get --purge remove nvidia-*
047d20b52defb3c86ecf1ddf2e84ae8847d18abfde3e3542b4a0a1f11b6f12614778fe3399a95e951ac367c6a9daf56a1cd93880504d47c487a50e1a0f2623c936

Convert PascalVOC Annotations to YOLO

This script reads PascalVOC xml files, and converts them to YOLO txt files.

Note: This script was written and tested on Ubuntu. YMMV on other OS's.

Disclaimer: This code is a modified version of Joseph Redmon's voc_label.py

Instructions:

  1. Place the convert_voc_to_yolo.py file into your data folder.
@iraadit
iraadit / crop_classes.md
Created January 14, 2019 21:10 — forked from vdalv/crop_classes.md
This script reads PascalVOC xml files, and crops the class instances into seperate image files.

Export Class Images from PascalVOC Annotations

This script reads PascalVOC xml files, and crops the class instances into seperate image files.

Note: This script relies on ImageMagick for the crop (convert) functionality. It comes pre-installed on most recent versions of Ubuntu.

Disclaimer: This code is a modified version of Dat Tran's xml_to_csv.py

Example:

Let's say we have this image in our train folder:

Bulk Downloading With The Ability to Specify Individual Filenames

After a few hours of searching, I've finally found a convenient way to download a large amount of files in a bulk/multi-threaded/parallel manner, while still having the ability to specify the saved files' names.

Many thanks to Diego Torres Milano

The input file (dl_data.txt):

bird_4345_543.jpg https://example.com/pictures/5351/image.jpg
bird_4345_544.jpg https://example.com/5352/pictures/image.jpg