Caffe Issue : *** self._open(**self.request.kwargs.copy()) TypeError: _open() got an unexpected keyword argument 'as_grey'*** - caffe

for j,y in enumerate(sorted(glob.glob('images/*'))):
z=net.predict([caffe.io.load_image(y)*255.0])[0]
While the following code on Python3, I am getting this output
* self._open(**self.request.kwargs.copy()) TypeError: _open() got an unexpected keyword argument 'as_grey'*

I figured out the issue actually.
In caffe/python/caffe/io.py line 302
img = skimage.img_as_float(skimage.io.imread(filename, as_grey=not
color)).astype(np.float32)
I changed it to
img = skimage.img_as_float(skimage.io.imread(filename)).astype(np.float32)

Related

Parsing with JSON.parse() returns the wrong unexpected token

When writing JSON.parse("hi") getting the following error:
Uncaught SyntaxError: Unexpected token 'h', "hi" is not valid JSON
When writing JSON.parse("foo") getting the following error:
Uncaught SyntaxError: Unexpected token 'o', "foo" is not valid JSON
Why is f letter ignored?
JSON.parse("false") is acceptable, so it's reading the "f" as a potential start of the "false" string, but failing when the next character isn't "a".

Invalid JSON Expression

I am making use of non-static import
JsonPath jp = response.jsonPath();
System.out.println(jp.get("data?(#.id>14).employee_name").toString());
For a JSON as shown below:
{"status":"success","data":[{"id":"1","employee_name":"Tiger Nixon","employee_salary":"320800","employee_age":"61","profile_image":""},{"id":"2","employee_name":"Garrett Winters","employee_salary":"170750","employee_age":"63","profile_image":""}]}
When i am trying to run it , i am getting below error:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: expecting EOF, found '[' # line 1, column 31.
data[?(#.id>14)].employee_name
^
1 error
Can someone guide me why is this error being thrown ?
I doubt if that syntax is right, nonetheless, you should be using the below
Also note that the id is a string in your response so you will have to include it in quotes
js.get("data.find {it.id > '14'}.employee_name").toString();

Error in fromJSON(commandArgs(1)) : unexpected character '''

I am calling a R script from Scala by using scala.sys.process. This script takes a command line argument in JSON format and processes it. I am using rjson's fromJSON function to store the JSON in a list.
This works very fine when I execute the R script from the command line:
$ ./dfChargerFlink.R '{"Id":"1","value":"ABC"}'
But when I call it from scala, I get the following error:
Error in fromJSON(commandArgs(1)) : unexpected character '''
Execution halted
This is the code I am using:
val shellCommand = "./dfChargerFlink.R '"+arg+"'"
return shellCommand !!
where arg is the JSON string.
You can notice that I have appended " ' " to both the sides of the JSON string as if I don't, I get this error:
Error in fromJSON(commandArgs(1)) : unclosed string
Execution halted
How can this be solved? Is it some bug?

Error in fromJSON(paste(raw.data, collapse = "")) : unclosed string

I am using the R package rjson to download weather data from Wunderground.com. Often I leave the program to run and there are no problems, with the data being collected fine. However, often the program stops running and I get the following error message:
Error in fromJSON(paste(raw.data, collapse = "")) : unclosed string
In addition: Warning message:
In readLines(conn, n = -1L, ok = TRUE) :
incomplete final line found on 'http://api.wunderground.com/api/[my_API_code]/history_20121214pws:1/q/pws:IBIRMING7.json'
Does anyone know what this means, and how I can avoid it since it stops my program from collecting data as I would like?
Many thanks,
Ben
I can recreate your error message using the rjson package.
Here's an example that works.
rjson::fromJSON('{"x":"a string"}')
# $x
# [1] "a string"
If we omit a double quote from the value of x, then we get the error message.
rjson::fromJSON('{"x":"a string}')
# Error in rjson::fromJSON("{\"x\":\"a string}") : unclosed string
The RJSONIO package behaves slightly differently. Rather than throwing an error, it silently returns a NULL value.
RJSONIO::fromJSON('{"x":"a string}')
# $x
# NULL

Tumblr Oauth returning 401 on API v2

I'm trying to set up an automatic tumblr post every time I add something new to my website. I'm using the following code:
$conskey = "APIKEY";
$conssec = "APISECRET";
$tumblr_blog = "blogname.tumblr.com";
$to_be_posted = "This is the text to be posted";
$oauth = new OAuth($conskey,$conssec);
$oauth->fetch("http://api.tumblr.com/v2/blog/".$tumblr_blog."/post", array('type'=>'text', 'body'=>$to_be_posted), OAUTH_HTTP_METHOD_POST);
$result = json_decode($oauth->getLastResponse());
if($result->meta->status == 200){
echo 'Success!';
}
As far as I can tell this is all formatted correctly. However this is the first time I've tried to connect up to a JSON API using Oauth so I'm not totally confident in what I'm doing.
This is the exact error I'm receiving:
Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)' in /home/public_html/edge/tumblr.php:35 Stack trace: #0 /home/public_html/edge/tumblr.php(35): OAuth->fetch('http://api.tumb...', Array, 'POST') #1 /home/public_html/edge/index.php(95): include('/home/...') #2 {main} thrown in /home/public_html/edge/tumblr.php on line 35
Line 35 is the line beginning with $oauth->fetch.
Thanks for any help :-)
EDIT
I've solved the issue by substituting my previous code with the example on this page