sassoftware / python-dlpy

The SAS Deep Learning Python (DLPy) package provides the high-level Python APIs to deep learning methods in SAS Visual Data Mining and Machine Learning. It allows users to build deep learning models using friendly Keras-like APIs.
Apache License 2.0
224 stars 131 forks source link

Getting Error When Running Trained MobileNet Model Keras File In SAS Viya 4 #406

Closed ojuschugh1 closed 1 month ago

ojuschugh1 commented 1 month ago

Hi Team,

Greetings for the day, I hope you are doing well.

I am trying to run my custom model .keras file in SAS Viya 4 but I am getting error - TypeError: load_weights() missing 1 required positional argument: 'path'

Even though I have specified the proper path of the model that I have uploaded to a directory where there is not restriction to read or access.

This is few part of my python code, that I am to load the model-:

import os
import time
import tensorflow as tf
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2, preprocess_input, decode_predictions
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import dlpy
from dlpy import Model

# Directory containing test images
test_images_directory = '/create-export/create/homes/Ojus.Chugh@sas.com/Test/Input_Data_Sample'  # Replace with the path to your test images directory

# Get a list of all image files in the directory
image_files = [os.path.join(test_images_directory, fname) for fname in os.listdir(test_images_directory) if fname.endswith(('.png', '.jpg', '.jpeg'))]

# Load the pre-trained model
model_path = "/create-export/create/homes/Ojus.Chugh@sas.com/Test/best_model.keras"
#model = tf.keras.models.load_model(model_path)

model=Model.load_weights(model_path, labels=False, data_spec=None, label_file_name=None, label_length=None, use_gpu=False, embedding_dim=None)
ojuschugh1 commented 1 month ago

I figured out the issue, No need for Dlpy to run python in SAS Viya 4, you can directly run it.

Thanks and Regards