Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting an issue in predict request #1

Open
manaligaikwad opened this issue Jun 28, 2016 · 9 comments
Open

getting an issue in predict request #1

manaligaikwad opened this issue Jun 28, 2016 · 9 comments

Comments

@manaligaikwad
Copy link

manaligaikwad commented Jun 28, 2016

Stack trace -

com.deepdetect.api.exceptions.DeepDetectException:
at com.deepdetect.api.request.DeepDetectRequest.process(DeepDetectRequest.java:55)
at com.imageindexer.deepdetect.service.ImageClassificationService.predictImages(ImageClassificationService.java:47)
at com.imageindexer.deepdetect.service.ImageCategoryIndexer.jsonToTwitterObjectMap(ImageCategoryIndexer.java:158)
at com.imageindexer.deepdetect.service.ImageCategoryIndexer.indexTwitterImageCategories(ImageCategoryIndexer.java:84)
at com.imageindexer.deepdetect.service.DeepDetectIndexingService.categorizeImages(DeepDetectIndexingService.java:83)
at com.spark.imageindexer.api.controller.ElasticsearchController.lambda$1(ElasticsearchController.java:79)
at spark.SparkBase$1.handle(SparkBase.java:311)
at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:159)
at spark.webserver.JettyHandler.doHandle(JettyHandler.java:60)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:179)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:451)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:252)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:266)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.ws.rs.ProcessingException: java.net.ConnectException: Connection refused: connect
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:287)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:700)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:696)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)
at com.deepdetect.api.request.DeepDetectRequest.doPost(DeepDetectRequest.java:79)
at com.deepdetect.api.request.PredictRequest.internalProcess(PredictRequest.java:144)
at com.deepdetect.api.request.PredictRequest.internalProcess(PredictRequest.java:17)
at com.deepdetect.api.request.DeepDetectRequest.process(DeepDetectRequest.java:48)
... 18 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at org.glassfish.jersey.client.internal.HttpUrlConnector$4.getOutputStream(HttpUrlConnector.java:385)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)
at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:228)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:299)
at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
at sun.nio.cs.StreamEncoder.flush(Unknown Source)
at java.io.OutputStreamWriter.flush(Unknown Source)
at org.glassfish.jersey.message.internal.ReaderWriter.writeToAsString(ReaderWriter.java:193)
at org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider.writeToAsString(AbstractMessageReaderWriterProvider.java:130)
at org.glassfish.jersey.message.internal.StringMessageProvider.writeTo(StringMessageProvider.java:99)
at org.glassfish.jersey.message.internal.StringMessageProvider.writeTo(StringMessageProvider.java:59)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:517)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:499)
at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:388)
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
... 31 more


config.properties file

Properties for image prediction

baseURLHost = http://localhost:8888
serviceName = imageserv
inputParameters = {"width":224,"height":224}
outputParameters = {"best":5}
mlibParameters = {"gpu":false}

I am using above values for my predict request in following method -

