-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: File not found: filepath=Backend\C4__256g_000040000.keras. Please ensure the file is an accessible .keras
zip file.
#20259
Comments
@sachinprasadhs answer please? |
Hi @ananthanarayanan431 - Can you provide the sample model file |
It is impossible to provide .keras file here. But I got the same issue within my code in Colab, the new keras version must have an issue: ValueError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/keras/src/saving/saving_api.py in load_model(filepath, custom_objects, compile, safe_mode) ValueError: File not found: filepath=mlp_1_regr.keras. Please ensure the file is an accessible |
@aur0ralight can you tell me the solution or |
Facing the same issue, didn't encounter it previously |
I even tried reducing the Keras version, but the code still doesn't work properly. |
Error:
Please ensure the file is an accessible '.keras' zip file
Keras Version: 3.5.0
tensorflow Version: 2.16.1
I don't have GPU please I need solution
Code:
import numpy as np
from keras.models import load_model
from keras.models import load_model
import matplotlib.pyplot as plt
from numpy import vstack
from tensorflow.keras.utils import img_to_array
from tensorflow.keras.preprocessing.image import load_img
from skimage.metrics import structural_similarity as ssim
from skimage.metrics import peak_signal_noise_ratio as psnr
from skimage.color import rgb2lab
import os
from tensorflow.keras.models import load_model
import tensorflow as tf
import keras
model_path = 'Backend\C4__256g_000040000.keras'
model = load_model(model_path)
model = keras.models.load_model(model_path,compile=False)
height, width = 256, 256
os.envrion['TF_ENABLE_ONEDNN_OPTS']='0'
print("Model input shape:", model.input_shape)
def plot_images(src_img, gen_img, tar_img=None):
if tar_img is not None:
images = [src_img, gen_img, tar_img]
titles = ['Source', 'Generated', 'Expected']
fig, axs = plt.subplots(1, 3, figsize=(15, 5))
else:
images = [src_img, gen_img]
titles = ['Source', 'Generated']
fig, axs = plt.subplots(1, 2, figsize=(10, 5))
def preprocess_data(data):
if isinstance(data, list):
X1, X2 = data
X1 = (X1 - 127.5) / 127.5
X2 = (X2 - 127.5) / 127.5
return [X1, X2]
else:
return (data - 127.5) / 127.5
def calculate_metrics(generated_image, target_image):
generated_image = (generated_image + 1) / 2.0
target_image = (target_image + 1) / 2.0
def process_images(src_path, tar_path):
src_image = load_img(src_path, target_size=(height, width), color_mode='rgb')
src_image = img_to_array(src_image)
src_image = np.expand_dims(src_image, axis=0)
def plot_histogram(image, ax, title):
colors = ('r', 'g', 'b')
for i, color in enumerate(colors):
hist, bins = np.histogram(image[:, :, i].flatten(), bins=256, range=[0, 1])
ax.plot(bins[:-1], hist, color=color, alpha=0.7)
ax.set_title(title)
ax.set_xlabel('Pixel Intensity')
ax.set_ylabel('Count')
def plot_difference_map(original, generated):
difference = np.abs(original - generated)
def colorize_image(image_file):
# Load the image
src_image = load_img(image_file, target_size=(height, width), color_mode='rgb')
src_image = img_to_array(src_image)
def plot_color_channels(image, title):
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
for i, channel in enumerate(['Red', 'Green', 'Blue']):
axes[i].imshow(image[:,:,i], cmap='gray')
axes[i].set_title(f'{channel} Channel')
axes[i].axis('off')
plt.suptitle(title)
return fig
def plot_lab_channels(image, title):
lab_image = rgb2lab(image)
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
channels = ['L (Lightness)', 'a (Green-Red)', 'b (Blue-Yellow)']
for i, channel in enumerate(channels):
im = axes[i].imshow(lab_image[:,:,i], cmap='gray')
axes[i].set_title(channel)
axes[i].axis('off')
plt.colorbar(im, ax=axes[i])
plt.suptitle(title)
return fig
Print model summary for debugging
model.summary()
all = ['process_images', 'plot_histogram', 'plot_difference_map', 'plot_color_channels', 'plot_lab_channels']
The text was updated successfully, but these errors were encountered: