Compare commits
No commits in common. 'd477d24d39c538bef36762d22ed2bd1978071370' and '1b875f6d70461afe0526ee90ba19211bd856b254' have entirely different histories.
d477d24d39
...
1b875f6d70
@ -1,97 +1,73 @@
|
|||||||
BASE_DIR=../../../
|
BASE_DIR=../
|
||||||
|
include Makefile.wasm.inc
|
||||||
AWSM_CC=awsm
|
|
||||||
|
# SOD does not generally require a Makefile to build. Just drop sod.c and its accompanying
|
||||||
NATIVE_CC=clang
|
# header files on your source tree and you are done.
|
||||||
NATIVE_CFLAGS = -I. -DCPU_FREQ=3600 -O3 -lm -DSOD_DISABLE_CNN -DLIBCOX_DISABLE_DISK_IO
|
NCC = clang
|
||||||
|
NCFLAGS = -I. -DCPU_FREQ=3600 -O3 -lm -DSOD_DISABLE_CNN -DLIBCOX_DISABLE_DISK_IO
|
||||||
OPTFLAGS=-O3 -flto
|
WCFLAGS = -DWASM -I. -DSOD_DISABLE_CNN -lm -DLIBCOX_DISABLE_DISK_IO
|
||||||
|
|
||||||
WASM_CC=wasm32-unknown-unknown-wasm-clang
|
#sod: sod.c
|
||||||
WASM_LDFLAGS=-Wl,-z,stack-size=524288,--allow-undefined,--no-threads,--stack-first,--no-entry,--export-all,--export=main,--export=dummy
|
# $(CC) sod.c samples/cnn_face_detection.c -o sod_face_detect -I. $(CFLAGS)
|
||||||
WASM_CFLAGS=${WASM_LDFLAGS} -nostartfiles -DWASM -I. -DSOD_DISABLE_CNN -lm -DLIBCOX_DISABLE_DISK_IO
|
|
||||||
|
EXT = out
|
||||||
MEMC_64=64bit_nix.c
|
WEXT = wout
|
||||||
|
|
||||||
# for aWsm compiler
|
SAMPLES = resize_image \
|
||||||
# Currently only uses wasmception backing
|
license_plate_detection
|
||||||
AWSM_DIR=${BASE_DIR}/awsm/
|
|
||||||
AWSM_RT_DIR=${AWSM_DIR}/runtime/
|
#SAMPLES = batch_img_loading \
|
||||||
AWSM_RT_MEM=${AWSM_RT_DIR}/memory/
|
# blob_detection \
|
||||||
AWSM_RT_LIBC=${AWSM_RT_DIR}/libc/wasmception_backing.c
|
# canny_edge_detection \
|
||||||
AWSM_RT_ENV=${AWSM_RT_DIR}/libc/env.c
|
# cnn_coco \
|
||||||
AWSM_RT_RT=${AWSM_RT_DIR}/runtime.c
|
# cnn_face_detection \
|
||||||
AWSM_RT_MEMC=${AWSM_RT_MEM}/${MEMC_64}
|
# cnn_object_detection \
|
||||||
DUMMY=${AWSM_DIR}/code_benches/dummy.c
|
# cnn_voc \
|
||||||
|
# crop_image \
|
||||||
# for SLEdge serverless runtime
|
# dilate_image \
|
||||||
SLEDGE_RT_DIR=${BASE_DIR}/runtime/
|
# erode_image \
|
||||||
SLEDGE_RT_INC=${SLEDGE_RT_DIR}/include/
|
# grayscale_image \
|
||||||
SLEDGE_MEMC=${SLEDGE_RT_DIR}/compiletime/memory/${MEMC_64}
|
# hilditch_thin \
|
||||||
|
# hough_lines_detection \
|
||||||
SLEDGE_BIN_DIR=${SLEDGE_RT_DIR}/bin/
|
# license_plate_detection \
|
||||||
WASMISA=${SLEDGE_RT_DIR}/compiletime/instr.c
|
# minutiae \
|
||||||
|
# otsu_image \
|
||||||
SAMPLES = resize_image \
|
# realnet_face_detection \
|
||||||
license_plate_detection
|
# realnet_face_detection_embedded \
|
||||||
|
# realnet_train_model \
|
||||||
#SAMPLES = batch_img_loading \
|
# resize_image \
|
||||||
# blob_detection \
|
# rnn_text_gen \
|
||||||
# canny_edge_detection \
|
# rotate_image \
|
||||||
# cnn_coco \
|
# sobel_operator_img
|
||||||
# cnn_face_detection \
|
|
||||||
# cnn_object_detection \
|
SAMPLESOUT = $(SAMPLES:%=%.$(EXT))
|
||||||
# cnn_voc \
|
SAMPLESWOUT = $(SAMPLES:%=%.$(WEXT))
|
||||||
# crop_image \
|
|
||||||
# dilate_image \
|
all: clean dir copy
|
||||||
# erode_image \
|
|
||||||
# grayscale_image \
|
native: samples
|
||||||
# hilditch_thin \
|
wasm: samples.wasm
|
||||||
# hough_lines_detection \
|
# samples.wasm
|
||||||
# license_plate_detection \
|
# samples
|
||||||
# minutiae \
|
|
||||||
# otsu_image \
|
dir:
|
||||||
# realnet_face_detection \
|
mkdir -p bin/
|
||||||
# realnet_face_detection_embedded \
|
|
||||||
# realnet_train_model \
|
copy:
|
||||||
# resize_image \
|
cp samples/*.png bin/
|
||||||
# rnn_text_gen \
|
cp samples/*.jpg bin/
|
||||||
# rotate_image \
|
|
||||||
# sobel_operator_img
|
samples: $(SAMPLESOUT)
|
||||||
|
|
||||||
all: dir copy
|
samples.wasm: $(SAMPLESWOUT)
|
||||||
|
|
||||||
dir:
|
%.$(EXT):
|
||||||
@mkdir -p bin/
|
$(NCC) $(NCFLAGS) sod.c samples/$(@:%.$(EXT)=%.c) -o bin/$@
|
||||||
|
|
||||||
copy:
|
%.$(WEXT):
|
||||||
cp samples/*.png bin/
|
$(WASMCC) $(WCFLAGS) $(WASMCFLAGS) $(OPTFLAGS) sod.c samples/$(@:%.$(WEXT)=%.c) $(DUMMY) -o bin/$(@:%.$(WEXT)=%.wasm)
|
||||||
cp samples/*.jpg bin/
|
$(SFCC) bin/$(@:%.$(WEXT)=%.wasm) -o bin/$(@:%.$(WEXT)=%.bc)
|
||||||
|
$(CC) ${CFLAGS} ${EXTRA_CFLAGS} $(OPTFLAGS) -D$(USE_MEM) bin/$(@:%.$(WEXT)=%.bc) $(RT_LIBC) $(RT_RT) ${MEMC} -o bin/$@
|
||||||
.PHONY: samples.wasm
|
|
||||||
samples.wasm: resize_image.wasm license_plate_detection.wasm
|
clean:
|
||||||
|
rm -f bin/*
|
||||||
.PHONY: samples.so
|
|
||||||
samples.so: resize_image.so license_plate_detection.so
|
|
||||||
|
|
||||||
.PHONY: samples.out
|
|
||||||
samples.out: resize_image.out license_plate_detection.out
|
|
||||||
|
|
||||||
%.wasm: samples/%.c
|
|
||||||
@$(WASM_CC) $(WASM_CFLAGS) $(OPTFLAGS) sod.c $< $(DUMMY) -o bin/$@
|
|
||||||
|
|
||||||
%.out: %.wasm
|
|
||||||
@$(AWSM_CC) $< -o $(<:.wasm=.bc)
|
|
||||||
@$(NATIVE_CC) ${CFLAGS} ${EXTRA_CFLAGS} $(OPTFLAGS) -DUSE_MEM_VM bin/$(<:.wasm=.bc) $(AWSM_RT_LIBC) $(AWSM_RT_RT) $(AWSM_RT_ENV) $(AWSM_RT_MEMC) -o $@
|
|
||||||
|
|
||||||
%.so: %.wasm
|
|
||||||
@$(AWSM_CC) --inline-constant-globals --runtime-globals bin/$< -o bin/$(@:.so=.bc)
|
|
||||||
@$(NATIVE_CC) --shared -fPIC ${CFLAGS} ${EXTRA_CFLAGS} $(OPTFLAGS) -DUSE_MEM_VM -I${SLEDGE_RT_INC} bin/$(@:.so=.bc) $(WASMISA) ${SLEDGE_MEMC} -o bin/$@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f bin/*
|
|
||||||
rm -f *.wasm
|
|
||||||
rm -f *.bc
|
|
||||||
rm -f *.so
|
|
||||||
rm -f *.out
|
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
BASE=awsm
|
||||||
|
SFCC=silverfish
|
||||||
|
CC=clang
|
||||||
|
WASMCC=wasm32-unknown-unknown-wasm-clang
|
||||||
|
|
||||||
|
OPTFLAGS=-O3 -flto
|
||||||
|
# same stack-size for all
|
||||||
|
WASMLINKFLAGS=-Wl,-z,stack-size=524288,--allow-undefined,--no-threads,--stack-first,--no-entry,--export-all,--export=main,--export=dummy
|
||||||
|
WASMCFLAGS=${WASMLINKFLAGS} -nostartfiles
|
||||||
|
|
||||||
|
MEMC_64=64bit_nix.c
|
||||||
|
MEMC_NO=no_protection.c
|
||||||
|
MEMC_GEN=generic.c
|
||||||
|
MEMC_MPX=mpx.c
|
||||||
|
MEMC_SEG=segmented.c
|
||||||
|
|
||||||
|
# for silverfish
|
||||||
|
RT_DIR=${BASE_DIR}/runtime/
|
||||||
|
RT_MEM=${RT_DIR}/memory/
|
||||||
|
RT_LIBC=${RT_DIR}/libc/libc_backing.c
|
||||||
|
RT_RT=${RT_DIR}/runtime.c
|
||||||
|
|
||||||
|
MEMC=${RT_MEM}/${MEMC_64}
|
||||||
|
DUMMY=${BASE_DIR}/code_benches/dummy.c
|
||||||
|
|
||||||
|
# for awsm
|
||||||
|
ABASE_DIR=${BASE_DIR}/../
|
||||||
|
ART_DIR=${ABASE_DIR}/runtime/
|
||||||
|
ART_INC=${ART_DIR}/include/
|
||||||
|
|
||||||
|
USE_MEM=USE_MEM_VM
|
||||||
|
ifeq ($(USE_MEM),USE_MEM_VM)
|
||||||
|
AMEMC=${ART_DIR}/compiletime/memory/${MEMC_64}
|
||||||
|
endif
|
||||||
|
WASMISA=${ART_DIR}/compiletime/instr.c
|
||||||
|
|
||||||
|
ABIN_DIR=${ART_DIR}/bin/
|
||||||
|
TMP_DIR=tmp/
|
@ -1,47 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "sod.h"
|
|
||||||
|
|
||||||
#define MAX_IMG_SZ 1024*1024
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
unsigned char *zInpbuf = NULL;
|
|
||||||
|
|
||||||
zInpbuf = malloc(MAX_IMG_SZ);
|
|
||||||
if (!zInpbuf)
|
|
||||||
{
|
|
||||||
perror("malloc");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t imgSz = read(0, zInpbuf, MAX_IMG_SZ);
|
|
||||||
if (imgSz <= 0)
|
|
||||||
{
|
|
||||||
perror("read");
|
|
||||||
free(zInpbuf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sod_img imgIn = sod_img_load_from_mem(zInpbuf, imgSz, SOD_IMG_COLOR /* full color channels */);
|
|
||||||
if (imgIn.data == 0) {
|
|
||||||
/* Invalid path, unsupported format, memory failure, etc. */
|
|
||||||
//puts("Cannot load input image..exiting");
|
|
||||||
printf("Error loading input\n");
|
|
||||||
free(zInpbuf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < imgIn.w * imgIn.h * imgIn.c; i++)
|
|
||||||
{
|
|
||||||
imgIn.data[i] = 255.0f - imgIn.data[i];
|
|
||||||
}
|
|
||||||
sod_img_save_as_png(imgIn, NULL);
|
|
||||||
sod_free_image(imgIn);
|
|
||||||
free(zInpbuf);
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in new issue