GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — CodeProject.AI-Server/src/modules/PortraitFilter/test.html at main · Major2000/CodeProject.AI-Server Expand file tree/ Copy pathtest.htmlMore file actions 152 lines (129 loc) · 5.43 KB / Copy pathtest.htmlFile metadata and controls152 lines (129 loc) · 5.43 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Portrait Filter Test Page</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <style> /* START EXPLORER STYLE */ /* END EXPLORER STYLE */ </style> <script type="text/javascript"> // START EXPLORER SCRIPT const apiServiceUrl = "http://localhost:32168"; function setStatus(text, color) { if (color) document.getElementById("status").innerHTML = "<span style='color:" + color + "'>" + text + "</span>"; else document.getElementById("status").innerHTML = "<span>" + text + "</span>"; } function submitRequest(controller, apiName, images, parameters, doneFunc) { setStatus("Sending request to AI server", "blue"); var formData = new FormData(); // Check file selected or not if (images && images.length > 0) { for (var i = 0; i < images.length; i++) { file = images[i]; formData.append('image' + (i + 1), file); } } if (parameters && parameters.length > 0) { for (var i = 0; i < parameters.length; i++) { keypair = parameters[i]; formData.append(keypair[0], keypair[1]); } } var url = apiServiceUrl + '/v1/' + controller + '/' + apiName; //result.innerHTML = ""; fetch(url, { method: "POST", body: formData }) .then(response => { if (!response.ok) setStatus('Error contacting API server', "red"); else { response.json().then(data => { if (data) { doneFunc(data) setStatus("Call to " + apiName + " complete", "green"); } else setStatus('No data was returned', "red"); }) .catch(error => { setStatus("Unable to read response: " + error, "red"); }) } }) .catch(error => { setStatus('Unable to complete API call: ' + error, "red") }); } function onSubmit(image, strength) { if (image.files.length == 0) { alert("No file was selected for scene detection"); return; } var images = [image.files[0]]; filteredImage.src = ""; submitRequest("image", "portraitfilter", images, [["strength", strength.value]], function (data) { // alert("got response"); filteredImage.src = "data:image/png;base64," + data.filtered_image; }); } function onFileSelect(image) { if (image.files.length == 0) { originalImage.src = ""; return; } originalImage.src = URL.createObjectURL(image.files[0]); filteredImage.src = ""; } function onStrengthChange() { filteredImage.src = ""; } // END EXPLORER SCRIPT </script> </head> <body> <div class="container"> <h1 class="text-center">Portrait Filter Test Page</h1> <form method="post" action="" enctype="multipart/form-data" id="myform"> <!-- START EXPLORER MARKUP --> <div class="row"> <div class="mb-3 col"> <label class="form-label">Image</label> <input class="form-control btn-light" id="image" type="file" onchange="onFileSelect(image)" /> </div> <div class="mb-3 col-2"> <label class="form-label">Strength</label> <input class="form-control" id="strength" type="number" min="0.0" max="1.0" step="0.1" value="0.5" onchange="onStrengthChange()"/> </div> </div> <div class="row"> <div class="mb-3 text-center"> <input class="btn btn-primary" type="button" value="Submit" onclick="onSubmit(image, strength)" /> </div> </div> <!-- END EXPLORER MARKUP --> </form> <div id="status" class="text-center"></div> <div class="row"> <label id="originallbl" class="col-6 text-center">Original</label> <label id="filteredlbl" class="col-6 text-center">Filtered</label> </div> <div class="row"> <img id="originalImage" class="col-6" /> <img id="filteredImage" class="col-6" /> </div> </div> <!-- Bootstrap 5 JavaScript Bundle with Popper --> integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> </body> </html> |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |