File size: 2,174 Bytes
9841e57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Image Enhancement with NAFNet</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        .image-container { display: flex; gap: 20px; margin-top: 20px; }
        img { max-width: 300px; height: auto; border: 1px solid #ccc; }
        .hidden { display: none; }
    </style>
</head>
<body>
    <h1>Upload Image for AI Enhancement (NAFNet)</h1>
    <input type="file" id="fileInput" accept="image/*">
    <button id="enhanceButton">Enhance Image</button>

    <div class="image-container hidden" id="imageResults">
        <div>
            <h3>Original Image:</h3>
            <img id="beforeImage" src="" alt="Before Image">
        </div>
        <div>
            <h3>Enhanced Image:</h3>
            <img id="afterImage" src="" alt="Enhanced Image">
        </div>
    </div>

    <script>
        document.getElementById('enhanceButton').addEventListener('click', function () {
            const fileInput = document.getElementById('fileInput');
            if (!fileInput.files.length) {
                alert('Please select an image.');
                return;
            }

            const file = fileInput.files[0];
            const formData = new FormData();
            formData.append('file', file);

            fetch('/process_image', {
                method: 'POST',
                body: formData,
            })
                .then(response => response.json())
                .then(data => {
                    if (data.status === 'success') {
                        document.getElementById('beforeImage').src = URL.createObjectURL(file);
                        document.getElementById('afterImage').src = data.output_path;
                        document.getElementById('imageResults').classList.remove('hidden');
                    } else {
                        alert('Processing failed: ' + data.message);
                    }
                })
                .catch(error => console.error('Error:', error));
        });
    </script>
</body>
</html>