이전에 했었는데 먼가 내용을 다시보니 부족해서 추가

 

edgetpu 용으로 변환된 모델

$ python3 classify_image.py   --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite   --labels models/inat_bird_labels.txt   --input images/parrot.jpg
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
137.5ms
13.0ms
13.1ms
13.1ms
13.1ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.77734

 

변환되지 않은 모델. 속도 차이가 상당히 나는데 반복 실행시 속도가 줄어들지 않는걸 보면..

tpu 가속을 받지 못하고 cpu로 돌리기 때문이려나?

그리고 정확도는 소수점 5자리 까지 동일하게 나온다.

quantization 으로 인한 정확도 차이는 잘만들면 무시할 만한 수준 이라고 보면 될 듯.

$ python3 classify_image.py \
>   --model models/mobilenet_v2_1.0_224_inat_bird_quant.tflite \
>   --labels models/inat_bird_labels.txt \
>   --input images/parrot.jpg


----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU m                                                                                                           emory.
552.0ms
542.7ms
541.3ms
549.1ms
541.4ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.77734

 

2020.10.20 - [프로그램 사용/google coral] - google coral, ubuntu 18.04

 

 

'프로그램 사용 > google coral' 카테고리의 다른 글

google coral with tpu, cpp  (4) 2022.02.07
edgetpu_c.h 파일 내용 분석  (0) 2022.02.07
tensorflow brace-enclosed initializer list  (4) 2022.02.07
google coral, tpu yolo  (0) 2022.01.27
coral tpu delegate example  (0) 2022.01.25
Posted by 구차니

 

2020년 1월 30일 커밋 되었는데

헤더에 사용법을 넣어두었고 그게 바로.. 문제의 그 내용 -_-

// 4. Modify interpreter with the delegate.
//
// auto* delegate =
//     edgetpu_create_delegate(device.type, device.path, nullptr, 0);
// interpreter->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});


// Frees delegate returned by `edgetpu_create_delegate`.
EDGETPU_EXPORT void edgetpu_free_delegate(TfLiteDelegate* delegate);

[링크 : https://github.com/google-coral/edgetpu/blob/master/libedgetpu/edgetpu_c.h]

 

delegate를 free 하지 않고(메모리 누수를 감수하면..)

위의 함수 원형으로 delegate만 던져주거나

unique_ptr <Delegate, Deleter > 로 랩핑하면 가능을 할 것 같은데

그게 아니라면..  { } 로 감싼 부분이 자동으로 변형되는건 아니겠지? (컴파일러 옵션에 의해)

TfLiteStatus ModifyGraphWithDelegate(
  TfLiteDelegate *delegate
)

TfLiteStatus ModifyGraphWithDelegate(
  std::unique_ptr< Delegate, Deleter > delegate
)

[링크 : https://www.tensorflow.org/lite/api_docs/cc/class/tflite/interpreter#modifygraphwithdelegate_1]

'프로그램 사용 > google coral' 카테고리의 다른 글

google coral with tpu, cpp  (4) 2022.02.07
google coral with tpu, python  (0) 2022.02.07
tensorflow brace-enclosed initializer list  (4) 2022.02.07
google coral, tpu yolo  (0) 2022.01.27
coral tpu delegate example  (0) 2022.01.25
Posted by 구차니

그냥 손에 익숙한(!) v2.4.1을 써서 그런가(구버전 api라서?)

해당 함수가 존재하지 않는다고 에러가 발생하고 빌드에 실패한다.

classify.cc:177:73: error: no matching function for call to ‘tflite::Interpreter::ModifyGraphWithDelegate(<brace-enclosed initializer list>)’
   interpreter->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});
                                                                         ^
In file included from classify.cc:12:
/home/pi/work/coral/tensorflow/tensorflow/lite/interpreter.h:421:16: note: candidate: ‘TfLiteStatus tflite::Interpreter::ModifyGraphWithDelegate(TfLiteDelegate*)’
   TfLiteStatus ModifyGraphWithDelegate(TfLiteDelegate* delegate);
                ^~~~~~~~~~~~~~~~~~~~~~~
/home/pi/work/coral/tensorflow/tensorflow/lite/interpreter.h:421:16: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘TfLiteDelegate*’
/home/pi/work/coral/tensorflow/tensorflow/lite/interpreter.h:431:23: note: candidate: ‘template<class Delegate, class Deleter> TfLiteStatus tflite::Interpreter::ModifyGraphWithDelegate(std::unique_ptr<_Tp, _Dp>)’
   inline TfLiteStatus ModifyGraphWithDelegate(
                       ^~~~~~~~~~~~~~~~~~~~~~~
/home/pi/work/coral/tensorflow/tensorflow/lite/interpreter.h:431:23: note:   template argument deduction/substitution failed:
classify.cc:177:73: note:   couldn't deduce template parameter ‘Delegate’
   interpreter->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});

 

