Skip to content

Instantly share code, notes, and snippets.

View sborquez's full-sized avatar
🤖
AI means love in chinese

Sebastián Bórquez sborquez

🤖
AI means love in chinese
View GitHub Profile
@sborquez
sborquez / argparse.py
Created July 3, 2019 02:23
Use cmd arguments with ArgParse and Python.
import argparse
ap = argparse.ArgumentParser(description="Script Description")
ap.add_argument("-s", "--string", required=True, help="Argument help.", type=str)
ap.add_argument("-n", "--number", default=0.0, help="Argument help.", type=float)
ap.add_argument("-l", "--list", nargs="+", type=int)
ap.add_argument('--feature1', dest='feature1', action='store_true')
ap.add_argument('--no-feature2', dest='feature2', action='store_false')
ap.set_defaults(feature1=False, feature2=True)
@sborquez
sborquez / log.py
Last active February 6, 2020 22:02 — forked from nguyenkims/log.py
Basic example on how setup a Python logger
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FILE = "my_app.log"
def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)
@sborquez
sborquez / opencv_utils_video.py
Last active November 9, 2019 23:56
OpenCV python utils
import cv2
from os import path
from math import floor
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
#from tqdm import tqdm_notebook as tqdm # for jupyter notebooks
# Video to Frame
def get_frame(video, second, save_folder=None, prefix="frame", resize=None, to_rgb=True, prefix_padding=4):
@sborquez
sborquez / download_images.py
Created August 15, 2019 07:08
Create dataset from Google Images
"""
Use this script to download the images from the url.txt, then is necesary to manual prunning irrelevant images from our dataset
"""
# import the necessary packages
from imutils import paths
import argparse
import requests
import cv2
@sborquez
sborquez / keras_bottleneck.py
Last active November 3, 2019 15:19
Find the bottleneck of your model.
import tensorflow as tf
from tensorflow.python.client import timeline
import keras
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata= tf.RunMetadata()
@sborquez
sborquez / rename_submissions.py
Last active January 12, 2020 03:16
Moodle utils scripts
import os
import glob
from tqdm import tqdm
from collections import Counter
def rename_submissions(submissions_folder, output_folder=None):
"""
Rename submissions downloaded from Moodle (download all submissions option).
Use it when the name of the submited files are differents between each student
and contains identification info in it.
@sborquez
sborquez / hello_tf.cpp
Last active January 16, 2020 13:09
Install Tensorflow for C/C++
#include <stdio.h>
#include <tensorflow/c/c_api.h>
int main() {
printf("Hello from TensorFlow C library version %s\n", TF_Version());
return 0;
}
@sborquez
sborquez / applied-neural-style-transfer.ipynb
Created February 7, 2020 17:17
Applied Neural Style Transfer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sborquez
sborquez / TM-power.yaml
Last active May 18, 2020 01:05
standard Turing Machine that calculates the function m^n, where m, n ≥ 1 are received coded in unary, in format m#n
name: power
source code: |-
input: '11#111'
blank: ' '
start state: setup_a
table:
setup_a:
1 : {write: 'x', L}
' ' : {write: '=', L: setup_b}
@sborquez
sborquez / TM-binary_palindrome_enumerator.yaml
Last active May 18, 2020 01:04
This is a Turing Machine that lists L_B in canonical order. Where L_B is the set formed by all natural numbers whose representation in binary is a palindrome.
name: binary palindrome enumerator
source code: |
# Adds 1 to a binary number.
input: ''
blank: ' '
start state: setup_a
table:
# binary generator
setup_a:
' ' : {write: '#', L: setup_b}