Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
paip
/
script
/
broiler_onoff
/
Or
Select Your Path :
Upload File :
New :
File
Dir
//paip/script/broiler_onoff/broiler_onoff.py
# Copyright (c) 2020~2023 PAIPTREE SmartFarm, Inc. All Rights Reserved. # Title : 닭 입출하 감지 # Author: 박정훈 # Date : 2023.03.24 import tensorflow as tf # from tensorflow import keras import pandas as pd import socket, warnings, os, sys, pymsteams, glob from datetime import date, datetime, timedelta if __name__ == '__main__': if len(sys.argv) <= 1 : print("fail - not input img_path") sys.exit() print("입추 확인 시작!!") img_path = sys.argv[1] print("Input img_path : ", img_path) try : # find model file windows_model_path = 'D:\\gate\\script\\broiler_onoff\\model\\' linux_model_path = '/gate/script/broiler_onoff/model/' model_path = windows_model_path if os.name == 'nt' else linux_model_path #print("model_path : ", model_path) model_file_list = glob.glob(model_path + '*') model_file_path = max(model_file_list, key=os.path.getmtime) #print("model_file_path : ", model_file_path) #수정/주석/삭제 금지 : gateway에서 이 구문을 통해 파일명 획득함 print("model_file_name:", os.path.basename(model_file_path)) # load model loaded_model = tf.keras.models.load_model(model_file_path) #print("load model") #img_path = '/gate/data/filesImageReal/20230324/H02_CT04,0_20230324122606_farm_image_real_a7741b014c3e.jpg' img = tf.keras.preprocessing.image.load_img(img_path, target_size=(540, 540)) img_array = tf.keras.preprocessing.image.img_to_array(img) img_array = tf.expand_dims(img_array, 0) prediction = loaded_model.predict(img_array) score = prediction[0] print("score:", score) if (score[0] < score[1]) and score[1] >= 3 : print("Yes broiler!\n") print(1) else: print("No broiler!\n") print(0) except : print("fail")