print("this is testforpy.py file")

import os
import json
import ssl
import pandas as pd
import numpy as np
import cv2
import sys
ssl._create_default_https_context = ssl._create_unverified_context
from tensorflow import keras as K
import tensorflow as tf
import matplotlib.pyplot as plt
import traceback

# jsonfile=('./MLModel/efficientnetb3.json')
#
# f=open(jsonfile,'r')
# data=json.load(f)
# r=json.dumps(data)
# global kerasmodel
# kerasmodel=K.models.model_from_json(r)
#
#
# kernelinput=kerasmodel.input_shape
# print(kerasmodel)

imagefold='/Users/yanghu/Library/Containers/ZZLAB.AI4EVER/Data/Library/Exports/'
files=os.listdir(imagefold)
files=sorted(files)
imgfiles=[]
for f in files:
    if '.png' in f:
        imgfiles.append(f)
images=[]
for f in imgfiles:
    try:
        imgpath=os.path.join(imagefold,f)
        print(imgpath)
        image=cv2.imread(imgpath,cv2.COLOR_BGR2RGB)
        image=cv2.resize(image,(300,300),interpolation=cv2.INTER_NEAREST)
        image=np.array(image)
        image=image.astype("float32")
        image/=255
        images.append(image)
    except:
        print('cv2 error on ',f)
        print(traceback.format_exc())
        continue