Skip to content

Instantly share code, notes, and snippets.

View gist:a0f54c37b0b1b4566dc8c223ea8fd53f
imds = imageDatastore('/Users/mizuno/Documents/MATLAB/deeplearning/SimpleDeepLearning/trainingSet/','IncludeSubfolders',true,'LabelSource','foldernames');
View gist:193c42f55f1096f0de416a5da5fb680f
camera = webcam; % Connect to the camera
%preview(camera);
net = alexnet; % Load the neural networ k
im = snapshot(camera); % Take a picture
image(im) % Show the picture
im = imresize(im,[227 227]); % Resize the picture for alexnet
label = classify(net,im); % Classify the picture
title(char(label),'FontSize',50) % Show the class label
drawnow
clear camera
View gist:6a452143ccf3653f30ee04383128bfdb
# Comment/uncomment the following line to enable/disable debugging
#DEBUG = y
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
@smzn
smzn / deep01
Last active Apr 29, 2019
deep01
View deep01
%学習イメージの取得
food_ds = imageDatastore('/Users/mizuno/Documents/MATLAB/deep01/image','IncludeSubfolders',true,'LabelSource','foldernames','ReadFcn',@imageread);
[trainImgs,testImgs] = splitEachLabel(food_ds,0.8);
numClasses = numel(categories(food_ds.Labels));
%montage(food_ds)
%AlexNet の変更によるネットワークの作成
net = alexnet;
layers = net.Layers;
layers(end-2) = fullyConnectedLayer(numClasses);
View gist:88468a28d8630b9982fb58dc58d57b63
%AlexNet の変更によるネットワークの作成
net = alexnet;
layers = net.Layers;
layers(end-2) = fullyConnectedLayer(numClasses);
layers(end) = classificationLayer;
View gist:6d130ca476558e930ccb996b3af2e484
%学習イメージの取得
food_ds = imageDatastore('/Users/mizuno/Documents/MATLAB/deep01/image','IncludeSubfolders',true,'LabelSource','foldernames','ReadFcn',@imageread);
[trainImgs,testImgs] = splitEachLabel(food_ds,0.8);
numClasses = numel(categories(food_ds.Labels));
@smzn
smzn / imageread
Created Apr 29, 2019
Matlabデータストア読み込み時利用関数
View imageread
function img = imageread(file)
img = imread(file);
img = imresize(img,[227 227]);
end
View insertTotals
public void insertTotals(TableResult response, int index){
System.out.println("Totals : Insert開始");
for (FieldValueList row : response.iterateAll()) {
Map<String, Object> rowvalue = new HashMap<>();
for(int i = 0; i < column; i++) {
rowvalue.put("sum"+i, row.get("sum"+i).getValue());
}
rowvalue.put("index", index);
InsertAllRequest insertRequest = InsertAllRequest.newBuilder(tableId).addRow(rowvalue).build();
View createTable
public void createTable() { //BigQueryにテーブルを作成
Field row[] = new Field[column+1];
for(int i = 0; i < column; i++) {
row[i] = Field.of("sum"+i, LegacySQLTypeName.INTEGER);
}
row[column] = Field.of("index", LegacySQLTypeName.INTEGER);
Schema schema = Schema.of(row);
StandardTableDefinition tableDefinition = StandardTableDefinition.of(schema);
bigQuery.create(TableInfo.of(tableId, tableDefinition));
}
You can’t perform that action at this time.