Imlidrdokefast / static /index1.html
Ashrafb's picture
Rename static/index.html to static/index1.html
4af5096 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image to Line Drawings</title>
</head>
<body>
<h1>Image to Line Drawings</h1>
<form action="/predict" method="post" enctype="multipart/form-data">
<label for="file">Choose an image:</label><br>
<input type="file" id="file" name="file"><br>
<label for="version">Version:</label><br>
<input type="radio" id="simple" name="version" value="Simple Lines" checked>
<label for="simple">Simple Lines</label><br>
<input type="radio" id="complex" name="version" value="Complex Lines">
<label for="complex">Complex Lines</label><br><br>
<input type="submit" value="Submit">
</form>
<div id="result"></div>
<script>
document.querySelector('form').addEventListener('submit', async function (e) {
e.preventDefault();
const formData = new FormData();
formData.append('file', document.querySelector('#file').files[0]);
formData.append('version', document.querySelector('input[name="version"]:checked').value);
const response = await fetch('/predict', {
method: 'POST',
body: formData
});
const blob = await response.blob();
const imageUrl = URL.createObjectURL(blob);
document.querySelector('#result').innerHTML = `<img src="${imageUrl}" alt="Line Drawing">`;
});
</script>
</body>
</html>