can you please convert python code into matlab code ?

# -*- coding: utf-8 -*- """ Created on Tue March 3 18:02:51 2022 @author: MRANAL """ from tensorflow.keras.models import load_model import cv2 import numpy as np best_model = load_model('modelsave.h5') pred_img = cv2.imread('./predicting/lungp_ben2.jpeg') pred_img = cv2.resize(pred_img, (80,80)) pred_img = pred_img/255; pred_img = np.asarray(pred_img).reshape((-1, 80, 80, 3)) ans = best_model.predict(pred_img) lis = ans.tolist() result = lis[0].index(max(lis[0])) if result==0: print("Benign tissue") elif result==1: print("Adenocarcinoma") else: print("Squamous cell carcinoma")

Respuestas (1)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou el 31 de Mayo de 2022
Save the TensorFlow model that you created in the SavedModel format, and then you can import the TensorFlow model into MATLAB by using the importTensorFlowNetworkNetwork function.
For an example on how to compare inference results between the TensorFlow model and the imported MATLAB network, see Inference Comparison Between TensorFlow and Imported Networks for Image Classification.

Categorías

Más información sobre Biotech and Pharmaceutical en Centro de ayuda y File Exchange.

Preguntada:

el 30 de Mayo de 2022

Respondida:

el 31 de Mayo de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by