Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
exit unless ARGV.length == 1
files = Dir.glob(ARGV[0] + '/*.txt')
files.each do |file|
name = nil;
File.new(file).each_line do |line|
next if line[0] == '#'
#!/usr/bin/env ruby
meta = File.new "meta.txt"
synsets = Hash.new
meta.each_line do |line|
dicts = line.split(" ")
synsets[dicts[1].to_s] = dicts[0].to_i;
end
#!/usr/bin/env ruby
meta = File.new "ILSVRC2010_test_ground_truth.txt"
ids = Array.new
i = 0
meta.each_line do |line|
ids << line.to_i
print ids[i].to_s + " test/ILSVRC2010_test_00" + ("%06d" % [i + 1]) + ".JPEG\n"
@liuliu
liuliu / gist:8878583
Last active August 29, 2015 13:56
generate half precision table
#include <stdio.h>
#include <stdint.h>
uint32_t basetable[512];
uint32_t shifttable[512];
void generatetables(){
unsigned int i;
int e;
for(i=0; i<256; ++i){
@liuliu
liuliu / gist:8906523
Last active August 29, 2015 13:56
resize image to 257x257
ccv_size_t size = ccv_size(257, 257);
for (i = 0; i < categorizeds->rnum; i++)
{
ccv_categorized_t* categorized = (ccv_categorized_t*)ccv_array_get(categorizeds, i);
ccv_dense_matrix_t* image = 0;
ccv_read(categorized->file.filename, &image, CCV_IO_ANY_FILE | CCV_IO_RGB_COLOR);
if (image)
{
ccv_dense_matrix_t* norm = 0;
if (image->rows > size.height && image->cols > size.width)
From 2d2ec7ba797e279a9196d0f6fb409f3781d174bc Mon Sep 17 00:00:00 2001
From: Liu Liu <i@liuliu.me>
Date: Sat, 8 Feb 2014 19:25:02 -0500
Subject: for testing with multiple sampling
---
lib/cuda/cwc_convnet.cu | 203 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 193 insertions(+), 10 deletions(-)
diff --git a/lib/cuda/cwc_convnet.cu b/lib/cuda/cwc_convnet.cu
../data/INRIAPerson/Test/pos/crop_000001.png 151 62 185 562 0.053384
../data/INRIAPerson/Test/pos/crop_000002.png 104 95 116 354 0.138356
../data/INRIAPerson/Test/pos/crop_000003.png 304 32 125 383 0.088343
../data/INRIAPerson/Test/pos/crop_000004.png 152 69 85 260 0.046716
../data/INRIAPerson/Test/pos/crop_000005.png 178 77 79 241 0.079528
../data/INRIAPerson/Test/pos/crop_000005.png 56 49 85 260 0.040967
../data/INRIAPerson/Test/pos/crop_000008.png 459 91 158 482 0.089334
../data/INRIAPerson/Test/pos/crop_000009.png 307 83 200 608 0.053156
../data/INRIAPerson/Test/pos/crop_000012.png 214 167 146 446 0.046018
../data/INRIAPerson/Test/pos/crop_000016.png 580 77 185 562 0.133419
static inline float cbrt_5_f32(float f)
{
const uint32_t b1 = 709921077;
uint32_t* p = (uint32_t*)(&f);
*p = *p / 3 + b1;
return f;
}
diff --git a/bin/cifar-10.c b/bin/cifar-10.c
index 1552aae..ca975db 100644
--- a/bin/cifar-10.c
+++ b/bin/cifar-10.c
@@ -192,7 +192,7 @@ int main(int argc, char** argv)
},
},
};
- ccv_convnet_t* convnet = ccv_convnet_new(1, ccv_size(32, 32), params, sizeof(params) / sizeof(ccv_convnet_layer_param_t));
+ ccv_convnet_t* convnet = ccv_convnet_new(0, ccv_size(31, 31), params, sizeof(params) / sizeof(ccv_convnet_layer_param_t));
@liuliu
liuliu / k-mean on histogram.c
Last active September 26, 2016 06:05
k-mean for layer
gsl_rng_env_setup();
gsl_rng* rng = gsl_rng_alloc(gsl_rng_default);
sqlite3* db = 0;
int h[0x10000];
int kc[0x100];
float kmean[0x100];
uint16_t tbl[0x10000];
int i;
for (i = 0; i < 0x10000; i++)
tbl[i] = i;