PDFBox - java.lang.UnsatisfiedLinkError: jpeg (Library is already loaded in another ClassLoader) - jpeg

I just integrated PDFBox into my project in order to generate image from a PDF page.
I made a unit test generating such image.
It works well in my dev environment.
However, when running the test in our gitlab, it is not able to load properly:
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1461)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1408)
at java.lang.System.loadLibrary(System.java:583)
at com.sun.imageio.plugins.jpeg.JPEGImageReader$1.run(JPEGImageReader.java:104)
at com.sun.imageio.plugins.jpeg.JPEGImageReader$1.run(JPEGImageReader.java:102)
at java.security.AccessController.doPrivileged(AccessController.java:678)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.<clinit>(JPEGImageReader.java:101)
at com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(JPEGImageReaderSpi.java:97)
at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:331)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:540)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:524)
at org.apache.pdfbox.filter.Filter.findImageReader(Filter.java:155)
at org.apache.pdfbox.filter.DCTFilter.decode(DCTFilter.java:58)
at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:80)
at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:179)
at org.apache.pdfbox.pdmodel.common.PDStream.createInputStream(PDStream.java:241)
at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.createInputStream(PDImageXObject.java:793)
at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:517)
at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:226)
at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:479)
at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:460)
at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1059)
at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:67)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:933)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:515)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:489)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:156)
at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:275)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:347)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:268)
at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:240)
Anyone got an idea ?
Thanks !

Related

Js-Report not display other language when deploy on lambda

I have use js-report to generate pdf with thai language
all of my process is
1.get csv file from s3
2.read data and convert csv to object
3.send object to jsreport
i already done all process in local and it's work fine .
but when i deploy this project on lambda (we can attach js report to lambda. more details in this url : jsreport-aws-lambda )
but when i deploy and test, it's not displaying thai language(and i think maybe other language too.)
at first i think it's becode encoding ('base64') i try to change it's to utf-8 but the file is corrupted.
I already set meta content of html file to
enter code here
but's still not working
what can i do to solved this, please help me.
Thanks.

How to add Metadata in the Tensorflow Lite for a model taken from Github?

I have used this project from Github: https://github.com/nicknochnack/TFODCourse
The project contains a model that can detect License Plate on a given Vehicle image. The Github repo also contains code for the conversion of model into Tensorflow Lite file.
I used that code to generate TFLite file.
And then, I followed this link: https://developers.google.com/codelabs/tflite-object-detection-android
Where I downloaded the sample Application of Object detection model and following the instructions, I copied my TFLite files into the Android Application.
Now, if I run the application and take a photo, it gives me this error,
/TaskJniUtils: Error getting native address of native library: task_vision_jni
java.lang.RuntimeException: Error occurred when initializing ObjectDetector: Input tensor has type kTfLiteFloat32: it requires specifying NormalizationOptions metadata to preprocess input images.
at org.tensorflow.lite.task.vision.detector.ObjectDetector
I understand that I have to add Metadata in my TFLite model. so, I searched about it and ended up on this link: https://www.tensorflow.org/lite/models/convert/metadata#model_with_metadata_format
But I didn't understand at all what exactly should I be doing. Can anyone please help me in pointing to the right direction that for my problem specifically, what exactly do I need to do?

opencv fisherface recognizer

I'm trying to load model files for a FisherFaceRecognizer. The initial problem is that the program was written for an older OpenCV version and it seems some interfaces were changed.
Info about my project:
programming language: Python 3.5
OpenCV Version: 3.3.0
These are the two lines were I had a problem with:
model = cv2.face.createFisherFaceRecognizer()
model.load('foo_model.xml')
In the OpenCV documentation I found out that there is a new way to call the create functions and it seems to work. But I could not find the right call for the load function. I have tried to use the read function of the recognizer, but that results in an error.
model = cv2.face.FisherFaceRecognizer_create()
model.read('foo_model.xml')
The error message I've got when I try to use read():
File can't be opened for reading! in function read
Does somebody can help me with loading the model files? Thank you :)
The problem is with the xml file format. if you open the XML file you will not find "my_object" tag. I will not go to the details of this but, every time I face this problem, it works when I modify the xml file as follows.
<?xml version="1.0"?>
<opencv_storage>
<my_object> //add this
.........
.........
.........
</my_object> //and this
</opencv_storage>
The problem seems to be that the xml format in which the models are saved had been changed. This seems to be a known issue. I am using OpenCV 3.3.0 and want to load a model from an older OpenCV version which results in the mentioned error from the read-function. In the OpenCV Q&A forum a solution was suggested to me, but in my case it did not work. Nonetheless I will drop the link to my post at OpenCV Q&A here. Maybe someone else with the same problem can benefit from it.

Analyze a tensorflow graph or a .pb file on Tensorboard

I have been following github repository for "Tensorflow on Android".
I was able to build the code using bazel and then import the Android project to Android Studio, as mentioned here.
As you can see here, after building the APK, using Android Studio, the Model files/Graphs are included in the tensorflow/examples/android/assets
By default, tensorflow_inception_graph.pb and imagenet_comp_graph_label_strings.txt are included, from inception5 file which is downloaded while the APK is built.
What's the issue?
I have a retrained graph (InceptionV3 model, mentioned in tensorflow/examples/image_retraining/retrain.py), which I was able to place in the assets folder in android directory and generate a working APK.
Inference time while I was using the default graph or .pb file was ~500ms and with my retrained.pb or graph it is ~1400ms.(tested on OnePlus3T device)
Please help me understand
How to analyze the default tensorflow_inception_graph.pb on Tensorboard
Last May they have introduced a helper script called import_pb_to_tensorboard to do just that.
usage: import_pb_to_tensorboard.py [-h] [--model_dir MODEL_DIR]
[--log_dir LOG_DIR]
optional arguments:
-h, --help show this help message and exit
--model_dir MODEL_DIR
The location of the protobuf ('pb') model to
visualize.
--log_dir LOG_DIR The location for the Tensorboard log to begin
visualization from.
Note that currently, the version in master seems to have received more love than the one present in the latest 1.2.1 distribution of tensorflow, so I would suggest to use this one.

CrfSharp file not found

when I try to run crfsharp, I get the following error at VS2012,
+err{"Could not find file 'C:\codeplex\POIParser\data\training\POIParser_corpus.train.tag'.":"C:\codeplex\POIParser\data\training\POIParser_corpus.train.tag"} System.Exception {System.IO.FileNotFoundException}
where can I find this file "POIParser_corpus.train.tag" ? I have downloaded both source code and main program of crfsharp and running it in VS2012.
Also I want to ask you can I use the CRFsharp to extract aspects by using training templates?
How do you run it ?
To train a CRF model, you need to prepare training corpus, template file at first and run CRFSharpConsole.exe with some parameters. CRFSharpConsole.exe will show usage, if you run it without any parameters.
Actually, I recommend you to download demo package from [DOWNLOADS] section in CRFSharp project web site(http://crfsharp.codeplex.com) at first, and then play with demo. In demo package, it will show you how to run CRFSharp in command line. For example, you can download Named entity recognized demo in English demo and run batch file to train a new model and test it.
For POIParser_corpus.train.tag you mentioned, it's the training corpus for Chinese POI inner-structure parser. You can also download it and run build_model.bat to train the model, and run test_model.bat to test it.

Resources