update
Browse files- app.py +3 -0
- static/index.js +28 -3
- static/style.css +5 -0
- templates/index.html +14 -0
app.py
CHANGED
|
@@ -111,6 +111,9 @@ def process_input(body, random=False):
|
|
| 111 |
def root(request: Request):
|
| 112 |
return templates.TemplateResponse("index.html", {"request": request})
|
| 113 |
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
@app.post("/predict")
|
| 116 |
async def predict(request: Request):
|
|
|
|
| 111 |
def root(request: Request):
|
| 112 |
return templates.TemplateResponse("index.html", {"request": request})
|
| 113 |
|
| 114 |
+
@app.get("/check_gpu")
|
| 115 |
+
async def check_gpu():
|
| 116 |
+
return torch.cuda.is_available()
|
| 117 |
|
| 118 |
@app.post("/predict")
|
| 119 |
async def predict(request: Request):
|
static/index.js
CHANGED
|
@@ -7,6 +7,30 @@ let svgGraph = null;
|
|
| 7 |
let mouselbtn = false;
|
| 8 |
var current_time = (new Date()).getTime();
|
| 9 |
var user_id = Math.floor(Math.random() * 1000000000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
// initilize
|
|
@@ -19,6 +43,7 @@ window.onload = function () {
|
|
| 19 |
ctxIn.color = "#b0d49b";
|
| 20 |
ctxIn.lineWidth = 30;
|
| 21 |
ctxIn.lineJoin = ctxIn.lineCap = 'round';
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
|
|
@@ -52,7 +77,7 @@ cvsIn.addEventListener("mousemove", function (e) {
|
|
| 52 |
ctxIn.lineTo(x, y);
|
| 53 |
ctxIn.strokeStyle = ctxIn.color;
|
| 54 |
ctxIn.stroke();
|
| 55 |
-
if (((new Date).getTime() - current_time) >=
|
| 56 |
move_range = domainSlider.value;
|
| 57 |
onRecognition(move_range);
|
| 58 |
current_time = (new Date).getTime();
|
|
@@ -218,7 +243,7 @@ function onRecognition(range) {
|
|
| 218 |
alert("error");
|
| 219 |
})
|
| 220 |
|
| 221 |
-
console.timeEnd("
|
| 222 |
}
|
| 223 |
|
| 224 |
function onRecognition_random(range) {
|
|
@@ -242,7 +267,7 @@ function onRecognition_random(range) {
|
|
| 242 |
alert("error");
|
| 243 |
})
|
| 244 |
|
| 245 |
-
console.timeEnd("
|
| 246 |
}
|
| 247 |
|
| 248 |
function drawImgToCanvas(canvasId, b64Img) {
|
|
|
|
| 7 |
let mouselbtn = false;
|
| 8 |
var current_time = (new Date()).getTime();
|
| 9 |
var user_id = Math.floor(Math.random() * 1000000000);
|
| 10 |
+
var infer_interval = null;
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
function setInferInterval() {
|
| 14 |
+
// call 'check_gpu' function to check if GPU is available
|
| 15 |
+
$.ajax({
|
| 16 |
+
url: './check_gpu',
|
| 17 |
+
type: 'GET',
|
| 18 |
+
contentType: 'application/json',
|
| 19 |
+
}).done(function (data) {
|
| 20 |
+
console.log(data);
|
| 21 |
+
if (data == false) {
|
| 22 |
+
console.log("GPU is not available. Use CPU for inference.");
|
| 23 |
+
infer_interval = 4000;
|
| 24 |
+
}
|
| 25 |
+
else {
|
| 26 |
+
console.log("GPU is available. Use GPU for inference.");
|
| 27 |
+
infer_interval = 300;
|
| 28 |
+
}
|
| 29 |
+
}).fail(function (XMLHttpRequest, textStatus, errorThrown) {
|
| 30 |
+
console.log(XMLHttpRequest);
|
| 31 |
+
alert("error");
|
| 32 |
+
})
|
| 33 |
+
}
|
| 34 |
|
| 35 |
|
| 36 |
// initilize
|
|
|
|
| 43 |
ctxIn.color = "#b0d49b";
|
| 44 |
ctxIn.lineWidth = 30;
|
| 45 |
ctxIn.lineJoin = ctxIn.lineCap = 'round';
|
| 46 |
+
setInferInterval();
|
| 47 |
}
|
| 48 |
|
| 49 |
|
|
|
|
| 77 |
ctxIn.lineTo(x, y);
|
| 78 |
ctxIn.strokeStyle = ctxIn.color;
|
| 79 |
ctxIn.stroke();
|
| 80 |
+
if (((new Date).getTime() - current_time) >= infer_interval) {
|
| 81 |
move_range = domainSlider.value;
|
| 82 |
onRecognition(move_range);
|
| 83 |
current_time = (new Date).getTime();
|
|
|
|
| 243 |
alert("error");
|
| 244 |
})
|
| 245 |
|
| 246 |
+
console.timeEnd("predict");
|
| 247 |
}
|
| 248 |
|
| 249 |
function onRecognition_random(range) {
|
|
|
|
| 267 |
alert("error");
|
| 268 |
})
|
| 269 |
|
| 270 |
+
console.timeEnd("predict");
|
| 271 |
}
|
| 272 |
|
| 273 |
function drawImgToCanvas(canvasId, b64Img) {
|
static/style.css
CHANGED
|
@@ -2,6 +2,11 @@
|
|
| 2 |
text-align: center;
|
| 3 |
}
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
.boxitem1 {
|
| 6 |
display: inline-block;
|
| 7 |
vertical-align: left;
|
|
|
|
| 2 |
text-align: center;
|
| 3 |
}
|
| 4 |
|
| 5 |
+
/* Solid border */
|
| 6 |
+
hr.solid {
|
| 7 |
+
border-top: 3px solid #bbb;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
.boxitem1 {
|
| 11 |
display: inline-block;
|
| 12 |
vertical-align: left;
|
templates/index.html
CHANGED
|
@@ -8,6 +8,20 @@
|
|
| 8 |
<title>Label to Art Demo_V_0.7 </title>
|
| 9 |
</head>
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
<div class="common">
|
| 12 |
|
| 13 |
<body>
|
|
|
|
| 8 |
<title>Label to Art Demo_V_0.7 </title>
|
| 9 |
</head>
|
| 10 |
|
| 11 |
+
<h1 style="text-align: center; font-size: 40px; font-family: 'Times New Roman', Times, serif;">
|
| 12 |
+
Controllable Multi-domain Semantic Artwork Synthesis
|
| 13 |
+
</h1>
|
| 14 |
+
<p style="text-align: center; font-size: 20px; font-family: 'Times New Roman', Times, serif;">
|
| 15 |
+
<a href="https://sky24h.github.io/websites/cvmj2023_controllable-artwork-synthesis/" target="_blank">
|
| 16 |
+
<b>Project Page</b>
|
| 17 |
+
<!-- <br> -->
|
| 18 |
+
</a>
|
| 19 |
+
<a style="text-align: center; display:inline-block" href="https://huggingface.co/spaces/sky24h/Controllable_Multi-domain_Semantic_Artwork_Synthesis?duplicate=true">
|
| 20 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm.svg#center" alt="Duplicate Space">
|
| 21 |
+
</a>
|
| 22 |
+
</p>
|
| 23 |
+
<hr class="solid">
|
| 24 |
+
|
| 25 |
<div class="common">
|
| 26 |
|
| 27 |
<body>
|