deepsite-project / image-modification.html
al2kool's picture
I need you to generate a new image using faces from this attached image and the name tags on their body in a setup and arrangement as follows: it's mom and dad's 45 wedding anniversary, so the theme of the image should be there celebration party where everyone is in wedding clothes. Mom and dad in the center, side hugging with my son 1, my son 2 and sister's daughter kneeling/standing in front of them. Me and my wife on mom's side and sister and sister's husband on dad's side. Everyone side hugging for the picture
cff23f2 verified
Raw History Blame Contribute Delete
11.3 kB
<!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>