Skip to content

Commit 197bf8f

Browse files
committed
update news
1 parent d6a3e37 commit 197bf8f

File tree

155 files changed

+17446
-3834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+17446
-3834
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/Build_pycaffe/
12
/3rd/include
23
/3rd/staticlib
34
/Build

3rd/README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
如果要编译,请下载3rd.rar后解压缩到这个目录下
2-
3-
https://pan.baidu.com/s/1Dc38GgfZ8TQ79ll162k_wA
1+
# 3rd
2+
请下载3rd.rar,解压到本目录即可
3+
目录结构如下:
4+
3rd:
5+
--include
6+
--staticlib
7+
--README.md

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CC4.0
2-
Caffe for CC4.0-Windows,简单的Caffe C++接口,方便简单而更深入的研究深度学习 a
2+
Caffe for CC4.0-Windows,简单的Caffe C++接口,方便简单而更深入的研究深度学习
33

44
# 特性
55
1.只需要一个头文件和一个依赖项libcaffe.lib<br/>
@@ -9,7 +9,6 @@ Caffe for CC4.0-Windows,简单的Caffe C++接口,方便简单而更深入的
99
5.支持LSTM不定长OCR(有案例),支持SSD更轻易的训练起来<br/>
1010
6.有了4.0的支持,很轻易的能够实现任何新的网络结构<br/>
1111
7.可以允许通过自定义层,训练中查看训练效果,更加容易理解CNN在干嘛,学的效果怎么样,不再盲目了<br/>
12-
8.接口查看[cc.h](https://github.com/dlunion/CC4.0/blob/master/include/caffe/cc/core/cc.h)[cc_utils.h](https://github.com/dlunion/CC4.0/blob/master/include/caffe/cc/core/cc_utils.h)
1312

1413
# 编译
1514
编译环境:VS2013<br/>
@@ -21,8 +20,7 @@ CUDNN版本:5.0<br/>
2120

2221
# 下载编译好的库文件和案例等数据
2322
推荐使用VS2013,下载后压缩包已经配置好环境和带好了OpenCV2.4.10静态库<br/>
24-
<del>[CC4.0.3.rar-百度网盘](https://pan.baidu.com/s/1OQDmxWwVpVohER2YMqGbZQ)</del>,里面的依赖可以用,但是头文件和libcaffe.dll不可用(因为有几个bug),等待重新编译并上传<br/>
25-
Win32-GPU编译,请下载[CUDA6.5 ToolKit](http://www.zifuture.com/fs/18.cc4.0/CUDAToolkit.rar)<br/>
23+
<del>[CC4.0.3.rar-百度网盘](https://pan.baidu.com/s/1OQDmxWwVpVohER2YMqGbZQ)</del>,里面的依赖可以用,但是头文件和libcaffe.dll不可用(因为有几个bug),等待重新编译并上传
2624

2725
# 案例
2826
非常容易在C++里面实现自己的datalayer、losslayer等,自定义数据的输入等

include/caffe/cc/core/cc.h

+88-12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace cc{
3737
public:
3838
operator char*(){ return get(); }
3939
operator const char*(){ return get(); }
40+
bool operator==(const char* str){ return strcmp(get(), str) == 0; }
4041
CCString& operator=(const char* str){ set(str); return *this; }
4142
CCString& operator=(char* str){ set(str); return *this; }
4243
CCString& operator=(const CCString& str){ set(str.get(), str.len()); return *this; }
@@ -171,6 +172,28 @@ namespace cc{
171172
};
172173

173174
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
175+
//轻量级的Blob
176+
class Blob;
177+
struct CCAPI BlobData{
178+
float* list;
179+
int num;
180+
int channels;
181+
int height;
182+
int width;
183+
int capacity_count; //保留空间的元素个数长度,字节数请 * sizeof(float)
184+
185+
BlobData();
186+
virtual ~BlobData();
187+
bool empty() const;
188+
int count() const;
189+
void reshape(int num, int channels, int height, int width);
190+
void reshapeLike(const BlobData* other);
191+
void copyFrom(const BlobData* other);
192+
void copyFrom(const Blob* other);
193+
void reshapeLike(const Blob* other);
194+
void release();
195+
};
196+
174197
class CCAPI Blob{
175198
public:
176199
void setNative(void* native);
@@ -200,6 +223,7 @@ namespace cc{
200223
void Reshape(int numShape, int* shapeDims);
201224
void ReshapeLike(const Blob& other);
202225
void copyFrom(const Blob& other, bool copyDiff = false, bool reshape = false);
226+
void copyFrom(const BlobData& other);
203227
void setDataRGB(int numIndex, const Mat& data);
204228
CCString shapeString();
205229

@@ -219,6 +243,12 @@ namespace cc{
219243
bool hasParam(const char* path);
220244
CCString name();
221245
MessageHandle* param();
246+
int getNumBottom();
247+
int getNumTop();
248+
CCString bottomName(int index);
249+
CCString topName(int index);
250+
Blob* paramBlob(int index);
251+
int getNumParamBlob();
222252

223253
#ifdef USE_PROTOBUF
224254
caffe::LayerParameter& layer_param();
@@ -273,8 +303,8 @@ namespace cc{
273303
void* getNative();
274304
int iter();
275305
float smooth_loss();
276-
void Restore(const char* resume_file);
277-
void Snapshot();
306+
void Restore(const char* solvestate_file);
307+
void Snapshot(const char* caffemodel_savepath = 0, bool save_solver_state = true);
278308
int max_iter();
279309
void Solve();
280310
void installActionSignalOperator();
@@ -300,8 +330,31 @@ namespace cc{
300330
CCAPI void CCCALL releaseBlob(Blob* blob);
301331
CCAPI void CCCALL releaseSolver(Solver* solver);
302332
CCAPI void CCCALL releaseNet(Net* net);
303-
CCAPI Solver* CCCALL loadSolverFromPrototxt(const char* solver_prototxt);
304-
CCAPI Solver* CCCALL loadSolverFromPrototxtString(const char* solver_prototxt_string);
333+
CCAPI Solver* CCCALL loadSolverFromPrototxt(const char* solver_prototxt, const char* netstring = 0);
334+
CCAPI Solver* CCCALL loadSolverFromPrototxtString(const char* solver_prototxt_string, const char* netstring = 0);
335+
336+
#ifdef USE_CC_PYTHON
337+
class CCAPI CCPython{
338+
public:
339+
CCPython();
340+
virtual ~CCPython();
341+
bool load(const char* pyfile);
342+
CCString callstringFunction(const CCString& name, CCString& errmsg = CCString());
343+
CCString train_ptototxt();
344+
CCString deploy_prototxt();
345+
CCString solver();
346+
CCString last_error();
347+
348+
private:
349+
void* module_;
350+
CCString lasterror_;
351+
};
352+
353+
CCAPI Solver* CCCALL loadSolverFromPython(const char* pythonfile);
354+
355+
//phase指定加载train_prototxt还是deploy_prototxt
356+
CCAPI Net* CCCALL loadNetFromPython(const char* pythonfile, const char* func="deploy_prototxt", int phase = PhaseTest);
357+
#endif
305358

306359
#ifdef USE_PROTOBUF
307360
CCAPI Solver* CCCALL newSolverFromProto(const caffe::SolverParameter* solver_param);
@@ -326,6 +379,21 @@ namespace cc{
326379
CCAPI void CCCALL WriteProtoToBinaryFile(const google::protobuf::Message& proto, const char* filename);
327380
#endif
328381

382+
383+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
384+
class CCAPI LMDB{
385+
public:
386+
LMDB(const char* folder);
387+
void put(const char* key, const void* data, int length);
388+
void putAnnotatedDatum(const char* key, void* datum);
389+
void putDatum(const char* key, void* datum);
390+
void release();
391+
virtual ~LMDB();
392+
393+
private:
394+
void* native_;
395+
};
396+
329397
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
330398
class CCAPI AbstractCustomLayer{
331399
public:
@@ -379,39 +447,44 @@ namespace cc{
379447

380448
class CCAPI DataLayer : public AbstractCustomLayer{
381449
public:
382-
DataLayer();
450+
DataLayer(int batchCacheSize = 3, int watcherSize = 1);
383451
virtual ~DataLayer();
384452

385-
virtual int getBatchCacheSize();
386453
virtual void loadBatch(Blob** top, int numTop) = 0;
387454
virtual void setup(const char* name, const char* type, const char* param_str, int phase, Blob** bottom, int numBottom, Blob** top, int numTop);
388455
virtual void forward(Blob** bottom, int numBottom, Blob** top, int numTop);
389-
virtual void reshape(Blob** bottom, int numBottom, Blob** top, int numTop){}
456+
virtual void reshape(Blob** bottom, int numBottom, Blob** top, int numTop);
390457
void stopBatchLoader();
458+
int getWatcherIndex();
391459
virtual int waitForDataTime();
460+
void setPrintWaitData(bool wait);
392461

393462
private:
394463
void setupBatch(Blob** top, int numTop);
395-
static void watcher(DataLayer* ptr);
464+
static void watcher(DataLayer* ptr, int ind);
396465
void startWatcher();
397466
void stopWatcher();
398467
void pullBatch(Blob** top, int numTop);
399468

400469
private:
401470
volatile bool keep_run_watcher_;
402-
void* hsem_;
403-
bool* batch_flags_;
404-
Blob*** batch_;
471+
void** hsem_;
472+
bool** batch_flags_;
473+
Blob**** batch_; //batch_
405474
int numTop_;
406475
int cacheBatchSize_;
476+
int watcherSize_;
477+
void* watcher_map_;
478+
bool print_waitdata_;
407479
};
408480

409481
class CCAPI SSDDataLayer : public DataLayer{
410482
public:
411-
SSDDataLayer();
483+
SSDDataLayer(int batchCacheSize = 3, int watcherSize = 1);
412484
virtual ~SSDDataLayer();
413485

414486
virtual int getBatchCacheSize();
487+
virtual int getWatcherSize();
415488
virtual void loadBatch(Blob** top, int numTop);
416489
virtual void setup(const char* name, const char* type, const char* param_str, int phase, Blob** bottom, int numBottom, Blob** top, int numTop);
417490
virtual void* getAnnDatum() = 0;
@@ -435,6 +508,9 @@ namespace cc{
435508
CCAPI void CCCALL releaseLabelMap(void* labelmap);
436509
CCAPI void CCCALL releaseAnnDatum(void* datum);
437510

511+
CCAPI void* CCCALL loadDatum(const char* path, int label);
512+
CCAPI void CCCALL releaseDatum(void* datum);
513+
438514

439515
/////////////////////////////////////////////////////////////////////////////
440516
CCAPI MessageHandle CCCALL loadMessageNetCaffemodel(const char* filename);

include/caffe/cc/core/cc_c.h

-79
This file was deleted.

0 commit comments

Comments
 (0)