Subreddit Classifier

No algorithm description given

Table of Contents Introduction I/O examples Algorithm Console Introduction This algorithm detects which subreddit an image probably belongs to, and returns class pairs for the Top 3 best guesses. The classifier is a Convolutional Neural Network , trained to detect the subreddit that an image belongs to; this was done using the following torch model: nn.Sequential {
 [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> (14) -> output]
 (1): nn.SpatialConvolution(3 -> 6, 5x5)
 (2): nn.ReLU
 (3): nn.SpatialMaxPooling(2x2, 2,2)
 (4): nn.SpatialConvolution(6 -> 16, 5x5)
 (5): nn.ReLU
 (6): nn.SpatialMaxPooling(2x2, 2,2)
 (7): nn.View(55696)
 (8): nn.Linear(55696 -> 1024)
 (9): nn.Tanh
 (10): nn.Dropout(0.125000)
 (11): nn.Linear(1024 -> 120)
 (12): nn.Tanh
 (13): nn.Linear(120 -> 5)
 (14): nn.LogSoftMax
}
 The above model uses multiple convolution and max pooling layers to allow the CNN model to break up the large (3 colour channels)*height*weight tensor into multiple smaller subregions that can each have different operations performed. The Convolutions allows the network to create feature maps from an image, which allows the rest of the network to predict image content from extracted features instead of raw image data. The CNN model was trained with the following image based subreddits: Cat Pictures Dog Pictures Car Porn History Porn Food Porn I/O Input src: String src - (required) - the source image to classify, this must be in either jpg or png format, mage Data API Url' Web (http/https) Url /binary image or a base64 encoded JPEG String. Output {
 "first": {
 "className": String,
 "confidence": Float
 },
 "second": {
 "className": String,
 "confidence": Float
 },
 "third": {
 "className": String,
 "confidence": Float
 }
}
 first - the source image to classify, this must be in either jpg or png format, mage Data API Url' Web (http/https) Url /binary image or a base64 encoded JPEG String. className - The classname for the label (string). confidence - The confidence that this label is correct (float). Examples Example 1 Input "http://lovelace-media.imgix.net/uploads/191/0f832b40-d622-0132-cea9-0e01949ad350.jpg"
 Output {
 "first": {
 "className": "dogpictures",
 "confidence": 0.9969158
 },
 "second": {
 "className": "catpictures",
 "confidence": 0.0027667093
 },
 "third": {
 "className": "foodporn",
 "confidence": 0.00031607767
 }
}
 Example 2 Input "https://i.imgur.com/nraWKPw.jpg"
 Output {
 "first": {
 "className": "foodporn",
 "confidence": 0.99819106
 },
 "second": {
 "className": "dogpictures",
 "confidence": 0.0013163951
 },
 "third": {
 "className": "catpictures",
 "confidence": 0.00039565665
 }
}


Tags
(no tags)

Cost Breakdown

0 cr
royalty per call
1 cr
usage per second
avg duration

Cost Calculator

API call duration (sec)
×
API calls
=
Estimated cost
per calls
for large volume discounts
For additional details on how pricing works, see Algorithmia pricing.

Internet access

This algorithm has Internet access. This is necessary for algorithms that rely on external services, however it also implies that this algorithm is able to send your input data outside of the Algorithmia platform.


To understand more about how algorithm permissions work, see the permissions documentation.

1. Type your input

2. See the result

Running algorithm...

3. Use this algorithm

curl -X POST -d '{{input | formatInput:"curl"}}' -H 'Content-Type: application/json' -H 'Authorization: Simple YOUR_API_KEY' https://api.algorithmia.com/v1/algo/deeplearning/SubredditClassifier/0.1.3
View cURL Docs
algo auth
# Enter API Key: YOUR_API_KEY
algo run algo://deeplearning/SubredditClassifier/0.1.3 -d '{{input | formatInput:"cli"}}'
View CLI Docs
import com.algorithmia.*;
import com.algorithmia.algo.*;

String input = "{{input | formatInput:"java"}}";
AlgorithmiaClient client = Algorithmia.client("YOUR_API_KEY");
Algorithm algo = client.algo("algo://deeplearning/SubredditClassifier/0.1.3");
AlgoResponse result = algo.pipeJson(input);
System.out.println(result.asJsonString());
View Java Docs
import com.algorithmia._
import com.algorithmia.algo._

val input = {{input | formatInput:"scala"}}
val client = Algorithmia.client("YOUR_API_KEY")
val algo = client.algo("algo://deeplearning/SubredditClassifier/0.1.3")
val result = algo.pipeJson(input)
System.out.println(result.asJsonString)
View Scala Docs
var input = {{input | formatInput:"javascript"}};
Algorithmia.client("YOUR_API_KEY")
           .algo("algo://deeplearning/SubredditClassifier/0.1.3")
           .pipe(input)
           .then(function(output) {
             console.log(output);
           });
View Javascript Docs
var input = {{input | formatInput:"javascript"}};
Algorithmia.client("YOUR_API_KEY")
           .algo("algo://deeplearning/SubredditClassifier/0.1.3")
           .pipe(input)
           .then(function(response) {
             console.log(response.get());
           });
View NodeJS Docs
import Algorithmia

input = {{input | formatInput:"python"}}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('deeplearning/SubredditClassifier/0.1.3')
print algo.pipe(input)
View Python Docs
library(algorithmia)

input <- {{input | formatInput:"r"}}
client <- getAlgorithmiaClient("YOUR_API_KEY")
algo <- client$algo("deeplearning/SubredditClassifier/0.1.3")
result <- algo$pipe(input)$result
print(result)
View R Docs
require 'algorithmia'

input = {{input | formatInput:"ruby"}}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('deeplearning/SubredditClassifier/0.1.3')
puts algo.pipe(input).result
View Ruby Docs
use algorithmia::*;

let input = {{input | formatInput:"rust"}};
let client = Algorithmia::client("YOUR_API_KEY");
let algo = client.algo('deeplearning/SubredditClassifier/0.1.3');
let response = algo.pipe(input);
View Rust Docs
Discussion
  • {{comment.username}}