tf.size() tflite 호환 연산자 목록에 없긴한데

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

 

tf.size()는... tflite 지원인지 아닌지 말이 없네?

[링크 : https://www.tensorflow.org/api_docs/python/tf/size?hl=ko]

 

하라는 대로 하니 변환은 되었다?

아무래도 tflite_convert에는 없는 SELECT_TF_OPS 같은게 있어서 그런가?

import tensorflow as tf

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.target_spec.supported_ops = [
  tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
  tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

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

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

 

일단은 먼진 몰라도 그냥 pb가 있는거 대충 받는 링크

[링크 : https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2]

[링크 : https://tfhub.dev/tensorflow/retinanet/resnet101_v1_fpn_1024x1024/1]

 

tflite-converter.py 에서 뒤져보니 아래와 같은 옵션을 주어야 작동하는건가..?

  if flags.experimental_select_user_tf_ops:
    if lite.OpsSet.SELECT_TF_OPS not in converter.target_spec.supported_ops:
      raise ValueError("--experimental_select_user_tf_ops can only be set if "
                       "--target_ops contains SELECT_TF_OPS.")

 

+

변환한 파일을 실행하니 죽는다 -_ㅠ overflowed.. 무시무시한 에러인데?

$ ./label_image -i 2012060407491899196_l.jpg -m test.tflite 
INFO: Loaded model go.tflite
INFO: resolved reporter
ERROR: tensorflow/lite/core/subgraph.cc BytesRequired number of elements overflowed.

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

Posted by 구차니

변환하기 힘들다 ㅠㅠ

실행해보니 pb나 tflite 를 읽어서 시각화 하는데

tensorboard랑 비슷하다고 해야하나 다르다고 하나.. 보이는 방식은 가로로(tensroboard) 세로로(netron) 보이는 차이인것 같기도 하고..

다만 버전정보가 똭 보이는건 편하네..

그리고 tensorboard보다는 빠른 느낌이다.

 

[링크 : https://devinlife.com/tensorflow%20lite/tflite-simple-regression/]

[링크 : https://github.com/lutzroeder/netron]

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

tensorflowlite build  (0) 2021.01.28
pb to tflite 변환 part 2...  (0) 2021.01.27
pb to tflite, tensorboard  (0) 2021.01.26
tensorflow pb to tflite  (0) 2021.01.25
텐서플로우 - detection과 classification  (0) 2021.01.22
Posted by 구차니

tensorboard

먼가 복잡하게 나오는데 보는법을 모르겠다? ㅠㅠ

[링크 : https://urbangy.tistory.com/38]

[링크 : https://eehoeskrap.tistory.com/322]

 

pb to tflite

영... 실패중.. ㅠㅠ

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

 

$ python3 /home/minimonk/src/tensorflow/tensorflow/lite/python/tflite_convert.py --saved_model_dir=./saved_model --output_file=output.tflite
2021-01-26 19:01:39.223104: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-01-26 19:01:39.223142: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-01-26 19:01:41.278842: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-01-26 19:01:41.279042: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2021-01-26 19:01:41.279063: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2021-01-26 19:01:41.279101: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (mini2760p): /proc/driver/nvidia/version does not exist
2021-01-26 19:01:41.279527: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-01-26 19:01:55.229040: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:316] Ignored output_format.
2021-01-26 19:01:55.229092: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:319] Ignored drop_control_dependency.
2021-01-26 19:01:55.229117: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:325] Ignored change_concat_input_ranges.
2021-01-26 19:01:55.230250: I tensorflow/cc/saved_model/reader.cc:32] Reading SavedModel from: ./saved_model
2021-01-26 19:01:55.349428: I tensorflow/cc/saved_model/reader.cc:55] Reading meta graph with tags { serve }
2021-01-26 19:01:55.349498: I tensorflow/cc/saved_model/reader.cc:93] Reading SavedModel debug info (if present) from: ./saved_model
2021-01-26 19:01:55.349576: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-01-26 19:01:55.676408: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:196] None of the MLIR optimization passes are enabled (registered 0 passes)
2021-01-26 19:01:55.748285: I tensorflow/cc/saved_model/loader.cc:206] Restoring SavedModel bundle.
2021-01-26 19:01:55.826459: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 2494460000 Hz
2021-01-26 19:01:56.738523: I tensorflow/cc/saved_model/loader.cc:190] Running initialization op on SavedModel bundle at path: ./saved_model
2021-01-26 19:01:57.100034: I tensorflow/cc/saved_model/loader.cc:277] SavedModel load for tags { serve }; Status: success: OK. Took 1869785 microseconds.
2021-01-26 19:01:58.857435: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:194] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.
2021-01-26 19:01:59.851936: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
loc(callsite(callsite("Postprocessor/BatchMultiClassNonMaxSuppression/MultiClassNonMaxSuppression/SortByField_1/Size@__inference_call_func_10155" at "StatefulPartitionedCall@__inference_signature_wrapper_11818") at "StatefulPartitionedCall")): error: 'tf.Size' op is neither a custom op nor a flex op
error: failed while converting: 'main': Ops that can be supported by the flex runtime (enabled via setting the -emit-select-tf-ops flag):
	tf.Size {device = ""}
