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.preprocessing import image | |
import numpy as np | |
import sys | |
filepath = "./banana.jpg" | |
image = np.array(Image.open(filepath).resize((25, 25))) | |
print(filepath) | |
image = image.transpose(2, 0, 1) | |
image = image.reshape(1, image.shape[0] * image.shape[1] * image.shape[2]).astype("float32")[0] | |
result = model.predict_classes(np.array([image / 255.])) |
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 | |
filepath = "./mikan.jpg" | |
# 画像を25x25pixelに変換し、1要素が[R,G,B]3要素を含む配列の25x25の2次元配列として読み込む。 | |
# [R,G,B]はそれぞれが0-255の配列。 | |
image = np.array(Image.open(filepath).resize((5, 5))) | |
print(filepath) | |
print(image) | |
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
# original code from fruit.py @ http://qiita.com/hiroeorz@github/items/ecb39ed4042ebdc0a957 | |
from keras.models import Sequential | |
from keras.layers import Activation, Dense, Dropout | |
from keras.utils.np_utils import to_categorical | |
from keras.optimizers import Adagrad | |
from keras.optimizers import Adam | |
import numpy as np | |
from PIL import Image | |
import os |
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
# このコードはfruit101.pyの続きです | |
# original code from http://qiita.com/secang0/items/1229212a37d8c9922901 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
filepath = "./tomato.jpg" | |
#画像の読み込み | |
#imgに三次元のnp.arrayの配列が格納される。 |
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
# original code from http://blog.mudatobunka.org/entry/2016/10/03/014520 | |
# Anaconda 4.4.0 (64-bit) | |
# Python 3.6.1 | |
# OpenCV3 ( http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv ) | |
# image from https://www.photo-ac.com/ | |
%matplotlib inline | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import cv2 |
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
# jupyter notebook 上でのversion確認 | |
import platform | |
print(platform.python_version()) | |
import tensorflow as tf | |
tf.__version__ | |
# 以下は、Anaconda Prompt 上でのversion確認 | |
$ python --version |
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
# original code from http://qiita.com/HirofumiYashima/items/667cefcabf84278e6a67 | |
# 1d Convolution neural network モデル を 定義 | |
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten | |
from keras.layers import Input | |
from keras.models import Model | |
print('Build model...') | |
#model = Sequential() |
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
# original code from http://qiita.com/gollowars/items/fb664c66f9a69e8c5cac | |
# -*- coding: utf-8 -*- | |
# 作成中 | |
import cv2, matplotlib | |
import numpy as np | |
import matplotlib.pyplot as plt |
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
# this code does not work | |
# error | |
# chainer.utils.type_check.InvalidType: | |
# Invalid operation is performed in: Convolution2DFunction (Forward) | |
# | |
# Expect: in_types[0].ndim == 4 | |
# Actual: 2 != 4 | |
from flask import Flask, render_template, request, redirect, url_for |
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
# original code from https://qiita.com/xolmon/items/0b82f4861cf93fd28e33 | |
import os | |
import sys | |
import glob | |
import cv2 | |
from PIL import Image | |
#import dlib | |
""" |