검색해보니 c++x00

 

class Example {
  private:
  public:
    Example(std::initializer_list<int> list) {
    }
};

Example exam = {10,10,10,10,10};

[링크 : https://forum.arduino.cc/t/how-to-make-brace-enclosed-initializer-list-constructor/628295]

 

Phenotype(std::initializer_list<uint8> c) {
  assert(c.size() <= std::size(m_array));
  std::copy(c.begin(), c.end(), m_array);
}

// used like
Phenotype p1{1, 2, 3};
Phenotype p2({1, 3, 2}); // works too
Phenotype p3(1, 2, 3); // doesn't work

[링크 : https://stackoverflow.com/questions/4118025/brace-enclosed-initializer-list-constructor]

 

그나저나 api 문서가 업데이트 늦을수도 있지만

아래의 원형밖에 없는데 std::unique_ptr이 std::initializer_list일 리는 없을테고. 도대체 어떤 함수를 써야 하는걸까?

TfLiteStatus ModifyGraphWithDelegate(
  TfLiteDelegate *delegate
)

TfLiteStatus ModifyGraphWithDelegate(
  std::unique_ptr< Delegate, Deleter > delegate
)

TfLiteStatus ModifyGraphWithDelegate(
  std::unique_ptr< TfLiteDelegate > delegate
)=delete

[링크 : https://www.tensorflow.org/lite/api_docs/cc/class/tflite/interpreter#modifygraphwithdelegate_1]

'프로그램 사용 > google coral' 카테고리의 다른 글

google coral with tpu, python  (0) 2022.02.07
edgetpu_c.h 파일 내용 분석  (0) 2022.02.07
google coral, tpu yolo  (0) 2022.01.27
coral tpu delegate example  (0) 2022.01.25
google coral, ubuntu 18.04  (0) 2020.10.20
Posted by 구차니

요약하면.. 메모리 부족하니 빌드 속도를 포기하고 swap을 이용해서 커버치기!

[링크 : https://gist.github.com/EKami/9869ae6347f68c592c5b5cd181a3b205]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

tensorflow lite / mnist 학습  (0) 2024.01.02
yolo-label  (0) 2022.03.22
bazel cross compile  (0) 2022.01.27
bazel clean  (0) 2021.10.19
2.7.0-rc with opencl  (0) 2021.10.13
Posted by 구차니

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

yolo-label  (0) 2022.03.22
tflite bazel rpi3b+  (0) 2022.01.27
bazel clean  (0) 2021.10.19
2.7.0-rc with opencl  (0) 2021.10.13
tf release 2.7.0-rc  (0) 2021.10.12
Posted by 구차니

'프로그램 사용 > google coral' 카테고리의 다른 글

edgetpu_c.h 파일 내용 분석  (0) 2022.02.07
tensorflow brace-enclosed initializer list  (4) 2022.02.07
coral tpu delegate example  (0) 2022.01.25
google coral, ubuntu 18.04  (0) 2020.10.20
google coral  (0) 2020.10.06
Posted by 구차니
프로그램 사용/VNC2022. 1. 26. 17:07

'프로그램 사용 > VNC' 카테고리의 다른 글

libvncserver 마우스 이벤트  (0) 2022.02.25
libvncserver 사용예  (0) 2022.02.15
gconf-editor / ubuntu 14.04 LTS vino + VNC 접속불가  (0) 2015.03.22
VNC web 버전?  (0) 2014.12.11
VNC 5.0.5  (0) 2013.09.04
Posted by 구차니
프로그램 사용/meson2022. 1. 25. 15:04

 

 

[binaries]
c = '/usr/lib/ccache/arm-linux-gnueabihf-gcc'
cpp = '/usr/lib/ccache/arm-linux-gnueabihf-g++'
ar = '/usr/bin/arm-linux-gnueabihf-ar'
strip = '/usr/bin/arm-linux-gnueabihf-strip'
pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'
 
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv8hl'
endian = 'little'
meson build/ \
    --cross-file=$HOME/pi/mesa/cross_file

[링크 : https://makersweb.net/qt/17557]

 

ubuntu 에서 apt install meson 으로 설치시 구버전이라 발생하는 에러

meson_options.txt:1:0: ERROR:  Unknown type feature.

[링크 : https://github.com/swaywm/wlroots/issues/1258]

 

Ninja는 속도에 중점을 둔 소형 빌드 시스템으로, Make의 느린 증분 빌드의 대안으로 만들어졌습니다.

[링크 : https://int-i.github.io/cpp/2021-06-26/cpp-meson/]

Posted by 구차니

cpp

[링크 : https://github.com/google-coral/tflite]

[링크 : https://coral.ai/docs/edgetpu/tflite-cpp/]

 

 

python

[링크 : https://coding-yoon.tistory.com/91]

 

+

auto* delegate = edgetpu_create_delegate(device.type, device.path, nullptr, 0);
  interpreter->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});

[링크 : https://github.com/google-coral/tflite/blob/master/cpp/examples/classification/classify.cc]

 

auto delegates = delegate_providers.CreateAllDelegates();
  for (auto& delegate : delegates) {
    const auto delegate_name = delegate.provider->GetName();
    if (interpreter->ModifyGraphWithDelegate(std::move(delegate.delegate)) !=
        kTfLiteOk) {
      LOG(ERROR) << "Failed to apply " << delegate_name << " delegate.";
      exit(-1);
    } else {
      LOG(INFO) << "Applied " << delegate_name << " delegate.";
    }
  }

[링크 : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/examples/label_image/label_image.cc]

 

'프로그램 사용 > google coral' 카테고리의 다른 글

edgetpu_c.h 파일 내용 분석  (0) 2022.02.07
tensorflow brace-enclosed initializer list  (4) 2022.02.07
google coral, tpu yolo  (0) 2022.01.27
google coral, ubuntu 18.04  (0) 2020.10.20
google coral  (0) 2020.10.06
Posted by 구차니

h.264 코덱으로 된 녀석이라 데이터 부분만 빼내서 ffmpeg 거치면 재생이 가능할줄 알았는데 무리인가?

 

[링크 : https://video.stackexchange.com/questions/29073]

[링크 : https://codecpack.co/download/recover-mp4.html]

[링크 : https://stackoverflow.com/questions/19300350]

 

+

2022.02.14

복구 성공!

 

동일 기기에서 촬영된 정상 동영상과 복구할 동영상이 필요함

1. 정상 동영상에서 부터 무언가를 추출

C:\> recover_mp4.exe good.mp4 --analyze
/// 중략
Now run the following command to start recovering:
recover_mp4.exe corrupted_file result.h264 --noaudio --ext

Then use ffmpeg to mux the final file:
ffmpeg.exe -r 12.097 -i result.h264 -c:v copy result.mp4

 

2. 비정상 동영상으로 부터 h264 만 추출

위에서 알려준 옵션대로 처리해야 복구가 진행된다.

C:\> recover_mp4.exe corrupted_file result.h264 --noaudio --ext
// 중략
skip: 0x001C02C5 [0x       6] ???           {00 00 00 02 09 F0}
H264: 0x001C02CB [0x    15CA] -> 0x  1BF903 {41 9B A0 14} P frame
%100.000
Complete!
H264 non-IDR NAL unit size: Min 0x4, Avg 0x1289, Max 0x366C
Video=99.864
'result.h264' created, size 1838797 (99.864%)

 

3. 복구 데이터를 이용해서(아마도 h.264 스트림?) mp4로 변환

-r 뒤의 숫자는 framerate 니까 굳이 안 넣어 주면 원본의 속도로 복구 된다. (안되면 넣어주는게 좋을 듯)

C:\> ffmpeg.exe -r 30 -i result.h264 -c:v copy recovered.mp4
Input #0, h264, from 'result.h264':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 800x480, 25 fps, 25 tbr, 1200k tbn
Output #0, mp4, to 'recovered.mp4':
  Metadata:
    encoder         : Lavf59.16.100
  Stream #0:0: Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 800x480, q=2-31, 25 fps, 25 tbr, 15360 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0000020bce548780] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=  363 fps=0.0 q=-1.0 Lsize=    1798kB time=00:00:12.06 bitrate=1220.7kbits/s speed=2.16e+03x
video:1796kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.130085%

[링크 : https://blog.naver.com/winsweet/222340783544]

[링크 : http://slydiman.me/eng/mmedia/recover_mp4.htm]

[링크 : https://restore.media/blog/how-to-fix-corrupted-mp4-files]

Posted by 구차니