public PredictResponse predictImages(String baseURLHost, String serviceName, String imageURL, String inputParameters, String outputParameters, String mlibParameters) {
PredictResponse response = null;
try {
response = PredictRequest.newPredictRequest() //
.baseURL(baseURLHost) //
.service(serviceName) //
.data(imageURL) //
.input(inputParameters)
.output(outputParameters)
.mllibParams(mlibParameters)
.build().process();

        System.out.println(response);
        System.out.println("\npredictions");
        for (int i = 0; i < response.getBody().getPredictions().size(); i++) {
            PredictionValue predictionValue = response.getBody().getPredictions().get(i);
            // System.out.println(" * " + words[i]);
            for (PredictionClass predictionClass : predictionValue.getClasses()) {
                System.out
                        .println("\t- " + predictionClass.getCategory() + " : " + predictionClass.getProbability());
            }
        }
    } catch (DeepDetectException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return response;
}

getting exception in doPost() method of DeepDetectRequest.java.

I have created service - imageserv in deepdetect and my deepdetect is running on port 8888

@kfadhel
Copy link
Owner

kfadhel commented Jun 28, 2016

Can you please check that your server is running and reachable?
From the stack trace:

Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
...

@manaligaikwad
Copy link
Author

manaligaikwad commented Jun 28, 2016

I checked for that before posting issue.. deepdetect server is running properly
2016-06-28

DeepDetect is running on a Docker

@kfadhel
Copy link
Owner

kfadhel commented Jun 28, 2016

try using 192.168.99.100:8888
as even in your console:
curl: (7) Failed to connect to localhost port 8888: Connection refused

@manaligaikwad
Copy link
Author

tried that before posting this issue.. it was not working so I tried with localhost. But either of them is not working

@manaligaikwad
Copy link
Author

manaligaikwad commented Jun 28, 2016

after using 192.168.99.100:8888, stack trace is different:
I think I am doing something wrong at the time of predict request creation.

com.deepdetect.api.exceptions.DeepDetectException:
at com.deepdetect.api.request.DeepDetectRequest.process(DeepDetectRequest.java:55)
at com.imageindexer.deepdetect.service.ImageClassificationService.predictImages(ImageClassificationService.java:47)
at com.imageindexer.deepdetect.service.ImageCategoryIndexer.jsonToTwitterObjectMap(ImageCategoryIndexer.java:158)
at com.imageindexer.deepdetect.service.ImageCategoryIndexer.indexTwitterImageCategories(ImageCategoryIndexer.java:84)
at com.imageindexer.deepdetect.service.DeepDetectIndexingService.categorizeImages(DeepDetectIndexingService.java:83)
at com.spark.imageindexer.api.controller.ElasticsearchController.lambda$1(ElasticsearchController.java:79)
at spark.SparkBase$1.handle(SparkBase.java:311)
at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:159)
at spark.webserver.JettyHandler.doHandle(JettyHandler.java:60)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:179)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:451)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:252)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:266)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.ws.rs.BadRequestException: HTTP 400 Bad Request
at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:999)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:816)
at org.glassfish.jersey.client.JerseyInvocation.access$700(JerseyInvocation.java:92)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:700)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:696)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)
at com.deepdetect.api.request.DeepDetectRequest.doPost(DeepDetectRequest.java:79)
at com.deepdetect.api.request.PredictRequest.internalProcess(PredictRequest.java:144)
at com.deepdetect.api.request.PredictRequest.internalProcess(PredictRequest.java:17)
at com.deepdetect.api.request.DeepDetectRequest.process(DeepDetectRequest.java:48)
... 18 more

@kfadhel
Copy link
Owner

kfadhel commented Jun 28, 2016

this means Bad Request – Malformed syntax in request or JSON body
can you display *Parameters passed to the method before calling the predict server?
I am working on an other issue to use objects instead of strings as requests parameters

@manaligaikwad
Copy link
Author

manaligaikwad commented Jun 28, 2016

these are the parameters I am passing to a method before calling predict :
baseURLHost = http://192.168.99.100:8888
serviceName = imageserv
inputParameters = {"width":224,"height":224}
outputParameters = {"best":5}
mlibParameters = {"gpu":false}
imageURL = https://www.google.ca/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwj_r7-B98vNAhVL5GMKHToHDBAQjRwIBw&url=https%3A%2F%2Fdavechampionsliberty.com%2F2015%2F09%2Ffact-there-is-no-war-on-police%2F&psig=AFQjCNFzfZ_mHNtPqBabXHTbl54nKr0_9g&ust=1467244811402590

These are all string values I am reading them from a property file.

This is the Entity object getting created for above data -

Entity{entity={"service":"imageserv","parameters":{"input":{"width":224,"height":224},"output":{"best":5},"mllib":{"gpu":false}},"data":["https://www.google.ca/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwj_r7-B98vNAhVL5GMKHToHDBAQjRwIBw&url=https%3A%2F%2Fdavechampionsliberty.com%2F2015%2F09%2Ffact-there-is-no-war-on-police%2F&psig=AFQjCNFzfZ_mHNtPqBabXHTbl54nKr0_9g&ust=1467244811402590"]}, variant=Variant[mediaType=application/json, language=null, encoding=null], annotations=[]}

@manaligaikwad
Copy link
Author

My issue is resolved... URL I was using was invalid. I tried with different image URL and it worked.
Thank you.

@kfadhel
Copy link
Owner

kfadhel commented Jun 29, 2016

I need to make the error message clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants