ImageHandwrittenDetector Error #393
Unanswered
matt-song27
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello JohnSnowLabs,
This is Matt. I would like to have a question about using ImageHandwrittenDetector()
of SparkOCR.
Please see the below for Environments, Code, and the Error.
Thank you!!
Environments
OS: Ubuntu 20.04.2 LTS WSL on Windows 10
Spark Version: 3.0.2
pyspark version: 3.0.2
Spark NLP Version: 3.2.2
Spark JSL Version: 3.2.2
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
Code
from pyspark.ml import PipelineModel
import pyspark.sql.functions as f
from sparkocr.transformers import *
from sparkocr.enums import *
from sparkocr.utils import display_images
imagePath = './data/ICF/ICF_Part3_Signed.jpg'
image_df = spark.read.format("binaryFile").load(imagePath)
display_images(BinaryToImage().transform(image_df), "image")
binary_to_image = BinaryToImage()
binary_to_image.setImageType(ImageType.TYPE_3BYTE_BGR)
pretrained_model = ("image_handwritten_detector_gsa0803", "en", "public/ocr/models")
handwritten_detector = ImageHandwrittenDetector()
.pretrained(*pretrained_model)
.setInputCol("image")
.setOutputCol("handwritten_regions")
.setScoreThreshold(0.4)
Error
ERROR:root:Exception while sending command.
Traceback (most recent call last):
File "/home/matt_song/anaconda3/envs/sparkocr/lib/python3.7/site-packages/py4j/java_gateway.py", line 1207, in send_command
raise Py4JNetworkError("Answer from Java side is empty")
py4j.protocol.Py4JNetworkError: Answer from Java side is empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/matt_song/anaconda3/envs/sparkocr/lib/python3.7/site-packages/py4j/java_gateway.py", line 1033, in send_command
response = connection.send_command(command)
File "/home/matt_song/anaconda3/envs/sparkocr/lib/python3.7/site-packages/py4j/java_gateway.py", line 1212, in send_command
"Error while receiving", e, proto.ERROR_ON_RECEIVE)
py4j.protocol.Py4JNetworkError: Error while receiving
Py4JError Traceback (most recent call last)
in
----> 1 handwritten_detector = ImageHandwrittenDetector()
2 .pretrained(*pretrained_model)
3 .setInputCol("image")
4 .setOutputCol("handwritten_regions")
5 .setScoreThreshold(0.4)
~/anaconda3/envs/sparkocr/lib/python3.7/site-packages/pyspark/init.py in wrapper(self, *args, **kwargs)
108 raise TypeError("Method %s forces keyword arguments." % func.name)
109 self._input_kwargs = kwargs
--> 110 return func(self, **kwargs)
111 return wrapper
112
~/anaconda3/envs/sparkocr/lib/python3.7/site-packages/sparkocr/transformers/image_handwritten_detector.py in init(self, classname, java_model)
81 if classname and not java_model:
82 self.class._java_class_name = classname
---> 83 self._java_obj = self._new_java_obj(classname, self.uid)
84 if java_model is not None:
85 self._transfer_params_from_java()
~/anaconda3/envs/sparkocr/lib/python3.7/site-packages/pyspark/ml/wrapper.py in _new_java_obj(java_class, *args)
65 java_obj = _jvm()
66 for name in java_class.split("."):
---> 67 java_obj = getattr(java_obj, name)
68 java_args = [_py2java(sc, arg) for arg in args]
69 return java_obj(*java_args)
~/anaconda3/envs/sparkocr/lib/python3.7/site-packages/py4j/java_gateway.py in getattr(self, name)
1642 answer[proto.CLASS_FQN_START:], self._gateway_client)
1643 else:
-> 1644 raise Py4JError("{0} does not exist in the JVM".format(new_fqn))
1645
1646
Py4JError: com.johnsnowlabs.ocr.transformers.ImageHandwrittenDetector does not exist in the JVM
Beta Was this translation helpful? Give feedback.
All reactions