I used the following command to create a .pb file:
flow --model ../YOLOv2/alexeyAB_darknet/darknet-master/cfg/yolov2-dppedestrian.cfg --load ../YOLOv2/alexeyAB_darknet/darknet-master/backup/yolov2-dppedestrian_33900.weights --savepb
Although the model was created successfully, when I load it into my java tensorflow application, I get the following error:
Exception in thread "Thread-9" org.tensorflow.TensorFlowException: Could not find meta graph def matching supplied tags: { serve }. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli
The problem is in the second line of code:
String model_path = "/home/adisys/Desktop/cloudiV2/models/yolo_pedestrian/saved_model";
SavedModelBundle model = SavedModelBundle.load(model_path, "serve");
I tried digging deep and found this link:
Can not load pb file in tensorflow serving
Following the link I ran the following command:
saved_model_cli show --dir saved_model/
The output is as follows:
/home/adisys/anaconda3/lib/python3.6/site-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters
The given SavedModel contains the following tag-sets:
As can be seen, there were no tag-sets displayed.
What could be the issue?
I just saw your post, I'm sure the problem has solved itself now, but I'm leaving the comment for others working with darkflow. The command --savepb needs to be assigned as --savepb True
Related
I am trying to load mobilenet model from this link. The model is stored on disk at the following path
C:\Users\userName\IdeaProjects\ImageClassification\src\main\resources\mobilenet_v2_1.4_224\mobilenet_v2_1.4_224.pb
Following is the code which is located at this path C:\Users\userName\IdeaProjects\ImageClassification\src\main\java\com\DeepLearning\ImgClassification.java
try(SavedModelBundle modelBundle = SavedModelBundle.load("src/main/resources/mobilenet_v2_1.4_224", "serve")){
Session mobileNetSession = modelBundle.session();
System.out.println(mobileNetSession);
}catch (TensorFlowException t){
System.out.println(t.getMessage());
}
I am trying to load the .pb using SavedModelBundle.load(), but I get the following error
2020-07-31 12:40:35.385591: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: src/main/resources/mobilenet_v2_1.4_224
2020-07-31 12:40:35.570627: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2020-07-31 12:40:35.577560: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: fail. Took 191903 microseconds.
Could not find meta graph def matching supplied tags: { serve }. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: `saved_model_cli`
How do I resolve the path of the model?
What am I mising here?
Thanks.
I am trying to import a h2o model as a .zip file exporter as POJO with R. The following error is all I get:
model_file <- "/Users/bernardo/Desktop/DRF_1_AutoML_20190816_133251.zip"
m <- h2o.importFile(model_file)
Error: DistributedException from localhost/127.0.0.1:54321: 'Cannot determine file type. for nfs://Users/bernardo/Desktop/DRF_1_AutoML_20190816_133251.zip', caused by water.parser.ParseDataset$H2OParseException: Cannot determine file type. for nfs://Users/bernardo/Desktop/DRF_1_AutoML_20190816_133251.zip
I already ran file.exists(model_file) and that returns TRUE, so the file exists. Did the same with normalizePath(model_file) and same result. When I try to import it into my R session, it seems that h2o finds the file but can't import it for some reason.
Here's my R Session info:
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] h2o_3.26.0.2 lares_4.7 data.table_1.12.2 lubridate_1.7.4 forcats_0.4.0
[6] stringr_1.4.0 dplyr_0.8.3 purrr_0.3.2 readr_1.3.1 tidyr_0.8.3
[11] tibble_2.1.3 ggplot2_3.2.1 tidyverse_1.2.1
Hope you guys can help me import my POJO model into R. Thanks!
h2o models are not zip files. Try this
# path to your file
model_file <- "/Users/bernardo/Desktop/DRF_1_AutoML_20190816_133251.zip"
# prediction based on your mojo/pojo file.
preds = h2o.mojo_predict_df(df, model_file, genmodel_jar_path = NULL, classpath = NULL, java_options = NULL, verbose = F)
If they are zipped, then unzip and run them again. More info is here http://docs.h2o.ai/h2o/latest-stable/h2o-docs/save-and-load-model.html
https://rdrr.io/cran/h2o/man/h2o.mojo_predict_df.html
Ok, I actually found the solution I needed. The trick is to convert your dataframe (df) to json format, and then use the .zip file generated with h2o to predict using the h2o.predict_json instead of h2o.mojo_predict_df. I think it's pretty straight forward and less complicated. At least it worked as I needed it to work.
library(jsonlite)
library(h2o)
json <- toJSON(df)
output <- h2o.predict_json(zip_directory, json)
NOTE: No need to unzip the zip file.
If by any chance you've used the lares package, simply use the h2o_predict_MOJO function.
Hope it helps any other people trying to achieve the same result.
I have angular2-node.js application. I am executing a jar file through the node server.
Jar execution is happening fine but it's using the logback.xml present in the jar file.
Node js code:
app.get('/report/:parameter1/:parameter2', function(req, res) {
var fileName = path.join(__dirname, '..', 'javaFile', 'xyz.jar');
spawn('/usr/bin/java', ['-jar ', fileName, parameter1 , parameter2, '&'],{
stdio : ['ignore', out, err],
detached : true }).unref();
data = '{response: Success}';
res.status(200).json(data);
res.end();
});
I want to refer the different logback.xml file for jar execution while running the jar from UI. So, i tried the below code:
spawn('/usr/bin/java', ['-jar -Dlogback.configurationFile=./logback.xml', fileName, cacheName , cacheType, '&'],{
stdio : ['ignore', out, err],
detached : true }).unref();
But, it also didn't work and throw the below error:
Unrecognized option: -jar -Dlogback.configurationFile=./logback.xml
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I am new to node js. I searched the web but couldn't get an answer.
Is there any way to provide the logback.xml file dynamically in node.js code something like we do in shell script like below:
nohup java -jar -Dlogback.configurationFile=./logback.xml xyz.jar
Can anyone provide any solution for this.
The args arguments is <string[]>, so you should split the multiple args into multiple elements of the array, like you've done for the other arguments. You can check the signature of the method here.
Try,
spawn('/usr/bin/java', ['-jar', '-Dlogback.configurationFile=./logback.xml'], ....
I am trying to run an implementation a jason code that is using some Internal Actions. The interpreter is showing that it was not possible to find the "java" code of the internal action, as showed:
Server running on http://191.36.8.42:3272
[aslparser] [peleus.asl:29] warning: The internal action class for 'org.soton.peleus.act.plan(Goals)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.plan
[aslparser] [peleus.asl:42] warning: The internal action class for 'org.soton.peleus.act.isTrue(H)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.isTrue
[peleus] Could not finish intention: intention 1: +des([on(b3,table),on(b2,b3),on(b1,b2)])[source(self)] <- ... org.soton.peleus.act.plan(Goals); !checkGoals(Goals); .print("Goals ",Goals," were satisfied") /
{Goals=[on(b3,table),on(b2,b3),on(b1,b2)]}Trigger: +des([on(b3,table),on(b2,b3),on(b1,b2)])[noenv,code(org.soton.peleus.act.plan([on(b3,table),on(b2,b3),on(b1,b2)])),code_line(29),code_src("peleus.asl"),error(action_failed),error_msg("no environment configured!"),source(self)]
[peleus] Adding belief clear(table)
This mas2j file is as following:
MAS peleus {
infrastructure: Centralised
agents:
peleus;
}
Part of agent code (written by Felipe Meneguzzi) is showed bellow:
//The next line is line 28
+des(Goals) : true
<- org.soton.peleus.act.plan(Goals);
!checkGoals(Goals);
.print("Goals ",Goals," were satisfied").
+!checkGoals([]) : true <- true.
//The next line is line 40
+!checkGoals([H|T]) : true
<- .print("Checking ", H);
org.soton.peleus.act.isTrue(H);
!checkGoals(T).
I guess it is about the folder structure, how to set up Jason to search for java files in specific locations?
The folders structure is like this:
Peleus\src\org\soton\peleus for java files
Peleus\examples for mas2j and asl tested project
It all depends on how you are executing the application.
If you are using java, the CLASSPATH should be defined to include the missing classes.
if you are using jason script (that uses Ant), the .mas2j file should include the class path as well.
More on that in the FAQ. Notice that CLASSPATH is where .class files are found, not .java source code files. The error regards a missing class, not a missing source code.
I am new to pig. I wrote a UDF in pig and used it in my pig script. But it gives following error
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve UserDefined.PartsOfSpeech using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]
Here is my UDF code
public String exec(Tuple input) throws IOException {
//my code here
}
Here is my pig script
REGISTER /home/bigdata/NetBeansProjects/UserDefined/dist/UserDefined.jar
a = load '/user/bigdata/json' using TextLoader() as (input:chararray);
b = foreach a GENERATE UserDefined.PartsOfSpeech(input);
In the above code UserDefined is my package name and PartsOfSpeech is my class name
The error message says that Pig cannot find UserDefined.PartsOfSpeech.
What package declaration does PartsOfSpeech.java have at the top of the file?
If the package declaration is package com.my.company; try this instead:
REGISTER /home/bigdata/NetBeansProjects/UserDefined/dist/UserDefined.jar
a = load '/user/bigdata/json' using TextLoader() as (input:chararray);
b = foreach a GENERATE com.my.company.PartsOfSpeech(input);
That is, replace UserDefined.PartsOfSpeech(input) with com.my.company.PartsOfSpeech(input) since the UDF is located in the package com.my.company.
Also, consider using the DEFINE keyword in your Pig script so you don't need to repeat com.my.company every time you use PartsOfSpeech.
DEFINE PartsOfSpeech UserDefined.dist.PartsOfSpeech();
REGISTER /home/bigdata/NetBeansProjects/UserDefined/dist/UserDefined.jar
a = load '/user/bigdata/json' using TextLoader() as (input:chararray);
b = foreach a GENERATE PartsOfSpeech(input);
There is more information about DEFINE in Chapter 5 of Alan Gates' Programming Pig: http://chimera.labs.oreilly.com/books/1234000001811/ch05.html#udf_define.
Here is an example of DEFINE from Gates' book:
--define.pig
register 'your_path_to_piggybank/piggybank.jar';
define reverse org.apache.pig.piggybank.evaluation.string.Reverse();
divs = load 'NYSE_dividends' as (exchange:chararray, symbol:chararray,
date:chararray, dividends:float);
backwards = foreach divs generate reverse(symbol);
Before compiling your UDF(java class) make sure you have mentioned package name properly. for example if you have mentioned package name-
package com.pig.udf;
It means you need to take care of directory in your linux box as well.
you can follow below mentioned steps to create jar -
Create directory using
mkdir -p com/pig/udf
Create your java class with package com.pig.udf
Compile your java source code using command
javac -cp /usr/lib/pig-0.12.0.2.0.6.0-76.jar YourClass.java
Then go to the directory where you want to create jar for now -
cd ../../..
Now create jar using below command
jar -cvf yourJarName.jar com/
Register the jar in your script using keyword "register" followed by path of the jar
Now use your jar with keyword com.pig.udf.YourJavaClassName
for your scenerio -
REGISTER /home/bigdata/NetBeansProjects/UserDefined/dist/UserDefined.jar
a = load '/user/bigdata/json' using TextLoader() as (input:chararray);
b = foreach a GENERATE com.pig.udf.PartsOfSpeech(input);