zsylvester / segmenteverygrain

A SAM-based model for instance segmentation of images of grains

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: You are trying to restore a checkpoint from a legacy Keras optimizer into a v2.11+ Optimizer, which can cause errors.

catkinson2022 opened this issue · comments

I get the following error code while using code in google collab:

ValueError: You are trying to restore a checkpoint from a legacy Keras optimizer into a v2.11+ Optimizer, which can cause errors. Please update the optimizer referenced in your code to be an instance of tf.keras.optimizers.legacy.Optimizer, e.g.: tf.keras.optimizers.legacy.Adam.

Tried both instances with no solution to the problem.

The code used is shown below:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import cv2
from skimage import measure
from tensorflow.keras.optimizers.legacy import Adam
from tensorflow.keras.preprocessing.image import load_img
from importlib import reload
import segmenteverygrain as seg
from tqdm import trange

import tensorflow as tf
model = seg.Unet()
model.compile(optimizer= "Adam", loss=seg.weighted_crossentropy, metrics=["accuracy"])
model.load_weights('./checkpoints/seg_model')

The very last line "model.load_weights" is where the error is and not sure how to approach it.

I am facing same issue.

I am also getting this error and do not know how to solve it. If you figured out, can you please share with solution?

I am also getting this error and do not know how to solve it. If you figured out, can you please share with solution?

I guess this may be due to different versions of TensorFlow, but it seems that the author did not provide the TensorFlow version

Hi all, sorry for the slow response on this. I have uploaded an environment file that works for me on both Mac and Windows machines.