Traceback (most recent call last):
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/convert.py", line 210, in toco_convert_protos
    model_str = wrap_toco.wrapped_toco_convert(model_flags_str,
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/wrap_toco.py", line 32, in wrapped_toco_convert
    return _pywrap_toco_api.TocoConvert(
Exception: <unknown>:0: error: loc(callsite(callsite("Postprocessor/BatchMultiClassNonMaxSuppression/MultiClassNonMaxSuppression/SortByField_1/Size@__inference_call_func_10155" at "StatefulPartitionedCall@__inference_signature_wrapper_11818") at "StatefulPartitionedCall")): 'tf.Size' op is neither a custom op nor a flex op
<unknown>:0: note: loc("StatefulPartitionedCall"): called from
<unknown>:0: error: failed while converting: 'main': Ops that can be supported by the flex runtime (enabled via setting the -emit-select-tf-ops flag):
	tf.Size {device = ""}


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/minimonk/src/tensorflow/tensorflow/lite/python/tflite_convert.py", line 698, in <module>
    main()
  File "/home/minimonk/src/tensorflow/tensorflow/lite/python/tflite_convert.py", line 694, in main
    app.run(main=run_main, argv=sys.argv[:1])
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/minimonk/.local/lib/python3.8/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/minimonk/.local/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "/home/minimonk/src/tensorflow/tensorflow/lite/python/tflite_convert.py", line 677, in run_main
    _convert_tf2_model(tflite_flags)
  File "/home/minimonk/src/tensorflow/tensorflow/lite/python/tflite_convert.py", line 265, in _convert_tf2_model
    tflite_model = converter.convert()
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/lite.py", line 739, in convert
    result = _convert_saved_model(**converter_kwargs)
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/convert.py", line 632, in convert_saved_model
    data = toco_convert_protos(
  File "/home/minimonk/.local/lib/python3.8/site-packages/tensorflow/lite/python/convert.py", line 216, in toco_convert_protos
    raise ConverterError(str(e))
tensorflow.lite.python.convert.ConverterError: <unknown>:0: error: loc(callsite(callsite("Postprocessor/BatchMultiClassNonMaxSuppression/MultiClassNonMaxSuppression/SortByField_1/Size@__inference_call_func_10155" at "StatefulPartitionedCall@__inference_signature_wrapper_11818") at "StatefulPartitionedCall")): 'tf.Size' op is neither a custom op nor a flex op
<unknown>:0: note: loc("StatefulPartitionedCall"): called from
<unknown>:0: error: failed while converting: 'main': Ops that can be supported by the flex runtime (enabled via setting the -emit-select-tf-ops flag):
	tf.Size {device = ""}

 

[링크 : https://bekusib.tistory.com/210]

[링크 : https://bugloss-chestnut.tistory.com/entry/Tensorflow-keras-h5-pb-tflite-변환-오류python]

[링크 : https://gmground.tistory.com/entry/학습된-모델을-TensorFlow-Lite-모델tflite로-변환하여-Android에서-Object-Classification-해보기]

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

pb to tflite 변환 part 2...  (0) 2021.01.27
tensorflow netron  (0) 2021.01.27
tensorflow pb to tflite  (0) 2021.01.25
텐서플로우 - detection과 classification  (0) 2021.01.22
텐서플로우 모델 출력? (metadata?)  (0) 2021.01.21
Posted by 구차니

문득 생각이 들어 비싼 이어폰 써야 한대서

아부지 협찬으로 비싼(!) 이어폰 빌려서 해봤는데

내 기준으로는 그냥 볼륨이 커져서 작은 소리까지 잘 들리는 느낌?

 

그런 이유로 quad dac 켜면 미세하게 볼륨 조절되고 최대 볼륨이 더 커지는 게 개인적인 효과

다이나믹 레인지나 이런건 솔찍히 잘 모르겠고

 

en50332 이라는 표준에 의해 청각에 손상입지 않을 세기로 핸드폰 볼륨이 정해졌다고

[링크 : http://www.0db.co.kr/REVIEW_0DB/904118]

[링크 : https://www.clien.net/service/amp/board/park/11139522]

 

300옴

[링크 : http://danawa.com/product/product.html?code=74145&cateCode=12237350]

 

 

 

'개소리 왈왈 > 모바일 생활' 카테고리의 다른 글

v50s 색감이..  (0) 2021.02.06
모바일 크롬 탭 설정 변경  (0) 2021.02.02
LG 핸드폰 접는건가?!  (0) 2021.01.20
MMS가 안가서 검색을 해보니  (2) 2021.01.15
(이제야) 갤럭시 폴드 동영상을 보니  (2) 2021.01.15
Posted by 구차니

saved_model 디렉토리 전체가 필요하군..

단순하게 pb2만 있으면 되는게 아니군아..

 

Converting a SavedModel
tflite_convert \
  --saved_model_dir=/tmp/mobilenet_saved_model \
  --output_file=/tmp/mobilenet.tflite

Converting a Keras H5 model
tflite_convert \
  --keras_model_file=/tmp/mobilenet_keras_model.h5 \
  --output_file=/tmp/mobilenet.tflite

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

[링크 : https://stackoverflow.com/questions/52918051/how-to-convert-pb-to-tflite-format]

Posted by 구차니
프로그램 사용/gcc2021. 1. 24. 11:24

오늘도 어김없이(?) 노인학대 옵션 찾는중

3.19.59 x86 Options
These ‘-m’ options are defined for the x86 family of computers.

-march=cpu-type
‘sandybridge’
Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AES and PCLMUL instruction set support.

[링크 : https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html]

 

+

그래도 tensorflow 빌드 해서 실행하는데 속도에 유의미한 영향을 주진 않네

이런 라즈베리 파이 만도 못한 내 노트북 ㅠㅠㅠㅠ

(라즈베리 4코어 + neon 가속시  170ms 정도, i5-2520m 에서 1300ms ㅠㅠ)

Posted by 구차니

종일권은 쓸만한데 2시간 권은 좀 아쉬운 곳

1200평이라 남양주의 꼬꼬마아 600평에 비하면 2배라는데 체감은 그 이상

아무래도 직사각형과 정사각형에 가까운 구성이라 체감이 다른걸려나

 

가서 느낀건 머랄까 예식장을 롤라장으로 바꾸었다가 키즈카페로 업그레이드 한거 아냐 라는 느낌 ㅋ

 

[링크 : https://www.youtube.com/watch?v=m6oM4ba8oG0]

[링크 : https://rollerbounce.modoo.at/]

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

고통의 시간.. ㅠㅠ  (2) 2021.01.30
문을 파괴한다!  (0) 2021.01.30
오늘자 득템  (0) 2021.01.18
UHD 프로그램이 별로 없네  (0) 2021.01.17
1인 사우나를 샀다 그리고 핸드폰을 빼앗겼다  (0) 2021.01.15
Posted by 구차니
Linux2021. 1. 22. 15:36

ipcs 로 확인하고

ipcrm 으로 삭제한다.

$ ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x000f1206 0          minimonk   666        4          0

$ ipcrm shm 0
resource(s) deleted

$ ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status

[링크 : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/sect-oracle_9i_and_10g_tuning_guide-setting_shared_memory-removing_shared_memory]

'Linux' 카테고리의 다른 글

리눅스 스마트 카드 api  (0) 2021.02.02
linux smart card  (0) 2021.02.02
linux 프레임 버퍼에 이미지, 동영상 재생하기  (0) 2021.01.21
sit1 인터페이스  (0) 2021.01.20
특정 버전의 파일로 링크걸어서 빌드하기  (0) 2021.01.12
Posted by 구차니

detection은 객체의 종류와 확률 그리고 "위치"를 얻는다면

[링크 : https://www.tensorflow.org/lite/models/object_detection/overview]

 

classification은 객체의 종류와 확률 만을 결과로 얻는다.

[링크 : https://www.tensorflow.org/lite/models/image_classification/overview]

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

pb to tflite, tensorboard  (0) 2021.01.26
tensorflow pb to tflite  (0) 2021.01.25
텐서플로우 모델 출력? (metadata?)  (0) 2021.01.21
tensorflow 객체 탐지 예제  (0) 2021.01.21
tensorflow lite on x86 / label_image  (0) 2021.01.20
Posted by 구차니

+ 2021.01.22

다시 정리하고 와서 보니

위에는 classification tflite 파일이고 아래는 detection 이니 차이가 나는 듯.

 

+

tflite 파일 vi로 보니 문자열들이 좀 보이는데, python 써서 출력이 가능하려나?

[링크 : https://www.tensorflow.org/lite/convert/metadata]

 

---

output_tensor_metadata 에서

name:probability 라는게 있는데

[링크 : https://tfhub.dev/google/lite-model/aiy/vision/classifier/food_V1/1]

[링크 : https://tfhub.dev/google/lite-model/cropnet/classifier/cassava_disease_V1/1]

 

다른 tfilte 파일에서 보니

output_tensor_groups 라는게 존재해서 tensor_names로 3개의 출력이 존재하고

output_tensor_metadata 에 name:location, name:category, name:score 가 존재한다.

[링크 : https://tfhub.dev/google/lite-model/object_detection/mobile_object_localizer_v1/1/metadata/2]

 

출력에서 여러개 출력을 내는건.. 해당 프로젝트에서 사용하는 tflite 파일이 그렇게 생성 되었기 때문인건가?

Output Signature
The model outputs four arrays, mapped to the indices 0-4. Arrays 0, 1, and 2 describe N detected objects, with one element in each array corresponding to each object.

[링크 : https://www.tensorflow.org/lite/models/object_detection/overview]

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

tensorflow pb to tflite  (0) 2021.01.25
텐서플로우 - detection과 classification  (0) 2021.01.22
tensorflow 객체 탐지 예제  (0) 2021.01.21
tensorflow lite on x86 / label_image  (0) 2021.01.20
tensorflow-lite 모델  (0) 2021.01.18
Posted by 구차니