2017년 6월 21일 수요일
[c#] task cancelation token
https://binary-studio.com/2015/10/23/task-cancellation-in-c-and-things-you-should-know-about-it/
2017년 6월 19일 월요일
[C#] Create Method Flow and Run Flow
static void Main( string [ ] args )
{
Func temp = new Func(x =>
{
Console.WriteLine("temp done // input is : " + x.ToString());
return "g0";
} );
Func temp1 = new Func(x => {
Console.WriteLine("temp1 done");
return "g1";
} );
Func temp2 = new Func(x => {
Console.WriteLine("temp2 done");
return 4.5;
} );
List any = new List();
any.Add( temp );
any.Add( temp1 );
any.Add( temp2 );
Console.WriteLine( "anycount = " + any.Count.ToString() );
var result = runme( 0, any , 10 );
Console.WriteLine( result );
Console.ReadLine();
}
static object runme( int idx , List list , object input )
{
Console.WriteLine( idx );
if ( idx == list.Count )
{
return input;
}
var output = list [ idx ].DynamicInvoke( input );
return runme( idx + 1 , list , output );
}
{
Func
{
Console.WriteLine("temp done // input is : " + x.ToString());
return "g0";
} );
Func
Console.WriteLine("temp1 done");
return "g1";
} );
Func
Console.WriteLine("temp2 done");
return 4.5;
} );
List
any.Add( temp );
any.Add( temp1 );
any.Add( temp2 );
Console.WriteLine( "anycount = " + any.Count.ToString() );
var result = runme( 0, any , 10 );
Console.WriteLine( result );
Console.ReadLine();
}
static object runme( int idx , List
{
Console.WriteLine( idx );
if ( idx == list.Count )
{
return input;
}
var output = list [ idx ].DynamicInvoke( input );
return runme( idx + 1 , list , output );
}
2017년 6월 15일 목요일
[ Python] Tensorflow on windows10 and vision lib setting
Install Anadonda Installer 4.2.1
Install Tensorflow
Install keras (option)
Install opencv3
-- conda install -c https://conda.binstar.org/menpo opencv3
Install Tensorflow
Install keras (option)
Install opencv3
-- conda install -c https://conda.binstar.org/menpo opencv3
[TF] tensor to ndarray
https://stackoverflow.com/questions/34097281/how-can-i-convert-a-tensor-into-a-numpy-array-in-tensorflow
predict = tf.argmax(model, 1)
result = sess.run(predict , feed_dict = {
X: x_data,
Y: y_data,
keep_prob: 1
})
print(type(result)) << ndarray
print( 'Predict' , result)
predict = tf.argmax(model, 1)
result = sess.run(predict , feed_dict = {
X: x_data,
Y: y_data,
keep_prob: 1
})
print(type(result)) << ndarray
print( 'Predict' , result)
2017년 6월 14일 수요일
[keras] image generater
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
import cv2
import numpy as np
datagen = ImageDataGenerator(
rotation_range=180,
width_shift_range=0.5,
height_shift_range=0.5,
shear_range=0.3,
zoom_range=0.6,
horizontal_flip=True,
vertical_flip = True,
fill_mode = "wrap")
img = cv2.imread(r"C:\image data\test\defect 001.jpg", 0)
#tensorflow backend
x = img_to_array(img) # this is a Numpy array with shape (150, 150 , 1)
x = x.reshape( (1,) + x.shape ) # this is a Numpy array with shape (1, 150, 150 , 1~3(ch) )
i = 0
for batch in datagen.flow_from_directory( directory= r"C:\image data\defect"
, target_size = (64,64)
, color_mode = "grayscale"
, batch_size=1
, shuffle = True
, save_to_dir=r'C:\image data\test\result'
, save_prefix='defect'
):
i += 1
if i > 50000:
break
import cv2
import numpy as np
datagen = ImageDataGenerator(
rotation_range=180,
width_shift_range=0.5,
height_shift_range=0.5,
shear_range=0.3,
zoom_range=0.6,
horizontal_flip=True,
vertical_flip = True,
fill_mode = "wrap")
img = cv2.imread(r"C:\image data\test\defect 001.jpg", 0)
#tensorflow backend
x = img_to_array(img) # this is a Numpy array with shape (150, 150 , 1)
x = x.reshape( (1,) + x.shape ) # this is a Numpy array with shape (1, 150, 150 , 1~3(ch) )
i = 0
for batch in datagen.flow_from_directory( directory= r"C:\image data\defect"
, target_size = (64,64)
, color_mode = "grayscale"
, batch_size=1
, shuffle = True
, save_to_dir=r'C:\image data\test\result'
, save_prefix='defect'
):
i += 1
if i > 50000:
break
new keras install
I uninstalled Keras using
pip uninstall keras
Then I executed the following commands.
1. C:\Users\tjhau>conda create -n keras_tensorflow python=3.5.2 anaconda=4.3
2. C:\Users\tjhau>activate keras_tensorflow
3. C:\Users\tjhau>conda install -c conda-forge tensorflow keras
2. C:\Users\tjhau>activate keras_tensorflow
3. C:\Users\tjhau>conda install -c conda-forge tensorflow keras
I understand that keras will be available in a directory after I execute the command
C:\Users\tjhau>activate keras_tensorflow
Thanks for your help.
[python] keras image dim converting
keras image dim convert
tensorflow image <-> theano image->
https://github.com/fchollet/keras/issues/3994
피드 구독하기:
글 (Atom)