-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CXXFLAGS_EXTRA = -Ijson11 -Wall -Wno-sign-compare -std=c++1y -g -O3 -pthread | ||
LDLIBS = -lopencv_highgui -lopencv_core -lboost_filesystem -lboost_system -lboost_python -lglog -lluaT -lTH -lluajit | ||
|
||
all: picpac.so | ||
|
||
clean: | ||
rm -rf *.o picpac.so | ||
|
||
picpac.so: lua-api.o picpac.o picpac-cv.o json11/json11.o | ||
g++ $(LDFLAGS) -o $@ $^ $(LDLIBS) | ||
|
||
.cpp.o: | ||
g++ -c -o $@ $(CXXFLAGS) $(CXXFLAGS_EXTRA) $< | ||
|
||
install: picpac.so | ||
cp picpac.so $(LIBDIR)/lib | ||
|
Submodule Simple-Web-Extra
updated
4 files
+2 −2 | CMakeLists.txt | |
+0 −1 | http_examples.cpp | |
+3 −76 | server_extra.hpp | |
+0 −3 | server_extra_zip.hpp |
Submodule Simple-Web-Server
updated
13 files
+0 −1 | .gitignore | |
+0 −2 | CMakeLists.txt | |
+19 −26 | client_http.hpp | |
+12 −26 | client_https.hpp | |
+0 −220 | crypto.hpp | |
+6 −33 | http_examples.cpp | |
+6 −29 | https_examples.cpp | |
+99 −129 | server_http.hpp | |
+6 −36 | server_https.hpp | |
+0 −6 | tests/CMakeLists.txt | |
+0 −77 | tests/crypto_test.cpp | |
+1 −2 | tests/io_test.cpp | |
+65 −58 | tests/parse_test.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#define LUA_LIB | ||
extern "C" { | ||
#include "lua.h" | ||
#include "lualib.h" | ||
#include "lauxlib.h" | ||
#include "luaT.h" | ||
} | ||
#include <iostream> | ||
#include <TH/TH.h> | ||
#include "picpac.h" | ||
#include "picpac-cv.h" | ||
|
||
using namespace std; | ||
using namespace picpac; | ||
|
||
namespace { | ||
static char const *TNAME_MODULE = "picpac_module"; | ||
static char const *TNAME_CLASS = "picpac_class"; | ||
static int ImageStream_constructor (lua_State *L) { | ||
const char *db = luaL_checkstring(L, 1); | ||
BatchImageStream **udata = (BatchImageStream **)lua_newuserdata(L, sizeof(BatchImageStream *)); | ||
BatchImageStream::Config config; | ||
*udata = new BatchImageStream(db, config); | ||
CHECK(*udata) << "failed to construct BatchImageStream"; | ||
luaL_getmetatable(L, TNAME_CLASS); | ||
lua_setmetatable(L, -2); | ||
return 1; | ||
} | ||
static BatchImageStream *checkImageStream (lua_State *L, int n) { | ||
return *(BatchImageStream **)luaL_checkudata(L, n, TNAME_CLASS); | ||
} | ||
static int ImageStream_size (lua_State *L) { | ||
BatchImageStream *ss = checkImageStream(L, 1); | ||
lua_pushinteger(L, lua_Integer(ss->size())); | ||
return 1; | ||
} | ||
static int ImageStream_next (lua_State *L) { | ||
BatchImageStream *ss = checkImageStream(L, 1); | ||
cout << "ImageStream(" << ss << ")::next" << endl; | ||
vector<long> images_dims; | ||
vector<long> labels_dims; | ||
ss->next_shape(&images_dims, &labels_dims); | ||
CHECK(images_dims.size() == 4); | ||
while (labels_dims.size() < 4) labels_dims.push_back(-1); | ||
THFloatTensor *images = THFloatTensor_newWithSize4d(images_dims[0], | ||
images_dims[1], images_dims[2], images_dims[3]); | ||
CHECK(THFloatTensor_isContiguous(images)); | ||
THFloatTensor *labels = THFloatTensor_newWithSize4d(labels_dims[0], | ||
labels_dims[1], labels_dims[2], labels_dims[3]); | ||
CHECK(THFloatTensor_isContiguous(labels)); | ||
float *images_buf = THFloatTensor_data(images); | ||
float *labels_buf = THFloatTensor_data(images); | ||
unsigned padding; | ||
ss->next_fill(images_buf, labels_buf, &padding); | ||
luaT_pushudata(L, images, "torch.FloatTensor"); | ||
luaT_pushudata(L, labels, "torch.FloatTensor"); | ||
luaT_pushinteger(L, lua_Integer(padding)); | ||
return 3; | ||
} | ||
static int ImageStream_destructor (lua_State *L) { | ||
delete checkImageStream(L, 1); | ||
return 0; | ||
} | ||
} | ||
|
||
extern "C" { | ||
LUALIB_API int luaopen_picpac (lua_State *L) { | ||
luaL_Reg PicPacMethods [] = { | ||
{"ImageStream", ImageStream_constructor}, | ||
{NULL, NULL} | ||
}; | ||
luaL_Reg ImageStreamMethods [] = { | ||
{"next", ImageStream_next}, | ||
{"size", ImageStream_size}, | ||
{"__gc", ImageStream_destructor}, | ||
{NULL, NULL} | ||
}; | ||
luaL_newmetatable(L, TNAME_CLASS); | ||
luaL_register(L, NULL, ImageStreamMethods); | ||
lua_pushvalue(L, -1); | ||
lua_setfield(L, -1, "__index"); | ||
luaL_newmetatable(L, TNAME_MODULE); | ||
luaL_register(L, NULL, PicPacMethods); | ||
//luaL_setfuncs(L, NULL, ImageStreamMethods); | ||
lua_setglobal(L, "picpac"); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package = "picpac" | ||
version = "0.1.alpha-0" | ||
|
||
source = { | ||
url = "./", ---"git://github.com/aaalgo/picpac", | ||
tag = "master" | ||
} | ||
|
||
description = { | ||
summary = "An image database and streamer for deep learning.", | ||
detailed = [[ | ||
]], | ||
homepage = "https://github.com/aaalgo/picpac", | ||
license = "BSD" | ||
} | ||
|
||
dependencies = { | ||
"torch >= 7.0", | ||
} | ||
|
||
build = { | ||
type = "make", | ||
makefile = "Makefile.lua", | ||
build_variables = { | ||
CXXFLAGS="$(CFLAGS) -I$(LUA_INCDIR)", | ||
LDFLAGS="$(LIBFLAG) -L$(LUA_LIBDIR)", | ||
}, | ||
install_variables = { | ||
LIBDIR="$(LIBDIR)", | ||
}, | ||
} |