This file contains 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 | |
import numpy as np | |
################################################################################## | |
# Initialization | |
################################################################################## | |
# Xavier : tf.contrib.layers.xavier_initializer() | |
# He : tf.contrib.layers.variance_scaling_initializer() | |
# Normal : tf.random_normal_initializer(mean=0.0, stddev=0.02) |
This file contains 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 | |
from scipy import misc | |
import numpy as np | |
import random, os | |
from tensorflow.contrib import slim | |
class ImageData: | |
def __init__(self, load_size, channels, augment_flag): | |
self.load_size = load_size |
This file contains 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 kmp(st,pt): | |
# 传入一个母串和一个子串 | |
if len(pt)==0: | |
return 0 | |
if len(st)==0: | |
return -1 | |
# 生成next数组 | |
next=[-1]*len(pt) |
This file contains 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 partition(seq): | |
pi, seq = seq[0], seq[1:] | |
lo = [x for x in seq if x <= pi] | |
hi = [x for x in seq if x > pi] | |
return lo, pi, hi | |
def selectmax(seq, k): | |
lo, pi, hi = partition(seq) | |
m = len(lo) |
This file contains 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 os | |
import re | |
import sys | |
import json | |
import time | |
import random | |
import requests | |
from hashlib import md5 | |
from pyquery import PyQuery as pq | |
from multiprocessing.dummy import Pool |
This file contains 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 cv2 | |
import numpy as np | |
image = cv2.imread('./trex.png') | |
image_blur = np.hstack( # 均值滤波器结果图像的水平拼接 | |
[cv2.blur(image, (3, 3)), # kernel_size为3×3 | |
cv2.blur(image, (5, 5)), | |
cv2.blur(image, (7, 7))] # 能够看到图像变得越来越模糊 | |
) | |
cv2.imwrite('blur_of_diff_size.jpg', image_blur) |
This file contains 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
class ALG(object): | |
def __init__(self,list): | |
self.list=list | |
#冒泡 | |
def bubble_sort(nums): | |
n =len(nums) | |
for i in range(n - 1): | |
for j in range(n-1 - i): | |
if nums[j+1] < nums[j]: | |
nums[j], nums[j + 1] = nums[j + 1], nums[j] |
This file contains 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 fib_iter(n): | |
pre,next = 1, 1 | |
result = 0 | |
i = 2 | |
while i < n: | |
result = pre + next | |
pre,next= next,result | |
i += 1 | |
return result |
This file contains 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 numpy as np | |
import cv2 | |
img = cv2.imread('X.jpg',0) | |
cv2.imshow('image',img) | |
k = cv2.waitKey(0) | |
k = cv2.waitKey(0) & 0xFF # 64位机器 | |
if k == 27: # 按下esc时,退出 | |
cv2.destroyAllWindows() | |
elif k == ord('s'): # 按下s键时保存并退出 |
This file contains 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 os | |
import time | |
from functools import reduce | |
from threading import Thread | |
from PIL import Image | |
class MosaicMaker(object): | |
# 内部类,执行多线程拼图的任务类 | |
class __SubTask: |
OlderNewer