SOL4Py Sample: EfficientDet |
pip install tensorflow==2.4.0 pip install cython git clone https://github.com/google/automl.git cd automl git clone https://github.com/cocodataset/cocoapi.git cd cocoapi/PythonAPI # Probably you have to modify extra_compiler_args in setup.py in the following way: # setup.py #extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'], extra_compile_args=['-std=c99'], python setup.py build_ext install pip install pyyaml Please clone the latest EfficientDetector.git in a working directory(det). mkdir c:\work cd c:\work git clone https://github.com/atlan-antillia/EfficientDetector.git |
;saved_model.config [configuration] runmode = saved_model name = efficientdet-d0 model_name = efficientdet-d0 log_dir = ./projects/coco/ tensorrt = None threads = 0 trace_filname = None use_xla = False freeze = False export_ckpt = None delete_logdir = True ckpt_dir = ./efficientdet-d0 saved_model_dir = ./projects/coco/saved_model hparams = ./projects/coco/configs/default.yaml output_image_dir = ./projects/coco/outputs
;detect_config [configuration] runmode = saved_model_infer model_name = efficientdet-d0 ckpt_dir = ./efficientdet-d0 saved_model_dir = ./projects/coco/saved_model ;output_dir = ./projects/coco/outputs hparams = None ;filters = [car] ;filters = [car,person] ;filters = [person] ;filters = None log_dir = ./projects/coco/ label_map_pbtxt = ./projects/coco/mscoco_label_map.pbtxt tensorrt = None threads = 0 trace_filname = None use_xla = False freeze = False export_ckpt = None delete_logdir = True batch_size = 1 output_image_dir = ./projects/coco/outputs detect_results_dir = ./projects/coco/results input_image = ./images/*.* input_video = None output_video = None trace_filename = ./projects/coco/trace.log line_thickness = 2 max_boxes_to_draw = 100 min_score_thresh = 0.2 nms_method = gaussianPlease edit this detect.config file for your own needs.
filters = [car,person]
#****************************************************************************** # # Copyright (c) 2020-2021 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #****************************************************************************** # # DownloadCkpt.py import sys import os import traceback import tarfile import shutil import tensorflow as tf def download_checkpoint_file(): try: #Download checkpoint file url = "https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/efficientdet-d0.tar.gz" folder = "efficientdet-d0" tar_file = "efficientdet-d0.tar.gz" if os.path.exists(folder) != True: print("Try download {}".format(url)) tar_file = tf.keras.utils.get_file(tar_file, url) print("You have downloaded {}".format(tar_file)) with tarfile.open(tar_file, "r:gz") as tar: tar.extractall() else: print("OK, you have the weight file {}!".format(tar_file)) except Exception as ex: traceback.print_exc() if __name__=="__main__": try: MODEL = "efficientdet-d0" ckpt_path = os.path.join(os.getcwd(), MODEL); download_checkpoint_file() except Exception as ex: traceback.print_exc() |
#****************************************************************************** # # Copyright (c) 2020-2021 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #****************************************************************************** # # DownloadImage.py import sys import os import time import traceback import numpy as np import shutil def download_image_file(img_file): try: path = os.path.join(os.getcwd(), "images") os.makedirs(path, exist_ok=True) local_image_path = os.path.join(path, img_file) if os.path.exists(local_image_path) != True: url = 'https://user-images.githubusercontent.com/11736571/77320690-099af300-6d37-11ea-9d86-24f14dc2d540.png' print("Downloading a file {}".format(url)) img_file = tf.keras.utils.get_file(img_file, url) shutil.move(img_file, local_image_path) print("You have downloaded {}".format(local_image_path)) else: print("Found a downloaded file {}".format(local_image_path)) return local_image_path except Exception as ex: traceback.print_exc() if __name__=="__main__": try: img_file="img.png" download_image_file(img_file) except Exception as ex: traceback.print_exc() |
# ============================================================================== # Copyright 2020 Google Research. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # Copyright 2020-2021 antillia.com Toshiyuki Arai # 2021/09/22 atlan-antillia # EfficientDetObjectDetector.py r"""Tool to inspect a model.""" import os # |