https://drive.google.com/drive/folders/1RdlCSJl6IwPfvVNwzX6PDbz1KCXHwysM?usp=sharing
def decode_image(filepath, label):
img = tf.io.read_file(filepath)
img = tf.image.decode_jpeg(img)
img = tf.image.resize(img, [224, 224])
img = tf.cast(img, tf.float32) / 255.0
return img, label
!pip install tensorflowjs
!tensorflowjs_converter \
--input_format=keras \
my_model.h5 \
drive/MyDrive/ML/my_tfjs_model_new
const modelUrl = "https://firebasestorage.googleapis.com/v0/....";
const model = await tf.loadLayersModel(modelUrl);
async function decodeBase64ToTensor(base64String) {
try {
const buffer = Buffer.from(base64String, 'base64');
const { data, info } = await sharp(buffer)
.resize(224, 224)
.raw()
.toBuffer({ resolveWithObject: true });
const { width, height, channels } = info;
if (width !== 224 || height !== 224 || channels !== 3) {
throw new Error('Image is not the correct size or number of channels.');
}
const imageTensor = tf.tensor3d(new Uint8Array(data), [height, width, channels]);
return imageTensor;
} catch (error) {
console.error("Error in decodeBase64ToTensor function:", error);
throw error;
}
}
function preprocessImage(imageTensor) {
try {
// Normalize the image tensor to have values in [0, 1] and add batch dimension
const normalizedTensor = imageTensor.div(tf.scalar(255.0)).expandDims(0);
return normalizedTensor;
} catch (error) {
console.error("Error in preprocessImage function:", error);
throw error;
}
}
async function predict(model, imageTensor) {
try {
// Perform prediction using the loaded model
const prediction = model.predict(imageTensor);
const predictionData = await prediction.data();
return predictionData;
} catch (error) {
console.error("Error in predict function:", error);
throw error;
}
}
Problem: New moles from the mobile app is very inaccurate, but images from the dataset uploaded trough the app is accurate
Proven wrong by:
- Creating a validation set with 20% of the full dataset
- Validation has 0.92 accuracy
Therfore this hypothesis is WRONG
2.) Hypothesis: Commonly expected images from the app differs significantly from the images in the dataset
Solution:
- Collecting each mole image carefully from ISIC ARCHIVE
with the following statment: "Could this picture be taken with a phone"