File size: 11,279 Bytes
87bbcb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cff23f2
87bbcb4
 
 
 
 
 
cff23f2
 
 
 
 
 
 
 
87bbcb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cff23f2
 
 
87bbcb4
 
 
 
 
 
 
 
 
 
 
 
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Image Modification</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        .upload-area {
            border: 2px dashed #ccc;
            border-radius: 10px;
            padding: 40px;
            text-align: center;
            cursor: pointer;
            transition: border-color 0.3s;
        }
        .upload-area:hover {
            border-color: #666;
        }
        .upload-area.dragover {
            border-color: #3b82f6;
            background-color: #f0f9ff;
        }
        .chat-message {
            margin: 10px 0;
            padding: 10px;
            border-radius: 8px;
        }
        .user-message {
            background-color: #e3f2fd;
            margin-left: 20%;
        }
        .ai-message {
            background-color: #f5f5f5;
            margin-right: 20%;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <h1 class="text-3xl font-bold text-center mb-8">AI Image Modification</h1>
        
        <div class="grid md:grid-cols-2 gap-8">
            <!-- Upload Section -->
            <div class="space-y-6">
                <div class="upload-area" id="uploadArea">
                    <input type="file" id="imageUpload" accept="image/*" class="hidden">
                    <div class="text-center">
                        <svg class="w-12 h-12 mx-auto text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
                        </svg>
                        <p class="mt-2 text-lg">Click to upload an image or drag and drop</p>
                        <p class="text-sm text-gray-500">PNG, JPG, JPEG up to 10MB</p>
                    </div>
                </div>
                
                <div id="imagePreview" class="hidden">
                    <img id="previewImage" class="w-full max-w-md mx-auto rounded-lg shadow-md">
                </div>
            </div>

            <!-- Chat Interface -->
            <div class="space-y-6">
                <div class="bg-white rounded-lg shadow-md p-4">
                    <h2 class="text-xl font-semibold mb-4">Describe your modifications</h2>
                    <div id="chatContainer" class="h-64 overflow-y-auto mb-4 space-y-2">
                        <div class="chat-message ai-message">
                            <p>Hello! I can help you modify your image using AI. Please upload an image and describe what changes you'd like me to make.</p>
                        </div>
                    </div>
                    
                    <div class="flex space-x-2">
                        <input type="text" id="messageInput" placeholder="Describe your image modifications..." 
                               class="flex-1 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:border-blue-500">
                        <button id="sendButton" class="bg-blue-500 text-white px-6 py-2 rounded-lg hover:bg-blue-600 transition-colors">
                            Send
                        </button>
                    </div>
                </div>

                <!-- Modification Controls -->
                <div class="bg-white rounded-lg shadow-md p-4">
                    <h2 class="text-xl font-semibold mb-4">Modification Options</h2>
                    <div class="space-y-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">Face Arrangement</label>
                            <select id="arrangementSelect" class="w-full border border-gray-300 rounded-lg px-3 py-2">
                                <option value="grid">Grid Layout</option>
                                <option value="circle">Circular Arrangement</option>
                                <option value="pyramid">Pyramid Formation</option>
                                <option value="random">Random Placement</option>
                            </select>
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">Name Tag Style</label>
                            <select id="tagStyleSelect" class="w-full border border-gray-300 rounded-lg px-3 py-2">
                                <option value="modern">Modern</option>
                                <option value="classic">Classic</option>
                                <option value="minimal">Minimal</option>
                                <option value="elegant">Elegant</option>
                            </select>
                        </div>
                        
                        <button id="generateButton" class="w-full bg-green-500 text-white py-2 rounded-lg hover:bg-green-600 transition-colors disabled:bg-gray-300" disabled>
                            Generate Modified Image
                        </button>
                    </div>
                </div>
            </div>
        </div>

        <!-- Results Section -->
        <div id="resultsSection" class="mt-8 hidden">
            <h2 class="text-2xl font-bold mb-4">Generated Result</h2>
            <div class="bg-white rounded-lg shadow-md p-6 text-center">
                <img id="resultImage" class="max-w-full mx-auto rounded-lg mb-4">
                <button id="downloadButton" class="bg-blue-500 text-white px-6 py-2 rounded-lg hover:bg-blue-600 transition-colors">
                    Download Result
                </button>
            </div>
        </div>
    </div>

    <script>
        // Use the provided sample image by default
        const uploadArea = document.getElementById('uploadArea');
        const imageUpload = document.getElementById('imageUpload');
        const imagePreview = document.getElementById('imagePreview');
        const previewImage = document.getElementById('previewImage');
        const generateButton = document.getElementById('generateButton');
        
        // Set the sample image on page load
        window.addEventListener('load', function() {
            previewImage.src = "https://huggingface.co/spaces/al2kool/deepsite-project/resolve/main/images/27544.jpg";
            imagePreview.classList.remove('hidden');
            generateButton.disabled = false;
            addChatMessage('ai', 'I\'ve loaded the sample image for you. Now describe what modifications you\'d like me to make. For example: "Arrange the faces in a circle with elegant name tags"');
        });
uploadArea.addEventListener('click', () => imageUpload.click());
        uploadArea.addEventListener('dragover', (e) => {
            e.preventDefault();
            uploadArea.classList.add('dragover');
        });
        uploadArea.addEventListener('dragleave', () => {
            uploadArea.classList.remove('dragover');
        });
        uploadArea.addEventListener('drop', (e) => {
            e.preventDefault();
            uploadArea.classList.remove('dragover');
            const files = e.dataTransfer.files;
            if (files.length > 0) {
                handleImageUpload(files[0]);
            }
        });
        
        imageUpload.addEventListener('change', (e) => {
            if (e.target.files.length > 0) {
                handleImageUpload(e.target.files[0]);
            }
        });
        
        function handleImageUpload(file) {
            if (file && file.type.startsWith('image/')) {
                const reader = new FileReader();
                reader.onload = function(e) {
                    previewImage.src = e.target.result;
                    imagePreview.classList.remove('hidden');
                    generateButton.disabled = false;
                    addChatMessage('user', `Uploaded image: ${file.name}`);
                    addChatMessage('ai', 'Great! I can see your image. Now describe what modifications you\'d like me to make. For example: "Arrange the faces in a circle with elegant name tags"');
                };
                reader.readAsDataURL(file);
            }
        }
        
        // Chat functionality
        const chatContainer = document.getElementById('chatContainer');
        const messageInput = document.getElementById('messageInput');
        const sendButton = document.getElementById('sendButton');
        
        function addChatMessage(sender, message) {
            const messageDiv = document.createElement('div');
            messageDiv.className = `chat-message ${sender === 'user' ? 'user-message' : 'ai-message'}`;
            messageDiv.innerHTML = `<p>${message}</p>`;
            chatContainer.appendChild(messageDiv);
            chatContainer.scrollTop = chatContainer.scrollHeight;
        }
        
        sendButton.addEventListener('click', sendMessage);
        messageInput.addEventListener('keypress', (e) => {
            if (e.key === 'Enter') sendMessage();
        });
        
        function sendMessage() {
            const message = messageInput.value.trim();
            if (message) {
                addChatMessage('user', message);
                messageInput.value = '';
                
                // Simulate AI response
                setTimeout(() => {
                    addChatMessage('ai', `I understand you want: "${message}". I'll use the selected arrangement and style options to modify your image. Click "Generate Modified Image" when ready.`);
                }, 1000);
            }
        }
        
        // Generate functionality
        generateButton.addEventListener('click', generateImage);
        
        function generateImage() {
            const arrangement = document.getElementById('arrangementSelect').value;
            const tagStyle = document.getElementById('tagStyleSelect').value;
            
            addChatMessage('ai', `Generating image with ${arrangement} arrangement and ${tagStyle} name tags...`);
            
            // Simulate generation process
            setTimeout(() => {
                const resultsSection = document.getElementById('resultsSection');
                const resultImage = document.getElementById('resultImage');
                // Use a wedding anniversary themed image for demonstration
                resultImage.src = 'http://static.photos/wedding/1024x576/45';
resultsSection.classList.remove('hidden');
                
                addChatMessage('ai', 'Your modified image is ready! I\'ve arranged the faces as requested with the specified name tag style.');
            }, 2000);
        }
        
        // Download functionality
        document.getElementById('downloadButton').addEventListener('click', () => {
            alert('In a real implementation, this would download the generated image.');
        });
    </script>
</body>
</html>