프로그램 사용/gcc2021. 3. 25. 16:53

어떤게 변환되는지도 확인이 가능한 듯.

-ftree-vectorizer-verbose=[n] controls vectorization reports, with n ranging from 0 (no information reported) to 6 (all information reported).

 

25가지 예가 있는데 for a = b + c 같은건 된다고 한다.

Example 12: Induction:
Example 13: Outer-loop:
Example 14: Double reduction:
Example 15: Condition in nested loop:
Example 16: Load permutation in loop-aware SLP:
Example 17: Basic block SLP:
Example 18: Simple reduction in SLP:
Example 19: Reduction chain in SLP:
Example 20: Basic block SLP with multiple types, loads with different offsets, misaligned load, and not-affine Example 21: Backward access:
Example 22: Alignment hints:
Example 23: Widening shift:
Example 24: Condition with mixed types:
Example 25: Loop with bool:

[링크 : https://gcc.gnu.org/projects/tree-ssa/vectorization.html#using]

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

gcc %p (nil)  (0) 2021.05.07
gcc -D 옵션 인자를 printf로 출력하기  (0) 2021.04.08
gcc -march 옵션  (0) 2021.01.24
g++ 은 정적 빌드가 안되나?  (0) 2021.01.19
gcc offloading support  (0) 2020.11.24
Posted by 구차니

inference_input_type과 interfence_output_type을 tf.int8로 지정해주면 양자화 해주는 듯

import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_dataset
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8  # or tf.uint8
converter.inference_output_type = tf.int8  # or tf.uint8
tflite_quant_model = converter.convert()

 

[링크 : https://www.tensorflow.org/lite/performance/post_training_quantization]

[링크 : https://www.tensorflow.org/lite/performance/post_training_integer_quant?hl=ko]

 

+

2021.03.31

import tensorflow as tf
import numpy as np

saved_model_dir="./"

#def representative_dataset():
#  for data in tf.data.Dataset.from_tensor_slices((images)).batch(1).take(100):
#    yield [data.astype(tf.float32)]

def representative_dataset():
    for _ in range(100):
      data = np.random.rand(1, 244, 244, 3)
      yield [data.astype(np.float32)]

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_dataset
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8  # or tf.uint8
converter.inference_output_type = tf.int8  # or tf.uint8
tflite_quant_model = converter.convert()
open("saved_model.tflite", "wb").write(tflite_quant_model)

[링크 : https://bugloss-chestnut.tistory.com/entry/Tensorflow-tflite를-Quantization양자화하기python]

 

도대체 왜 크기가 안 맞는다고 나올까..

다시보니.. 모델은 320x320 인데 244x244로 되어서 안 맞아서 그런듯.

Traceback (most recent call last):
  File "conv.sh", line 21, in <module>
    tflite_quant_model = converter.convert()
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/lite.py", line 742, in convert
    result = self._calibrate_quantize_model(result, **flags)
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/lite.py", line 459, in _calibrate_quantize_model
    return calibrate_quantize.calibrate_and_quantize(
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/optimize/calibrator.py", line 97, in calibrate_and_quantize
    self._calibrator.Prepare([list(s.shape) for s in sample])
RuntimeError: tensorflow/lite/kernels/reshape.cc:69 num_input_elements != num_output_elements (5136 != 7668)Node number 93 (RESHAPE) failed to prepare.

 

(1,320,320,3) 으로 바꾸니 5136에서 8136 으로 바뀌었다.

저 수식 어떻게 되어먹은거야?

RuntimeError: tensorflow/lite/kernels/reshape.cc:69 num_input_elements != num_output_elements (8136 != 7668)Node number 93 (RESHAPE) failed to prepare.

 

아무튼.. pipeline.config를 보니 300x300 이라 넘어는 가는데..

이건 또 무슨 에러냐..

RuntimeError: Quantization not yet supported for op: 'CUSTOM'.

 

Posted by 구차니

아놔.. 라즈베리용 빌드를 썼더니.. -_-

libtensorflowlite.a 가 neon-vfp4 용으로 빌드되어서 정상작동하지 않아 저런 에러가 난건가?

확신은 못하겠지만 아무튼.. 라이브러리도, label_image도 모두 다시 빌드하니 문제없이 돌아는 간다.

 

 

---

혹시나 해서 입력 사이즈를

label_image 소스에서 224*224 로 되어있는 부분을 320*320으로 바꾸어 줘도 동일하게 에러가 발생한다 -_-

 

netron 으로 모델을 확인해보는데 정보가 많이 상이하긴 하다.

 

파일명 처럼 quantization 되어 있어서 0~1로 uint8로 받고 출력은 uint8[1,1001]

 

변환한 녀석은 float32[1,300,300,3] 차원은 동일한데 float32 형이라는게 차이가 있고

출력이 왜이렇게 여러가지가 존재하는거지?

 

[링크 : https://github.com/.../mobilenet_quant_v1_224.tflite]

Posted by 구차니

모델은 320x320이고

label_image 예제는 224x224 로 차이가 있긴한데

입력 이미지 크기도 영향을 받으려나?

 

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

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

 

Posted by 구차니

파이썬 경로는 매번 이상하네..

$ python3 export_tflite_graph_tf2.py --pipeline_config_path ssd_mobilenet_v2_320x320_coco17_tpu-8/pipeline.config --trained_checkpoint_dir ssd_mobilenet_v2_320x320_coco17_tpu-8/checkpoint/ --output_directory output
$ tflite_convert  --output_file saved_model.tflite --saved_model_dir ./

 

위는 변환에 사용한 ssd_mobilenet_v2_320x320_coco17_tpu-8 의 모델

아래는 export_tflite_graph_tf2.py를 통해 변환된 모델과 해당 모델은 tflite_convert를 통해서 변환한 tflite 모델

용량도 좀 변했는데 먼가 처리를 하긴 한 듯.

-rw-r----- 1 minimonk minimonk 9196842  7월 10  2020 saved_model.pb
-rw-r----- 1 minimonk minimonk 24548676  7월 10  2020 variables.data-00000-of-00001
-rw-r----- 1 minimonk minimonk     6158  7월 10  2020 variables.index

-rw-rw-r-- 1 minimonk minimonk  9321388  2월 26 19:14 saved_model.pb
-rw-rw-r-- 1 minimonk minimonk 24248516  2월 26 19:16 saved_model.tflite
-rw-rw-r-- 1 minimonk minimonk 24546669  2월 26 19:14 variables.data-00000-of-00001
-rw-rw-r-- 1 minimonk minimonk    19031  2월 26 19:14 variables.index

2021/02/24 - [프로그램 사용/yolo_tensorflow_golo] - tflite convert

Posted by 구차니

공식적으로 정리된 용어집이 없냐!!!!

 

모델은 텐서가 먼가를 연산하는 함수 기능?

A model is, abstractly:

A function that computes something on tensors (a forward pass) Some variables that can be updated in response to training

[링크 : http://www.tensorflow.org/guide/intro_to_graphs]

 

그래프는 tf.Operation 객체의 집합을 포함하는 데이터 구조

Graphs are data structures that contain a set of tf.Operation objects, which represent units of computation; and tf.Tensor objects, which represent the units of data that flow between operations

[링크 : http://www.tensorflow.org/guide/intro_to_modules]

 

체크포인트는 모델에 의해서 사용되는 모든 패러미터의 정확한 값을 캡쳐한다.

Checkpoints capture the exact value of all parameters (tf.Variable objects) used by a model. Checkpoints do not contain any description of the computation defined by the model and thus are typically only useful when source code that will use the saved parameter values is available.

[링크 : http://www.tensorflow.org/guide/checkpoint]

[링크 : http://www.tensorflow.org/guide/saved_model]

 

 

Posted by 구차니

계속 tflite_convert 만 사용했는데 export_Tflite_graph_tf2.py 라는 다른 녀석을 발견했다.

ssd mobilenetv2를 주로 사용했었으니 이걸로 tflite 변환이 잘되면 좋겠네 ㅠㅠ

 

NOTE: This only supports SSD meta-architectures for now.

[링크 : http://github.com/tensorflow/models/blob/master/research/object_detection/export_tflite_graph_tf2.py]

[링크 : http://github.com/tensorflow/models/issues/9371]

 

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

ssd model convert for tflite  (0) 2021.02.26
tensorflow 용어 정의  (0) 2021.02.25
tensorflow flex ops  (0) 2021.02.23
tensorflow 1.15 설치가 힘들군  (0) 2021.02.22
tensorflow2 학습 해보기 어렵네..  (0) 2021.02.20
Posted by 구차니

flex ops라는 말이 많이 나와서 도대체 멀까 정의를 찾아보는데 공식적인 문서는 발견하지 못했지만..

select 텐서플로우 ops를 텐서플로우 라이트에서 사용하는 내부 코드의 명칭

이라고 하니 더 이해가 안되네?

 

"Flex" is the internal code name for the "Using TensorFlow Lite with select TensorFlow ops" feature.

[링크 : http://stackoverflow.com/questions/53824223/what-does-flex-op-mean-in-tensorflow]

[링크 : https://www.tensorflow.org/lite/guide/ops_select]

 

+

[링크 : https://github.com/tensorflow/tensorflow/issues/45875]

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

tensorflow 용어 정의  (0) 2021.02.25
tflite convert  (0) 2021.02.24
tensorflow 1.15 설치가 힘들군  (0) 2021.02.22
tensorflow2 학습 해보기 어렵네..  (0) 2021.02.20
tensorflow 객체 탐지 디렉토리 구조  (0) 2021.02.19
Posted by 구차니

 

$ python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

 

$ pip3 install tensorflow==1.15.5
ERROR: Could not find a version that satisfies the requirement tensorflow==1.15.5 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.2.2, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.3.2, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0, 2.4.1)
ERROR: No matching distribution found for tensorflow==1.15.5

[링크 : https://pypi.org/project/tensorflow/1.15.5/]

 

[링크 : https://stackoverflow.com/questions/61491893/i-cannot-install-tensorflow-version-1-15-through-pip]

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

tflite convert  (0) 2021.02.24
tensorflow flex ops  (0) 2021.02.23
tensorflow2 학습 해보기 어렵네..  (0) 2021.02.20
tensorflow 객체 탐지 디렉토리 구조  (0) 2021.02.19
tensorflow model 학습 시작지점  (0) 2021.02.18
Posted by 구차니

재생하려니 안되고...

Pixel format yuv420p is not supported, use bgr24

 

pix_fmt 로 바꾸려고 하니 안되네.. -_-

Incompatible pixel format 'bgr24' for codec 'mpeg4', auto-selecting format 'yuv420p'

 

오잉?

-pix_fmts           show available pixel formats
-sample_fmts        show available audio sample formats
-f fmt              force format

 

 

+

하드웨어 가속을 못 받아서 그런가 무지 힘들어 하네

 

$ ffmpeg -re -i INPUT -c:v rawvideo -pix_fmt bgra -f fbdev /dev/fb0

[swscaler @ 0x2020050] No accelerated colorspace conversion found from yuv420p to rgb24.

[링크 : https://ffmpeg.org/ffmpeg-devices.html#Examples-12]

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

mp4 복구 시도  (0) 2022.01.24
ffmpeg을 이용한 rgb565 to bmp  (0) 2021.10.18
ffmpeg fbdev  (0) 2021.02.09
ffmpeg build  (0) 2020.11.25
webm을 mp3로 변환하기  (0) 2020.04.01
Posted by 구차니