This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# refer: https://www.geeksforgeeks.org/genetic-algorithms/ | |
import random | |
POPULATION_SIZE = 100 | |
# Valid genes | |
GENES = """abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP | |
QRSTUVWXYZ 1234567890, .-;:_!"#%&/()=?@${[]}""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from toolz import * | |
from toolz.curried import * | |
import string | |
lines = open('./gt.txt').readlines() | |
imgs = pipe( | |
lines, | |
map(lambda l: l.split('\t')[0]), | |
list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# crawl images from gogole images search using Selenium | |
# requirement: geckodriver | |
# gem: selenium-webdriver nokogiri | |
require 'selenium-webdriver' | |
require 'nokogiri' | |
require 'open-uri' | |
require 'securerandom' | |
driver = Selenium::WebDriver.for :firefox | |
driver.navigate.to "https://www.google.com/search?tbm=isch&q=single logos" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char (isSpace) | |
trim :: String -> String | |
trim = f . f | |
where f = reverse . dropWhile isSpace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.Char | |
import Data.List | |
strong :: String -> Bool | |
strong s = length s > 14 && | |
any (\c -> c `elem` ['A'..'Z']) s && | |
any (\c -> c `elem` ['a'..'z']) s && | |
any (\c -> c `elem` ['1'..'9']) s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def display(img): | |
"Display single image" | |
_, ax = plt.subplots(1, 1, figsize=(10, 10)) | |
#plt.axis('off') | |
#plt.title('Title') | |
plt.imshow(img); plt.show() | |
def display_grid(imgs): | |
"Display grid" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageOps | |
import cv2 | |
desired_size = 368 | |
im_pth = "/home/jdhao/test.jpg" | |
# im = Image.open(im_pth) | |
# old_size = im.size # old_size[0] is in (width, height) format | |
# ratio = float(desired_size)/max(old_size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# gdrive_download | |
# | |
# script to download Google Drive files from command line | |
# not guaranteed to work indefinitely | |
# taken from Stack Overflow answer: | |
# http://stackoverflow.com/a/38937732/7002068 | |
gURL=$1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
tf.logging.set_verbosity(tf.logging.ERROR) # level 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from tqdm import tqdm | |
import sys | |
import os | |
from pypeln import process as pr | |
# python filter.py train 8 | |
phase = sys.argv[1] |