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,pymysql.cursors | |
def get_error_ids(): | |
ids=[] | |
img_paths = os.listdir('./') | |
for img_path in img_paths: | |
if 'sale-error' not in img_path: continue | |
_id = img_path.split('-')[0] | |
ids.append(_id) | |
return ids |
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
lis = [] | |
new_df = raw_df['text'].apply(lambda x :prepro(x)) | |
for i in range(len(new_df)): | |
# print(new_df[i:i+1].values[0]) | |
lis.append(new_df[i:i+1].values[0]) | |
print(lis) | |
new_df = pd.DataFrame(lis) | |
new_df |
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
index2word = {i+1:key for i, key in enumerate(token.word_index)} |
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
#!/usr/bin/env python3 | |
import hashlib | |
def hash_string(string): | |
""" | |
Return a SHA-256 hash of the given string | |
""" | |
return hashlib.sha256(string.encode('utf-8')).hexdigest() |
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
from keras.models import Sequential | |
from keras.layers import Dense, Activation, Flatten | |
from keras.optimizers import Adam | |
import gym | |
from rl.agents.dqn import DQNAgent | |
from rl.policy import EpsGreedyQPolicy | |
from rl.memory import SequentialMemory | |
env = gym.make('MountainCar-v0') | |
nb_actions = env.action_space.n |
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
from keras.models import Sequential | |
from keras.layers import Dense, Activation, Flatten | |
from keras.optimizers import Adam | |
import gym | |
from rl.agents.dqn import DQNAgent | |
from rl.policy import EpsGreedyQPolicy | |
from rl.memory import SequentialMemory | |
env = gym.make('MountainCar-v0') | |
nb_actions = env.action_space.n |
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
じぇいそーぷ jsoup 名詞 | |
くらす <div class=""></div> 名詞 | |
しゅってん: 出典: 名詞 | |
みだし <h2></h2> 名詞 | |
みだし <h3></h3> 名詞 | |
みだし <h4></h4> 名詞 | |
hr <hr> 名詞 | |
h4 <h4></h4> 名詞 | |
h3 <h3></h3> 名詞 | |
h2 <h2></h2> 名詞 |
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 get_object_center(rois,image): | |
height = image.shape[0] | |
width = image.shape[1] | |
center = width / 2 | |
print(width,height) | |
print('center',center) | |
max_area = 0 | |
for i in range(len(rois)): | |
print(rois[i]) | |
start_height = rois[i][0] |
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 left_right_image(left_img_path,right_img_path, canvas_size = 500): | |
# load image | |
iml = Image.open(left_img_path) | |
imr = Image.open(right_img_path) | |
# make back ground | |
bg = Image.new("RGB",(canvas_size,canvas_size),(250,250,250)) | |
# target position | |
left_target = int(bg.size[0] / 4 * 1) |
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 make_mask(size,start_width,start_height,end_width,end_height): | |
mask = Image.new("L",(size,size),0) | |
draw = ImageDraw.Draw(mask) | |
draw.rectangle((start_width,start_height,end_width,end_height), fill=255) | |
print('mask',mask.size) | |
return mask |