recognize godzilla
Post on 22-Mar-2017
155 Views
Preview:
TRANSCRIPT
:http://www.asahi.com/articles/ASJ8X42B7J8XPUTB001.html
Python => Selenium Firefox
=> (´ ω )
Firefox 48 selenium-webdriver
=> Firefox 47.x
Python web driverAPI
Python Selenium
Plugin JavaScript
Selenium
trimming.py
def trimming(image_path):
#
x = 334
y = 276
#
width = 1892
height = 1066
src = cv2.imread(image_path, 1)
dst = src[y:y + height, x:x + width]
file_name = re.sub('(godzilla[0-9]+\.jpg)',
'trimming_\\1',
image_path)
cv2.imwrite(file_name, dst)
cutout.py
def cutout_square(img, image_path,
full_path, pixel_size, loop_count,
x_start_point, y_start_point, image_prefix):
for x in range(loop_count):
for y in range(loop_count):
x_start = x_start_point + (pixel_size * x)
x_end = x_start + pixel_size
y_start = y_start_point + (pixel_size * y)
y_end = y_start + pixel_size
dist = img[y_start:y_end, x_start:x_end]
resize_image = resize.to_target_pixel(dist)
if type(resize_image).__module__ == \
np.__name__:
write_image(resize_image,
image_prefix,
full_path)
else:
print(image_path)
resize.py
def to_target_pixel(image, pixel_size=32):
height = image.shape[0]
width = image.shape[1]
try:
resize_size_list = (\
int(height / (height / pixel_size)),
int(width / (width/ pixel_size)))
return cv2.resize(image, resize_size_list)
except:
return False
(※ github )
ls Finder=> cp mv too many arguments
=> => 5
=> (1 * 25) * (shift ) 5 * ( ) 20,000 ≒2,500,000=> ↑=> (´ ω )
find xargs
$ find ${DIRECTORY} -name ${FIND_PARAM} -maxdepth 1 \
-print0 | xargs -0 -J {} mv {} ${MV_DIRECTORY}
${DIRECTORY}
${FIND_PARAM}
${MV_DIRECTORY}
python
$ python increase_picture.py ${IMAGE_FILE}
find
$ find ${IMG_FILES} -maxdepth 1 -exec \
increase_picture.py {} \;
keras
# (?)
batch_size = 32
# ! 10 2
nb_classes = 2
# (?)
nb_epoch = 4
# (?)
nb_filter = 10
# input image dimensions. img_rows = height, img_cols = width
img_rows, img_cols = 32, 32
# the CIFAR10 images are RGB
img_channels = 3
# json
# yaml
json_string = model.to_json()
open(os.path.join('./model/', 'model.json'), 'w').write(json_string)
#
model.save_weights(os.path.join('./model/','model_weights.hdf5'
top related