i am getting an error on using tf.frompixels recently which i wasnt getting before. below is the code i am using - tensorflow

function preprocessImage(img) {
const tensor = tf.fromPixels(img)
.resizeNearestNeighbor([224, 224]);
const croppedTensor = cropImage(tensor);
const batchedTensor = croppedTensor.expandDims(0);
return batchedTensor.toFloat().div(tf.scalar(127)).sub(tf.scalar(1));
}
the error i am getting is that tf.fromPixels is not a function . i wasnt getting this error as of two weeks back but i am suddenly getting this error on running the same code.

It looks like tf.fromPixels() has been removed and its function taken over by tf.browser.fromPixels().
Source

Related

Cannot read property 'getDataRange' of null [duplicate]

This question already has an answer here:
How to fix 'TypeError: Cannot call method "getRange" of null' in Google Apps Script
(1 answer)
Closed last year.
Im very new working with google script and APIs and Im trying to run a piece of code that makes the sheet in to a Json however I`m facing an issue where it says:
TypeError: Cannot read property 'getDataRange' of null
json # Code.gs:4
The code I`m using is the following:
function json() {
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet()
const sheet = spreadsheet.getSheetByName("APItest")
const data = sheet.getDataRange().getValues()
const jsonData = convertToJson(data)
return ContentService
.createTextOutput(JSON.stringify(jsonData))
.setMimeType(ContentService.MimeType.JSON)
}
I already tried to change the getSheetID but also didn`t work
Probably you're getting null value after the execution of
const sheet = spreadsheet.getSheetByName("APItest")
And That's why you get the error in the next statement. make sure that the sheet is not null.

Issue with getting data from an array of objects - vue.js / API / axios / proxy

First of all I'm using Vue.js to access data of an API using axios and a proxy
I'm trying to access the property of an object nested in the last array of several other arrays but I'm kinda hitting a wall, here's the detail :
Global details
the property I'm trying to access
I've tried different ways but here's my latest try :
axios
.get(proxyurl + history_url, {
reqHeaders
})
.then((reponse) => {
console.log(reponse.data)
this.lastItem = reponse.data.data.history[history.length-1]
console.log(this.lastItem)
this.lastEvol = this.lastItem.price
console.log(this.lastEvol)
})
The issue here is that the answer to "console.log(this.lastItem)" is :
lastItem answer
The value of the properties are now different and incorrect.
Since it's showing "Proxy" as the root object name I thought that may be the issue but I'm not sure.
I've tried several other ways to access this property but only had errors.
Any help would be greatly appreciated.
history is undefined in the history.length expression. Try this:
.then((reponse) => {
const history = reponse.data.data.history;
console.log(reponse.data)
this.lastItem = history[history.length-1]
console.log(this.lastItem)
this.lastEvol = this.lastItem.price
console.log(this.lastEvol)
})

lodash.fp.convert.words not working as expected

Am I using lodash.fp's convert method incorrectly? It seems like it doesn't work in the case of words
const fp = require('lodash/fp')
const assert = require('assert')
const words = fp.words.convert({ cap: false })
assert.equal(typeof words, 'function') // true as expected
// here I'd expect `words` to return a function that is expecting the
// remaining string argument
const splitByX = words(/[^x]+/g)
assert.equal(typeof splitByX, 'function')
published the above snippet here: https://runkit.com/lokua/lodash-fp-words-bug
I've also tried using fixed: false in the call to convert but get the exact same results.
This appears to be a bug to me, but I thought it better to post on StackOverflow before submitting a report in case my understanding of how convert works is off.
Here is a link to related issue asking how fp.words works, the answer was to use convert: https://github.com/lodash/lodash/issues/3397
using lodash#4.17.4

Cannot read property 'backgroundColor' of undefined

When the function call below gets run it returns this error.
"Uncaught TypeError: Cannot read property 'backgroundColor' of
undefined" I am trying to change the background color of a class called
.jumbotron. I have tried everything I can thing of so far.
Could anyone tell me why this is happening?
clrElementJumbo("cornsilk");
function clrElementJumbo(scolor) {
var el = document.getElementsByClassName("jumbotron");
el.style.backgroundColor = scolor;
}
Try to replace the code
var el = document.getElementsByClassName("jumbotron");
with the following
var el=document.getElementsByClassName("jumbotron")[0];

reset() function called on fine uploader object is not working

I wonder what is the proper way to reset FineUploaders uploader to its initial state?
$('#uploader').fineUploader('reset')
This results in "Uncaught TypeError: Cannot call method 'reset' of undefined " in definition of reset function
reset: function() {
this.log("Resetting uploader...");
this._handler.reset();
this._filesInProgress = [];
this._storedIds = [];
this._autoRetries = [];
this._retryTimeouts = [];
this._preventRetries = [];
this._button.reset();
this._paramsStore.reset();
this._endpointStore.reset();
--> this._pasteHandler.reset(); <--
this._netFilesUploadedOrQueued = 0;
},
So it seems that _pasteHandler was not created. Am I missing something in my configuration or is this bug in the uploader itself (which I seriously doubt as I wasn't able to found anyone else with similar issue)
As this is my first encounter with Fine Uploader any advice will be highly appreciated .
Thanks
This DOES appear to be a bug in Fine Uploader 3.4 (released yesterday). It will affect anyone attempting to reset the Fine Uploader instance without the paste to upload feature enabled. Can you please open up a bug report in the Github project's issue tracker so it can be tracked? I'll try to fix this today.
Update: Fixed in 3.4.1.