import { useState } from 'react' import { motion, AnimatePresence } from 'framer-motion' import Header from './components/Header' import ImageUpload from './components/ImageUpload' import ResultDisplay from './components/ResultDisplay' import Features from './components/Features' import axios from 'axios' function App() { const [image1, setImage1] = useState(null) const [image2, setImage2] = useState(null) const [result, setResult] = useState(null) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const handleCompare = async () => { if (!image1 || !image2) { setError('Please upload both images') return } setLoading(true) setError(null) setResult(null) try { const formData = new FormData() formData.append('image1', image1.file) formData.append('image2', image2.file) const response = await axios.post('/api/compare', formData, { headers: { 'Content-Type': 'multipart/form-data' } }) setResult(response.data) } catch (err) { setError(err.response?.data?.detail || 'Failed to compare faces. Please try again.') } finally { setLoading(false) } } const handleReset = () => { setResult(null) setImage1(null) setImage2(null) setError(null) } // Clear result when an image is removed const handleClearImage1 = () => { setResult(null) setImage1(null) } const handleClearImage2 = () => { setResult(null) setImage2(null) } return (
{/* Hero Section */}

Face Recognition

Advanced AI-powered face comparison technology.
Upload two images to verify if they belong to the same person.

{/* Main Content - Side by Side Layout */}
{/* Upload Section */}
{/* Action Buttons - Smaller */}
{loading ? ( Analyzing... ) : ( 'Compare Faces' )} {(image1 || image2 || result) && ( Reset )}
{/* Error Display */} {error && ( {error} )}
{/* Results Section - Shows on Right, exits to Right */} {result && image1 && image2 && ( )}
{/* Features Section */}
{/* Footer */}
) } export default App