2
$\begingroup$

I developed this code that allows me to recognize what breed is the dog in the inserted image (for the time being developed only for five breeds of dogs), however, when I go to insert the image in output gives me a series of vectors . could you tell me where I'm wrong? I am attaching the code.

dobermann = {-> "Dobermann", -> "Dobermann", -> "Dobermann", -> 
    "Dobermann", -> "Dobermann"};
rottweiler = {-> "Rottweiler", -> "Rottweiler", -> "Rottweiler", -> 
    "Rottweiler", -> "Rottweiler"};
alano = {-> "Alano", -> "Alano", -> "Alano", -> "Alano", -> "Alano"};
labrador = {-> "Labrador", -> "Labrador", -> "Labrador", -> 
    "Labrador", -> "Labrador" };
husky = {-> "Husky", -> "Husky", -> "Husky", -> "Husky", -> "Husky" };
dogTypeSet = {dobermann, rottweiler, alano, labrador, husky};
dogTypes = Flatten[dogTypeSet];
class = Classify[
   Flatten[{dobermann, rottweiler, alano, labrador, husky}]];
CloudDeploy[
 FormPage["image" -> "Image", 
  Column[{image, "This is a " <> ToString[net[image]] <> "dog"}], 
  AppearanceRules -> <|"Title" -> "What dog is that?", 
    "Description" -> 
     "Enter an image of a dog and I'll tell you what it is"|>], 
 Permissions -> "Public"]

Before the arrows are inserted the images of each dog breed. I had to remove them otherwise the code became incomprehensible.

$\endgroup$
  • $\begingroup$ There appears to be an issue in your code - you are calling net rather than class in your FormPage. In Column[{image, "This is a " <> ToString[net[image]] <> "dog"}], replace net with class. $\endgroup$ – Carl Lange Jan 9 at 17:15
  • $\begingroup$ Done, but it gives me the following error: ClassifierFunction::mlincfttp: Incompatible variable type (Image) and variable value (image). $\endgroup$ – Pasquale Jan 9 at 17:21
  • $\begingroup$ Please see my answer - there was another error in your code I didn't immediately spot. $\endgroup$ – Carl Lange Jan 9 at 17:22
3
$\begingroup$

There are some errors in your code.

A working CloudDeploy statement is below.

CloudDeploy[
 FormPage["image" -> "Image", 
  Column[{#image, 
     "This is a " <> ToString[class[#image]] <> "dog"}] &, 
  AppearanceRules -> <|"Title" -> "What dog is that?", 
    "Description" -> 
     "Enter an image of a dog and I'll tell you what it is"|>], 
 Permissions -> "Public"]

Firstly, FormPage takes a function as the second argument, rather than an expression. Thus, you must use #image rather than image and close the expression with a $. Secondly, you misnamed class as net.

I have tried this myself with a day/night classifier (rather than dog breed classifier) and it works well.

daynight

$\endgroup$
  • $\begingroup$ Thank you very much. One last thing, how could I train a neural network so that I can recognize any breed of dog. Doing as I did I use too much time. $\endgroup$ – Pasquale Jan 9 at 17:29
  • 1
    $\begingroup$ That is a separate question and you should open a new one accordingly. If you found this answer useful for your specific question, you should mark it as accepted. A starting point for a dog breed classifier would be the Stanford Dogs dataset which has many images of 120 different breeds. You would need to import the data to Mathematica and you could run Classify in it in a similar way. $\endgroup$ – Carl Lange Jan 9 at 17:33
  • $\begingroup$ Now I try, in case I open a new discussion. Thank you. $\endgroup$ – Pasquale Jan 9 at 17:35
  • $\begingroup$ If instead I wanted to propose an interface on mathematica and not on the cloud, what should I change? $\endgroup$ – Pasquale Jan 9 at 17:46
  • 1
    $\begingroup$ @Pasquale Please consider opening a new question for follow-up questions, and consider marking this answer as accepted. Comments aren't good for long discussions! $\endgroup$ – Carl Lange Jan 9 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.