안녕하세요 답변감사합니다 eval문제가 또발생한거같네요 WARNING:tensorflow:Detecting that an object or model or tf.train.Checkpoint is being deleted with unrestored values. See the following logs for the specific values in question. To silence these warnings, use status.expect_partial() . See https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint#restorefor details about the status object returned by the restore function. 이런 문제가 떠서 import numpy as np import skimage.io as io from keras.preprocessing.image import ImageDataGenerator from model import UNET_ISBI_2012 from absl import flags from absl import app import os flags.DEFINE_string('checkpoint_path', default='saved_model_isbi_2012/unet_model.ckpt', help='path to a directory to restore checkpoint file') flags.DEFINE_string('test_dir', default='isbi_2012_test_result', help='directory which test prediction result saved') flags.DEFINE_integer('num_classes', default=1, help='number of prediction classes') FLAGS = flags.FLAGS # set configuration value batch_size = 1 total_test_image_num = 30 # normalize ISBI-2012 data def normalize_isbi_2012(input_images): # 0~255 -> 0.0~1.0 input_images = input_images / 255 return input_images # make prediction mask def create_mask(pred_mask): pred_mask = np.where(pred_mask > 0.5, 1, 0) return pred_mask[0] # make test data generator def make_test_generator(batch_size): image_gen = ImageDataGenerator() # set image and mask same augmentation using same seed image_generator = image_gen.flow_from_directory( directory='./isbi_2012/preprocessed', classes=['test_imgs'], class_mode=None, target_size=(512, 512), batch_size=batch_size, color_mode='grayscale', seed=1 ) for batch_images in image_generator: batch_images = normalize_isbi_2012(batch_images) yield batch_images def main(_): # check if checkpoint path exists # if not os.path.exists(FLAGS.checkpoint_path): # print('checkpoint file is not exists!') # exit() # create UNET model unet_model = UNET_ISBI_2012(FLAGS.num_classes) # restore latest checkpoint status = unet_model.load_weights(FLAGS.checkpoint_path) status.expect_partial() # Ignore warnings about incomplete restoration print(f'{FLAGS.checkpoint_path} checkpoint is restored!') # make generator test_generator = make_test_generator(batch_size) # check total image num print('total test image :', total_test_image_num) # save test prediction result to png file if not os.path.exists(os.path.join(os.getcwd(), FLAGS.test_dir)): os.mkdir(os.path.join(os.getcwd(), FLAGS.test_dir)) for image_num, test_image in enumerate(test_generator): if image_num >= total_test_image_num: break pred_mask = unet_model.predict(test_image) # Ensure the mask has three channels output_image = create_mask(pred_mask) output_image = np.stack((output_image,) * 3, axis=-1) # Convert to uint8 output_image = (output_image * 255).astype(np.uint8) output_image_path = os.path.join(os.getcwd(), FLAGS.test_dir, f'{image_num}_result.png') io.imsave(output_image_path, output_image) print(output_image_path + ' saved!') if __name__ == '__main__': app.run (main) 이렇게바꿧더니 결과사진이 이상하게 나오네요 ㅠ 맨위에 직선같은게 사진 결과입니다
(위사진 저장된 save file) train부분 에러 train_isbi _2012.py:17 7 : UserWarning: Model.fit_generator is deprecated and will be removed in a future version. Please use Model.fit , which supports generators. 이거를 Model.fit로 바꿔야하나요? I tensorflow/core/platform/cpu_feature_ guard.cc:193 ] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX cpu로 돌아가고있는 뜻같은데 gpu를 따로쓰는방법이있나요? evaluate 부분 에러 Found 30 images belonging to 1 classes. 1/1 [==============================] - 1s 955ms/step evaluate_isbi_ 2012.py:85 : UserWarning: C:\Users\Administrator\Desktop\UNET-tf2-main\isbi_2012_test_result\0_result.png is a low contrast image io.imsave(output_image_path, create_mask(pred_mask)) Traceback (most recent call last): File "evaluate_isbi_ 2012.py ", line 89, in app.run (main) File "D:\anaconda\envs\tfunet\lib\site-packages\absl\ app.py ", line 308, in run run main(main, args) File "D:\anaconda\envs\tfunet\lib\site-packages\absl\ app.py ", line 254, in run main sys.exit(main(argv)) File "evaluate_isbi_ 2012.py ", line 85, in main io.imsave(output_image_path, create_mask(pred_mask)) File "D:\anaconda\envs\tfunet\lib\site-packages\skimage\io\_ io.py ", line 143, in imsave return call_plugin('imsave', fname, arr, plugin=plugin, **plugin_args) File "D:\anaconda\envs\tfunet\lib\site-packages\skimage\io\manage_ plugins.py ", line 207, in call_plugin return func(*args, **kwargs) File "D:\anaconda\envs\tfunet\lib\site-packages\imageio\ v2.py ", line 397, in imwrite return file.write(im, **kwargs) File "D:\anaconda\envs\tfunet\lib\site-packages\imageio\plugins\ pillow.py ", line 405, in write raise ValueError("Can't write images with one color channel.") ValueError: Can't write images with one color channel. WARNING:tensorflow:Detecting that an object or model or tf.train.Checkpoint is being deleted with unrestored values. See the following logs for the specific values in question. To silence these warnings, use status.expect_partial() . See https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint#restorefor details about the status object returned by the restore function. W0510 18:14:50.947670 15764 checkpoint.py:205 ] Detecting that an object or model or tf.train.Checkpoint is being deleted with unrestored values. See the following logs for the specific values in question. To silence these warnings, use status.expect_partial() . See https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint#restorefor details about the status object returned by the restore function. WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._iterations W0510 18:14:50.952654 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._iterations WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._learning_rate W0510 18:14:50.953642 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._learning_rate WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._variables.1 W0510 18:14:50.954640 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._variables.1 WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._variables.2 W0510 18:14:50.955644 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._variables.2 WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._variables.3 W0510 18:14:50.955644 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._variables.3 WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._variables.4 W0510 18:14:50.956632 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._variables.4 WARNING:tensorflow:Value in checkpoint could not be found in the restored object: (root).optimizer._variables.5 W0510 18:14:50.957636 15764 checkpoint.py:214 ] Value in checkpoint could not be found in the restored object: (root).optimizer._variables.5 (optimizer._variables.96까지 에러,글자수 제한 있어 이렇게 씁니다) 안녕하세요 말하신데로 train evaluate 다바꿔서 5장 저장다하고 ckpt 로 교체해서 evaluate_isbi_ 2012.py 실행하니 이런문제가 뜨네요.감사합니다