2
$\begingroup$

over the last few weeks I routinely deployed neural nets to the cloud for computation. Today, even the simplest example does not work anymore:

(*initialise random neural net that talkes 200x200 image as input*)
scrnet = NetInitialize@
  NetChain[{ConvolutionLayer[1, 1], PartLayer[1]}, 
   "Input" -> {1, 200, 200}]

(*Deploy to cloud*)
cnet = CloudExport[scrnet, "MX", Permissions -> "Public"];

(*test on example image *WORKS**)
img = Import["ExampleData/ocelot.jpg"];
With[{net = CloudImport@cnet}, Image@net@{ImageData@img}]

(*Deploy as cloud form page *)
CloudDeploy[
 FormPage[{"image" -> "Image"}, 
  With[{net = CloudImport@cnet}, Image@net@{ImageData@#image}] &], 
 Permissions -> "Public"]

The last piece of code generates a cloud object. If I try to upload the ocelot image I get Image[Failed] as the sole output. If I do not use a net the form works fine:

CloudDeploy[FormPage[{"image" -> "Image"}, Image@ImageData@#image &], 
   Permissions -> "Public"]

Should I contact wolfram support or am I doing something wrong? I have ~1000 cloud credits left on a free account so that should not be the issue.

EDIT: Could it be related to my licence? I am on the free plan for the development platform which claims that "some" functions are restricted.

Best, Max

$\endgroup$
7
  • $\begingroup$ Huh. I'm not aware of any issue like this. A simple non-image Netchain works fine. ``` scrnet = NetInitialize@NetChain[{ElementwiseLayer[Ramp]}]; cnet = CloudExport[scrnet, "MX", Permissions -> "Public"]; FormPage["nums" -> DelimitedSequence["Real"], With[{net = CloudImport@cnet}, {net@#nums, #nums} &]] ``` when you supply it with input like "1,0,2" $\endgroup$ Commented Jul 13, 2018 at 20:05
  • $\begingroup$ Also, this NetChain seems to work fine in a notebook on Mathematica Online, so it's probably not some kind of strange compatibility issue. You've got me stumped. I guess I should try to capture what errors are happening $\endgroup$ Commented Jul 13, 2018 at 20:12
  • $\begingroup$ You mean you can ClodDeploy[] the conv net from mathematica online but not from the desktop version? $\endgroup$ Commented Jul 16, 2018 at 6:43
  • $\begingroup$ No. The Netchain works both in Desktop Mathematica and in a notebook on Mathematica Online. So it's pretty mysterious to me why it's returning $Failed. I'm asking around and filing a bug report, but you might want to report this Wolfram Tech Support so you can get a ticket number etc. $\endgroup$ Commented Jul 16, 2018 at 20:44
  • $\begingroup$ How do I reach tech support? I was just told by support to post the problem to the community while I don't see how that would help now. $\endgroup$ Commented Jul 17, 2018 at 12:58

1 Answer 1

0
$\begingroup$

it seems as if ImageData is used differently on my desktop compared to the cloud. The following alteration works:

scrnet = NetInitialize@
  NetChain[{ConvolutionLayer[1, 1], PartLayer[1]}, 
   "Input" -> {1, 200, 200, 3}]
cnet = CloudExport[scrnet, "MX", "scrnet", Permissions -> "Public"]
CloudDeploy[
 FormPage[{"image" -> "Image"}, 
  With[{net = CloudImport@cnet}, Image@net@{ImageData@#image}] &], 
 Permissions -> "Public"]

Funny enough the following does not work:

With[{net = CloudImport@cnet}, Image@net@{ImageData@img}]

It seems that ImageData on my desktop converts RGB to greyscale but does not do that in the cloud.

EDIT: As people stated correctly in the comments the issue was not with ImageData[] but rather with the way the image was saved. Thanks to everyone!

Max

$\endgroup$
2
  • $\begingroup$ If I create Form that does (ImageData // Dimensions), I consistently see RGB output that looks like {_,_,3}. Both in Mathematica and in the cloud. I think the issue is how the NetChain handles this. $\endgroup$ Commented Jul 17, 2018 at 15:54
  • $\begingroup$ So the issue is that original image is greyscale, but if you save it or do anything to it, it'll be converted into a different colorspace. In this case, you're converting it from grayscale into an RGB colorspace so the dimensionality of the image changes. This really confused me too, but I don't think it's a bug of any kind. The correct solution for this is probably to use NetEncoder for Images to make the NetChain be more universal in the kind of input it accepts. $\endgroup$ Commented Jul 18, 2018 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.