Ejemplo n.º 1
0
<?php

require '../../core.php';
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
header('Content-Type: application/json');
if (isset($_GET["action"])) {
    $action = $_GET["action"];
    $controller = new AlgorithmController();
    if ($action === "query") {
        if (isset($_GET["image_id"])) {
            $imageId = $_GET["image_id"];
            $scientistDataset = isset($_GET["scientist_dataset"]) && $_GET["scientist_dataset"];
            if (isset($_GET["store"]) && $_GET["store"]) {
                echo json_encode(["result" => $controller->runOnImage($imageId, true, null, $scientistDataset)]);
            } else {
                echo json_encode(["result" => $controller->runOnImage($imageId, false, null, $scientistDataset)]);
            }
        } else {
            error("No image id specified.");
        }
    } else {
        if ($action === "status") {
            $st = new JobStatusQuery();
            echo $status = $st->fetch()->asJSON();
        } else {
            error("Invalid action");
        }
    }
} else {
Ejemplo n.º 2
0
<?php

require "../core.php";
$onScientistData = Utils::getValue($_POST["scientist_dataset"], false);
$fromID = Utils::getValue($_POST["from_id"], 1);
$toID = Utils::getValue($_POST["to_id"], -1);
$settings = Utils::getValue($_POST["settings"], null);
if ($settings) {
    $settingsObj = json_decode($settings, true);
} else {
    $settingsObj = null;
}
$st = new JobStatusQuery();
$status = $st->fetch()->asArray();
$controller = new AlgorithmController();
/* if already running then abort */
if ($status["started"]) {
    return;
}
/* ignore user closing the connection */
ignore_user_abort(true);
/* allow infinite time */
set_time_limit(0);
$controller->runAlgorithmJobBatch($st, $settingsObj, $onScientistData, $fromID, $toID);
Ejemplo n.º 3
0
<?php

require 'core.php';
$classifier = new MammalClassifier();
// Usage:
/* Create a MammalClassifier object
    -> call on() to specify the id of the image
        this will load up the image classifications from the database
    -> call classify to run the classification algorithm
    -> call store() to store result back in database
    -> call getResult() to get the result

    Order is (most of the time) important!
*/
$controller = new AlgorithmController();
$controller->runAlgorithm();
$id = 311;
while ($id <= 311) {
    $res = $classifier->on($id)->classify()->store()->getResult();
    $id++;
    print "id: " . $id . " =>";
    print_r($res);
    print "\n";
}