-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
-Integrate with Paddle libs -Integrate with C++ code from liuyiquan -Create Objective C wrapper and bridging header to call from client in Swift -Able to capture video from device camera and output image buffer -Create hardcode data to draw bounding box and label
|
||
namespace image { | ||
|
||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this code, if it is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is removed in the newer version.
const size_t nChannels, | ||
const size_t dstHeight, | ||
const size_t dstWidth) { | ||
float ratioX = srcWidth * 1.0 / dstWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use static_cast<float>
replace * 1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The code is copied from another project, not refined but just for advanced use then.
float a2 = newX - x1; | ||
|
||
unsigned char* ptDst = outputImage + (i * dstWidth + j) * nChannels; | ||
unsigned char* ptSrc = const_cast<unsigned char*>(inputImage) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why need const_cast
? I think ptSrc
can be defined as const unsigned char*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
normed_channel_(0) { | ||
// Initalize Paddle | ||
char* argv[] = {const_cast<char*>("--use_gpu=False")}; | ||
CHECK(paddle_init(1, (char**)argv)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function which calls paddle_init
should be a static function and need to ensure that paddle_init
will only be called once.
void InitPaddle() {
static paddle_error ret = paddle_init(1, (char**)argv);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
private: | ||
paddle_gradient_machine gradient_machine_; | ||
paddle_error error_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error_
does not seem to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am considering to record the error instead of exiting directly...
const size_t height, | ||
const size_t width, | ||
const size_t channel) { | ||
// if (height == normed_height && width == normed_width && channel == |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the useless code (line 205-219).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is refined. When the input's size is the same as the normed, then resize is not needed.
// Bilinear Interpolation Resize | ||
unsigned char* resized_pixels = (unsigned char*)malloc( | ||
resized_height * resized_width * channel * sizeof(unsigned char)); | ||
image::resize_hwc(pixels, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From 228 to 255 is it possible to merge into one function? Convert the hwc format data with char type to chw format data with float type. This can improve image preprocessing performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will make the code not readable and difficult to debug. A rotation is also needed now. We profile the time then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hedaoyuan The c++ code is not the final version. It is for the first use in the demo and I'll refine it.
|
||
namespace image { | ||
|
||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is removed in the newer version.
const size_t nChannels, | ||
const size_t dstHeight, | ||
const size_t dstWidth) { | ||
float ratioX = srcWidth * 1.0 / dstWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The code is copied from another project, not refined but just for advanced use then.
float a2 = newX - x1; | ||
|
||
unsigned char* ptDst = outputImage + (i * dstWidth + j) * nChannels; | ||
unsigned char* ptSrc = const_cast<unsigned char*>(inputImage) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
const size_t height, | ||
const size_t width, | ||
const size_t channel) { | ||
// if (height == normed_height && width == normed_width && channel == |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is refined. When the input's size is the same as the normed, then resize is not needed.
// Bilinear Interpolation Resize | ||
unsigned char* resized_pixels = (unsigned char*)malloc( | ||
resized_height * resized_width * channel * sizeof(unsigned char)); | ||
image::resize_hwc(pixels, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will make the code not readable and difficult to debug. A rotation is also needed now. We profile the time then.
normed_channel_(0) { | ||
// Initalize Paddle | ||
char* argv[] = {const_cast<char*>("--use_gpu=False")}; | ||
CHECK(paddle_init(1, (char**)argv)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
private: | ||
paddle_gradient_machine gradient_machine_; | ||
paddle_error error_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am considering to record the error instead of exiting directly...
…curacy threshold and time refresh rate
@nickyfantasy @hedaoyuan @NHZlX
|
Add paddle logo
|
I have uploaded the models to a server:
|
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these blank lines.
Demo/iOS/AICamera/AICamera/SSDData.h
Outdated
@end | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these blank lines too.
Demo/iOS/AICamera/AICamera/SSDData.m
Outdated
self = [super init]; | ||
if (self) { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing between the if
statement? Then remove the line 17-19.
case .PascalMobileNet160: | ||
return (160, 160) | ||
case .PascalVGG300: | ||
return (300, 300) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove line 14-15 and line 25-28.
} else if ssdModel == SSDModel.PascalMobileNet300 { | ||
highlightBtn = pascalMobileNetBtn; | ||
} else if ssdModel == SSDModel.PascalVGG300 { | ||
highlightBtn = pascalVgg300Btn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this also be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to keep this. We give users an option to download and try VGG model, for now we hide the button when the model cannot be found
previewLayer.frame = previewContainer.bounds | ||
previewLayer.contentsGravity = kCAGravityResizeAspect | ||
previewLayer.videoGravity = AVLayerVideoGravityResizeAspect | ||
// previewLayer.connection.videoOrientation = .portrait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line since it is of no use.
// if (isRestarting) { | ||
// restart() | ||
// return; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all unused codes in this file.
@@ -0,0 +1,360 @@ | |||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cpp file is updated in https://github.com/PaddlePaddle/Mobile/tree/develop/Demo/linux . However, the paddle_image_recognizer.cpp
is split into two files. I found the format of c++ codes in this project is
disorderly. Did you copy the origin file to this project, or copy and paste the codes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I put image_utils in there as well. Now I copied paddle_image_recognizer and image_utils from linux Demo to here
Demo/iOS/AICamera/README.md
Outdated
|
||
//QR code link | ||
|
||
//screenshot link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make a directory images
and put the images here, then use following codes to link the images:
![image](./images/QR_code.jpg)
![image](./images/demo_screenshot.jpg)
Demo/iOS/AICamera/README.md
Outdated
| ------------------------ |:----------:| --------:| | ||
| face_mobilenet_160_91 | 160x160 | 71% | | ||
| pascal_mobilenet_300_66 | 300x300 | 91% | | ||
| vgg_ssd_net | 300x300 | 66% | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model and accuracy does not match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work. I'll approve it and merge it first. The README
still need to refine, but we can do in next PR.
@jetfuel @hedaoyuan @Xreki