Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/mobilenet_v2/mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_224.h5
14536120/14536120 ━━━━━━━━━━━━━━━━━━━━ 0s 0us/step
Modelo carregado com sucesso!
01.jpg(image/jpeg) - 303223 bytes, last modified: 12/08/2012 - 100% done
(function(scope) {
function span(text, styleAttributes = {}) {
const element = document.createElement('span');
element.textContent = text;
for (const key of Object.keys(styleAttributes)) {
element.style[key] = styleAttributes[key];
}
return element;
}
// Max number of bytes which will be uploaded at a time.
const MAX_PAYLOAD_SIZE = 100 * 1024;
function _uploadFiles(inputId, outputId) {
const steps = uploadFilesStep(inputId, outputId);
const outputElement = document.getElementById(outputId);
// Cache steps on the outputElement to make it available for the next call
// to uploadFilesContinue from Python.
outputElement.steps = steps;
return _uploadFilesContinue(outputId);
}
function _uploadFilesContinue(outputId) {
const outputElement = document.getElementById(outputId);
const steps = outputElement.steps;
const next = steps.next(outputElement.lastPromiseValue);
return Promise.resolve(next.value.promise).then((value) => {
// Cache the last promise value to make it available to the next
// step of the generator.
outputElement.lastPromiseValue = value;
return next.value.response;
});
}
function* uploadFilesStep(inputId, outputId) {
const inputElement = document.getElementById(inputId);
inputElement.disabled = false;
const outputElement = document.getElementById(outputId);
outputElement.innerHTML = '';
const pickedPromise = new Promise((resolve) => {
inputElement.addEventListener('change', (e) => {
resolve(e.target.files);
});
});
const cancel = document.createElement('button');
inputElement.parentElement.appendChild(cancel);
cancel.textContent = 'Cancel upload';
const cancelPromise = new Promise((resolve) => {
cancel.onclick = () => {
resolve(null);
};
});
// Wait for the user to pick the files.
const files = yield {
promise: Promise.race([pickedPromise, cancelPromise]),
response: {
action: 'starting',
}
};
cancel.remove();
// Disable the input element since further picks are not allowed.
inputElement.disabled = true;
if (!files) {
return {
response: {
action: 'complete',
}
};
}
for (const file of files) {
const li = document.createElement('li');
li.append(span(file.name, {fontWeight: 'bold'}));
li.append(span(
(${file.type || 'n/a'}) - ${file.size} bytes, +
last modified: ${ file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() : 'n/a'} - ));
const percent = span('0% done');
li.appendChild(percent);
outputElement.appendChild(li);
const fileDataPromise = new Promise((resolve) => {
const reader = new FileReader();
reader.onload = (e) => {
resolve(e.target.result);
};
reader.readAsArrayBuffer(file);
});
// Wait for the data to be ready.
let fileData = yield {
promise: fileDataPromise,
response: {
action: 'continue',
}
};
// Use a chunked sending to avoid message size limits. See b/62115660.
let position = 0;
do {
const length = Math.min(fileData.byteLength - position, MAX_PAYLOAD_SIZE);
const chunk = new Uint8Array(fileData, position, length);
position += length;
const base64 = btoa(String.fromCharCode.apply(null, chunk));
yield {
response: {
action: 'append',
file: file.name,
data: base64,
},
};
let percentDone = fileData.byteLength === 0 ?
100 :
Math.round((position / fileData.byteLength) * 100);
percent.textContent = `${percentDone}% done`;
} while (position < fileData.byteLength);
}
// All done.
yield {
response: {
action: 'complete',
}
};
}
scope.google = scope.google || {};
scope.google.colab = scope.google.colab || {};
scope.google.colab._files = {
_uploadFiles,
_uploadFilesContinue,
};
})(self);
Saving 01.jpg to 01.jpg
1/1 ━━━━━━━━━━━━━━━━━━━━ 1s 1s/step
Downloading data from https://storage.googleapis.com/download.tensorflow.org/data/imagenet_class_index.json
35363/35363 ━━━━━━━━━━━━━━━━━━━━ 0s 0us/step
Top 3 previsões:
- Classe: sunscreen - Confiança: 18.61%
- Classe: Band_Aid - Confiança: 6.12%
- Classe: jersey - Confiança: 3.24%
Classe identificada: sunscreen