⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagenet.c

📁 人脸识别
💻 C
字号:
/* ****************************************************************** * HISTORY * 15-Oct-94  Jeff Shufelt (js), Carnegie Mellon University *      Prepared for 15-681, Fall 1994. * ****************************************************************** */#include <stdio.h>#include <pgmimage.h>#include <backprop.h>extern void exit();#define TARGET_HIGH 0.9#define TARGET_LOW 0.1/*** This is the target output encoding for a network with one output unit.     It scans the image name, and if it's an image of me (js) then     it sets the target unit to HIGH; otherwise it sets it to LOW.     Remember, units are indexed starting at 1, so target unit 1     is the one to change....  ***/load_target(img, net)IMAGE *img;BPNN *net;{  int scale;  char userid[40], head[40], expression[40], eyes[40], photo[40];  userid[0] = head[0] = expression[0] = eyes[0] = photo[0] = '\0';  /*** scan in the image features ***/  sscanf(NAME(img), "%[^_]_%[^_]_%[^_]_%[^_]_%d.%[^_]",    userid, head, expression, eyes, &scale, photo);  if (!strcmp(userid, "glickman")) {    net->target[1] = TARGET_HIGH;  /* it's me, set target to HIGH */  } else {    net->target[1] = TARGET_LOW;   /* not me, set it to LOW */  }}/***********************************************************************//********* You shouldn't need to change any of the code below.   *******//***********************************************************************/load_input_with_image(img, net)IMAGE *img;BPNN *net;{  double *units;  int nr, nc, imgsize, i, j, k;  nr = ROWS(img);  nc = COLS(img);  imgsize = nr * nc;;  if (imgsize != net->input_n) {    printf("LOAD_INPUT_WITH_IMAGE: This image has %d pixels,\n", imgsize);    printf("   but your net has %d input units.  I give up.\n", net->input_n);    exit (-1);  }  units = net->input_units;  k = 1;  for (i = 0; i < nr; i++) {    for (j = 0; j < nc; j++) {      units[k] = ((double) img_getpixel(img, i, j)) / 255.0;      k++;    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -