Error in model exportation

Hi everyone, I built a model using the wildfire tutorial dataset and I tried to export it in a Jupyter Notebook format, but the platform always shows this message:


And it does not notifcate neither in the prompt nor perceptilabs why it cannot be exported :confused:
pd: It does export tensorflow format, but not jupyter notebook format.

Hi @CamiloRR,
Welcome to the forum!

Sorry for the confusion here, the Jupyter Notebook export is temporarily disabled but the frontend element is still there. We will remove the choice of it with the next update so there are no more confusions on it.

May I ask if there was anything specific you wanted to accomplish with the Jupyter after exporting it? :slight_smile:

All the best,
Robert

Thanks for your answer!!!
I’m looking to use the model with other images, but for classification, not for trainin. I just want to compare with my code, I´m learning all of this stuff by my own.

Ah cool!
Here is a small script that runs the model after you export it as a TensorFlow model (without any compression settings):

import tensorflow as tf
import os
from PIL import Image
import numpy as np
from tensorflow import keras

mapping = {0: "Normal", 1: "Defect"}
path_to_model = "Pills_model"

def load_image(path):
    image = Image.open(path)
    image = np.array(image, dtype=np.float32)
    image = np.expand_dims(image, axis=0)
    return image

#Load some images
defected = load_image("C:/Users/Robert/Documents/PerceptiLabs/Default/pills/defect/pic.6.571.0.png")
normal = load_image("C:/Users/Robert/Documents/PerceptiLabs/Default/pills/normal/pic.6.443.0.png")

#Loads the model
model = keras.models.load_model(path_to_model)

#Makes some predictions and catogirizes them
prediction1 = model(defected)
print(prediction1)
print(mapping[np.asarray(prediction1['labels']).argmax()])
prediction2 = model(normal)
print(prediction2)
print(mapping[np.asarray(prediction2['labels']).argmax()])

As for understanding the code, the best way right now is to press the Open Code button above the settings and taking a look in there. Everything you see in there is being ran when you start training.

Here is also a quick Docs guide on how we use TensorFlow: https://docs.perceptilabs.com/perceptilabs/references/fundamentals/how-perceptilabs-works-with-tensorflow

Hope that helps :slight_smile:

1 Like

Hi @robertl, Thank you for giving me the script example to read and use the tensorflow model.
But I’m having some issues with it, it shows this error:
OSError: SavedModel file does not exist at: saved_model.pb{saved_model.pbtxt|saved_model.pb}
Do you know what would it be?
Again, thank you for your time and help!

Hmm, that sounds like you don’t point to the correct folder, in my case the folder structure looks like this:
image

Where the Pills_model folder contains the exported model from PerceptiLabs, looking like this:
image

Strangely I encountered almost the same challenge when trying to load @Birdstream’s model before I realised that even though the .pb model was in the model directory alongside the *.py (so apparently satisfying

model = tf.keras.models.load_model('./model/')

It turned out that I was probably missing an import (?io) - at least restarting the kernel after updates had been done resolved that issue.

On the other hand, is it a missing “/” on path_to_model (which was exactly: path_to_model = “Pills_model”) (just asking; I hate path specs and often get them wrong)