can you please convert python code into matlab code ?

12 ビュー (過去 30 日間)
Muskan  Joshi
Muskan Joshi 2022 年 5 月 30 日
回答済み: Sivylla Paraskevopoulou 2022 年 5 月 31 日
# -*- 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")

回答 (1 件)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou 2022 年 5 月 31 日
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.

カテゴリ

Help Center および File ExchangeBiotech and Pharmaceutical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by