This repository was archived by the owner on Aug 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrection.php
More file actions
38 lines (33 loc) · 1.87 KB
/
correction.php
File metadata and controls
38 lines (33 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
// Override maximum execution time
ini_set('max_execution_time', 3000);
$rb = $_POST['rb'];
$correction = $_POST['correction'];
$correction = strtolower($correction);
// Confirm that user says label is wrong
if($rb == "No"){
// Replace space with dash
for ($i=0; $i < strlen($correction); $i++) {
if($correction[$i] == ' '){
$correction[$i] = '-';
}
}
// Begin downloading image from Google Custom Search; only maximum of 100 results can be obtained
$increment = 0;
for($startIndex=1; $startIndex <= 91; $startIndex += 10){
$search_link = file_get_contents("https://www.googleapis.com/customsearch/v1?key=AIzaSyBlK6AOSPS3Ee9Cyo0eweO3TNtp8AJK3KE&cx=009095537961394434779:9wu87vtldtc&q=" . $correction . "&searchType=image&start=" . $startIndex);
$search_result = json_decode($search_link, true);
$count = $search_result['queries']['request'][0]['count'];
for ($i=0; $i < $count; $i++) {
$link = $search_result['items'][$i]['link'];
shell_exec("python image-saver.py " . $link . " " . $correction . " img". ($i + $increment));
}
$increment += 10;
}
//// Script for retraining
// shell_exec('python -m scripts.retrain --bottleneck_dir=tf_files/bottlenecks --model_dir=tf_files/models/ --summaries_dir=tf_files/training_summaries/"mobilenet_0.50_224" --output_graph=tf_files/retrained_graph.pb --output_labels=tf_files/retrained_labels.txt --architecture="mobilenet_0.50_224" --image_dir=tf_files/training_images --random_crop=15');
echo "Thank you for your response. Please retrain the model again, or you may click <a href=\"index.html\">here</a> to go to index.html.";
} else {
echo file_get_contents("index.html");
}
?>