Skip to content

Commit

Permalink
prettier configure & make
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Jun 22, 2012
1 parent 139436b commit 620a01a
Show file tree
Hide file tree
Showing 31 changed files with 97 additions and 53 deletions.
6 changes: 3 additions & 3 deletions bin/dpmcreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void exit_with_help()
"\t--alpha-ratio : decrease the step size for each iteration [DEFAULT TO 0.9]\n"
"\t--margin-c : the famous C in SVM [DEFAULT TO 0.002]\n"
"\t--balance : to balance the weight of positive examples and negative examples [DEFAULT TO 1.75]\n"
"\t--negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 500]\n"
"\t--negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 1000]\n"
"\t--include-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object [DEFAULT TO 0.7]\n"
"\t--exclude-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Below this threshold, it is ensured to not be the same object [DEFAULT TO 0.5]\n"
"\t--grayscale : 0 or 1, whether to exploit color in a given image [DEFAULT TO 1]\n"
Expand Down Expand Up @@ -76,8 +76,8 @@ int main(int argc, char** argv)
.balance = 1.75,
.alpha_ratio = 0.9,
.iterations = 20,
.relabels = 5,
.negative_cache_size = 500,
.relabels = 10,
.negative_cache_size = 1000,
.C = 0.002,
.percentile_breakdown = 0.05,
.include_overlap = 0.7,
Expand Down
2 changes: 1 addition & 1 deletion bin/dpmdetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main(int argc, char** argv)
ccv_dense_matrix_t* image = 0;
ccv_read(argv[1], &image, CCV_IO_ANY_FILE);
ccv_dpm_mixture_model_t* model = ccv_load_dpm_mixture_model(argv[2]);
ccv_dpm_param_t params = { .interval = 8, .min_neighbors = 1, .flags = 0, .threshold = 1.1 };
ccv_dpm_param_t params = { .interval = 8, .min_neighbors = 1, .flags = 0, .threshold = -0.15 };
if (image != 0)
{
unsigned int elapsed_time = get_current_time();
Expand Down
12 changes: 7 additions & 5 deletions bin/makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC = `cat ../lib/.cc.conf`
LDFLAGS = -L"../lib" -lccv `cat ../lib/.l.conf` -lm
CFLAGS = -O3 -Wall -I"../lib" `cat ../lib/.def.conf`
CC = `cat ../lib/.CC`
LDFLAGS = -L"../lib" -lccv `cat ../lib/.LN` -lm
CFLAGS = -O3 -Wall -I"../lib" `cat ../lib/.DEF`

TARGETS = bbffmt siftmatch bbfcreate bbfdetect swtcreate swtdetect dpmcreate dpmdetect convert

Expand All @@ -10,10 +10,12 @@ clean:
rm *.o ../lib/*.o ../lib/3rdparty/*.o ../lib/libccv.a $(TARGETS)

$(TARGETS): %: %.o libccv.a
$(CC) -o $@ $< $(LDFLAGS)
@echo "$(CC) -o $@ $< $(LDFLAGS)"
@$(CC) -o $@ $< $(LDFLAGS)

libccv.a:
${MAKE} -C ../lib

%.o: %.c ../lib/ccv.h
$(CC) $< -o $@ -c $(CFLAGS)
@echo "$(CC) $< -o $@ -c $(CFLAGS)"
@$(CC) $< -o $@ -c $(CFLAGS)
31 changes: 27 additions & 4 deletions lib/ccv_dpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,28 @@ static int _ccv_dpm_read_negative_feature_vectors(ccv_array_t** _negv, int* negk
return 0;
}

static void _ccv_dpm_adjust_model_constant(ccv_dpm_mixture_model_t* model, ccv_dpm_feature_vector_t** posv, int posnum, double percentile)
{
int i, j, k;
double* scores = (double*)ccmalloc(posnum * sizeof(double));
for (k = 0; k < model->count; k++)
{
j = 0;
for (i = 0; i < posnum; i++)
if (posv[i] && posv[i]->id == k)
{
scores[j] = _ccv_dpm_vector_score(model, posv[i]);
j++;
}
_ccv_dpm_score_qsort(scores, j, 0);
float adjust = scores[ccv_clamp((int)(percentile * j), 0, j - 1)];
// adjust to percentile
model->root[k].beta -= adjust;
printf(" - tune model %d constant for %f\n", k, -adjust);
}
ccfree(scores);
}

static void _ccv_dpm_check_params(ccv_dpm_new_param_t params)
{
assert(params.components > 0);
Expand Down Expand Up @@ -1479,13 +1501,13 @@ void ccv_dpm_mixture_model_new(char** posfiles, ccv_rect_t* bboxes, int posnum,
c = t = r = 0;
ccv_array_t* negv = 0;
int negi = 0;
int abort = 0;
int* negk = (int*)ccmalloc(params.negative_cache_size * sizeof(int));
if (0 == _ccv_dpm_read_negative_feature_vectors(&negv, negk, params.negative_cache_size, neg_vector_checkpoint))
printf(" - read collected negative responses from last interrupted process\n");
_ccv_dpm_read_gradient_descent_progress(&c, &t, &r, &previous_loss, &positive_loss, &negative_loss, &loss, &pos_prog, &neg_prog, &negi, order, posnum + negnum, gradient_progress_checkpoint);
for (; c < params.relabels; c++)
{
int abort = 0;
double regz_rate = params.C / model->count;
double alpha = params.alpha * pow(params.alpha_ratio, t);
ccv_dpm_mixture_model_t* _model;
Expand Down Expand Up @@ -1660,7 +1682,7 @@ void ccv_dpm_mixture_model_new(char** posfiles, ccv_rect_t* bboxes, int posnum,
j = 0;
double* scores = (double*)ccmalloc(posnum * sizeof(double));
for (i = 0; i < posnum; i++)
if (posv[i] != 0)
if (posv[i])
{
scores[j] = _ccv_dpm_vector_score(model, posv[i]);
j++;
Expand Down Expand Up @@ -1699,12 +1721,13 @@ void ccv_dpm_mixture_model_new(char** posfiles, ccv_rect_t* bboxes, int posnum,
}
t = 0;
previous_loss = positive_loss = negative_loss = loss = 0;
// if abort, means that we cannot find enough negative examples, try to adjust constant
if (abort)
_ccv_dpm_adjust_model_constant(model, posv, posnum, params.percentile_breakdown);
for (i = 0; i < posnum; i++)
if (posv[i])
_ccv_dpm_feature_vector_free(posv[i]);
remove(feature_vector_checkpoint);
if (abort)
break;
}
ccfree(order);
ccfree(negk);
Expand Down
57 changes: 35 additions & 22 deletions lib/configure
Original file line number Diff line number Diff line change
@@ -1,86 +1,99 @@
#!/usr/bin/env sh

if [ "$1" = "force" ] ; then
rm -f .cc.conf .def.conf .l.conf
rm -f .CC .DEF .LN
fi

if [ -e .cc.conf ] ; then
CC=`cat .cc.conf`
if [ ! -e .CC -o ! -e .DEF -o ! -e .LN ] ; then
echo "\n There are a few questions for you:\n"
fi

if [ -e .CC ] ; then
CC=`cat .CC`
else
read -p "default compiler: clang [Y/n] ? " yn
echo -n " Default compiler: \033[4mclang\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) read -p "your favorite compiler: " CC
[nN]* ) read -p " Your favorite compiler: " CC
break;;
* ) CC='clang'
break;;
esac
echo $CC > .cc.conf
echo $CC > .CC
fi

if [ -e .def.conf -a -e .l.conf ] ; then
CFLAGS=`cat .def.conf`
LDFLAGS=`cat .l.conf`
if [ -e .DEF -a -e .LN ] ; then
CFLAGS=`cat .DEF`
LDFLAGS=`cat .LN`
else
CFLAGS=""
LDFLAGS=""
read -p "with SSE2 [Y/n] ? " yn
CFLAGS=" "
LDFLAGS=" "
echo -n " Enable \033[4mSSE2\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-msse2 "
break;;
esac
read -p "with libjpeg [Y/n] ? " yn
echo -n " With \033[4mlibjpeg\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-D HAVE_LIBJPEG "
LDFLAGS="$LDFLAGS-ljpeg "
break;;
esac
read -p "with libpng [Y/n] ? " yn
echo -n " With \033[4mlibpng\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-D HAVE_LIBPNG "
LDFLAGS="$LDFLAGS-lpng -lz "
break;;
esac
read -p "with gsl [Y/n] ? " yn
echo -n " With \033[4mgsl\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-D HAVE_GSL "
LDFLAGS="$LDFLAGS-lgsl "
break;;
esac
read -p "with fftw3 [Y/n] ? " yn
echo -n " With \033[4mfftw3\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-D HAVE_FFTW3 "
LDFLAGS="$LDFLAGS-lfftw3f -lfftw3 "
break;;
esac

read -p "with liblinear [Y/n] ? " yn
echo -n " With \033[4mliblinear\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-D HAVE_LIBLINEAR "
LDFLAGS="$LDFLAGS-llinear "
break;;
esac
read -p "with cblas [Y/n] ? " yn
echo -n " With \033[4mcblas\033[m [Y/n] ? "
read yn
case $yn in
[nN]* ) break;;
* ) CFLAGS="$CFLAGS-D HAVE_CBLAS "
LDFLAGS="$LDFLAGS-lblas "
break;;
esac
read -p "use openmp [y/N] ? " yn
echo -n " Use \033[4mopenmp\033[m [y/N] ? "
read yn
case $yn in
[yY]* ) CFLAGS="$CFLAGS-D USE_OPENMP -fopenmp "
LDFLAGS="$LDFLAGS-lgomp "
break;;
* ) break;;
esac
echo $CFLAGS > .def.conf
echo $LDFLAGS > .l.conf
echo $CFLAGS > .DEF
echo $LDFLAGS > .LN
fi

echo "\nsummary:\nuse: $CC\nwith following compile flags:\n$CFLAGS\nand link flags:\n$LDFLAGS\n"
echo "\n \033[1mUSE\033[m: \033[4m$CC\033[m\n \033[1mCOMPILE FLAGS\033[m: \033[4m$CFLAGS\033[m\n \033[1mLINK FLAGS\033[m: \033[4m$LDFLAGS\033[m\n"
10 changes: 6 additions & 4 deletions lib/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC = `cat .cc.conf`# -faddress-sanitizer -fno-omit-frame-pointer
CFLAGS = -O3 -ffast-math -mtune=native -Wall `cat .def.conf`
CC = `cat .CC`# -faddress-sanitizer -fno-omit-frame-pointer
CFLAGS = -O3 -ffast-math -mtune=native -Wall `cat .DEF`

config:
@./configure
Expand All @@ -18,7 +18,9 @@ libccv.a: ccv_cache.o ccv_memory.o 3rdparty/sha1/sha1.o 3rdparty/kissfft/kiss_ff
ar rcs $@ $^

ccv_io.o: ccv_io.c ccv.h ccv_internal.h io/*.c
$(CC) $< -o $@ -c $(CFLAGS)
@echo "$(CC) $< -o $@ -c $(CFLAGS)"
@$(CC) $< -o $@ -c $(CFLAGS)

%.o: %.c ccv.h ccv_internal.h
$(CC) $< -o $@ -c $(CFLAGS)
@echo "$(CC) $< -o $@ -c $(CFLAGS)"
@$(CC) $< -o $@ -c $(CFLAGS)
Binary file removed test/funct/data/blackbox.canny.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.flip_x.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.flip_xy.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.flip_y.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.resample.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sample_down.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sample_up.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.slice.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sobel.x.3.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sobel.x.5.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sobel.x.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sobel.y.3.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sobel.y.5.bin
Binary file not shown.
Binary file removed test/funct/data/chessbox.sobel.y.bin
Binary file not shown.
Binary file removed test/funct/data/nature.blur.bin
Binary file not shown.
Binary file removed test/funct/data/street.g100.bin
Binary file not shown.
Binary file removed test/funct/data/street.g101.bin
Binary file not shown.
File renamed without changes.
File renamed without changes.
14 changes: 8 additions & 6 deletions test/funct/makefile → test/functional/makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
CC = `cat ../../lib/.cc.conf`
LDFLAGS = -L"../../lib" -lccv -pthread `cat ../../lib/.l.conf`
CFLAGS = -O3 -msse2 -Wall -I"../../lib" -I"../" `cat ../../lib/.def.conf`
CC = `cat ../../lib/.CC`
LDFLAGS = -L"../../lib" -lccv -pthread `cat ../../lib/.LN`
CFLAGS = -O3 -msse2 -Wall -I"../../lib" -I"../" `cat ../../lib/.DEF`
TARGETS = algebra.tests util.tests numeric.tests basic.tests memory.tests

test: all
for test in $(TARGETS) ; do ./"$$test" ; done
@for test in $(TARGETS) ; do ./"$$test" ; done

all: $(TARGETS)

clean:
rm *.o ../../lib/*.o ../../lib/3rdparty/*.o ../../lib/libccv.a $(TARGETS)

%.tests: %.tests.o libccv.a
$(CC) -o $@ $< $(LDFLAGS)
@echo "$(CC) -o $@ $< $(LDFLAGS)"
@$(CC) -o $@ $< $(LDFLAGS)

libccv.a:
${MAKE} -C ../../lib

%.o: %.c ../../lib/ccv.h
$(CC) $(INCFLAGS) $< -o $@ -c $(CFLAGS)
@echo "$(CC) $(INCFLAGS) $< -o $@ -c $(CFLAGS)"
@$(CC) $(INCFLAGS) $< -o $@ -c $(CFLAGS)
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
${MAKE} -C funct ; ${MAKE} -C regression
${MAKE} -C functional ; ${MAKE} -C regression

clean:
rm *.o ../lib/*.o ../lib/3rdparty/*.o ../lib/libccv.a funct/*.tests regression/*.tests
rm *.o ../lib/*.o ../lib/3rdparty/*.o ../lib/libccv.a functional/*.tests regression/*.tests
14 changes: 8 additions & 6 deletions test/regression/makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
CC = `cat ../../lib/.cc.conf`
LDFLAGS = -L"../../lib" -lccv -pthread `cat ../../lib/.l.conf`
CFLAGS = -O3 -msse2 -Wall -I"../../lib" -I"../" `cat ../../lib/.def.conf`
CC = `cat ../../lib/.CC`
LDFLAGS = -L"../../lib" -lccv -pthread `cat ../../lib/.LN`
CFLAGS = -O3 -msse2 -Wall -I"../../lib" -I"../" `cat ../../lib/.DEF`
TARGETS = defects.l0.1.tests

test: all
for test in $(TARGETS) ; do ./"$$test" ; done
@for test in $(TARGETS) ; do ./"$$test" ; done

all: $(TARGETS)

clean:
rm *.o ../../lib/*.o ../../lib/3rdparty/*.o ../../lib/libccv.a $(TARGETS)

%.tests: %.tests.o libccv.a
$(CC) -o $@ $< $(LDFLAGS)
@echo "$(CC) -o $@ $< $(LDFLAGS)"
@$(CC) -o $@ $< $(LDFLAGS)

libccv.a:
${MAKE} -C ../../lib

%.o: %.c ../lib/ccv.h
$(CC) $(INCFLAGS) $< -o $@ -c $(CFLAGS)
@echo "$(CC) $(INCFLAGS) $< -o $@ -c $(CFLAGS)"
@$(CC) $(INCFLAGS) $< -o $@ -c $(CFLAGS)

0 comments on commit 620a01a

Please sign in to comment.