Spaces:
Sleeping
Sleeping
| import os | |
| html_path = 'e:/Deepfake/deepfake_detector/templates/index.html' | |
| with open(html_path, 'r', encoding='utf-8') as f: | |
| content = f.read() | |
| # 1. Update progress messages | |
| content = content.replace('ic=["Preparing image', 'ic=["Preparing media') | |
| # 2. Update onDrop validation to be more robust (accept any video) | |
| # Original: p&&(p.type.startsWith("image/")||p.name.toLowerCase().endsWith(".mp4"))&&a(p) | |
| content = content.replace('p.name.toLowerCase().endsWith(".mp4")', 'p.type.startsWith("video/")') | |
| # 3. Update analyzing state preview | |
| # Original: E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"}) | |
| # Note: There are two img tags with almost same props. Let's find them specifically. | |
| # Pattern for analyzing state | |
| # ...children:[E.jsxs("div",{className:"relative aspect-[4/3] overflow-hidden",children:[E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"}),E.jsx("div",{className:"absolute inset-0 bg-charcoal/30"}),... | |
| analyzing_img = 'E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"})' | |
| analyzing_video = '(l?.type.startsWith("video/")?E.jsx("video",{src:a,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0}):E.jsx("img",{src:a,alt:"Analyzing",className:"w-full h-full object-cover"}))' | |
| content = content.replace(analyzing_img, analyzing_video) | |
| # 4. Update result state preview | |
| result_img = 'E.jsx("img",{src:a,alt:"Analyzed",className:"w-full h-full object-cover"})' | |
| result_video = '(l?.type.startsWith("video/")?E.jsx("video",{src:a,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0}):E.jsx("img",{src:a,alt:"Analyzed",className:"w-full h-full object-cover"}))' | |
| content = content.replace(result_img, result_video) | |
| # 4.5 Update preview state (Ready for analysis) | |
| preview_img = 'E.jsx("img",{src:a,alt:"Uploaded image",className:"w-full h-full object-cover"})' | |
| preview_video = '(l?.type.startsWith("video/")?E.jsx("video",{src:a,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0}):E.jsx("img",{src:a,alt:"Uploaded image",className:"w-full h-full object-cover"}))' | |
| content = content.replace(preview_img, preview_video) | |
| # 5. Update footer/label text and titles to be more inclusive | |
| content = content.replace('Images, Video (MP4)', 'Images, Video (MP4, MOV, etc.)') | |
| content = content.replace('AI Image Authenticity Detector', 'AI Media Authenticity Detector') | |
| content = content.replace('TrueLens — AI Image', 'TrueLens — AI Media') | |
| content = content.replace('children:"Image uploaded"', 'children:(l?.type.startsWith("video/")?"Video uploaded":"Image uploaded")') | |
| content = content.replace('this image is authentic.', 'this media is authentic.') | |
| content = content.replace('children:"Change Image"', 'children:"Change Media"') | |
| # 6. Update accept attribute | |
| content = content.replace('accept="image/*,video/mp4"', 'accept="image/*,video/mp4,video/quicktime,video/x-msvideo,video/webm,video/*"') | |
| # Write back | |
| with open(html_path, 'w', encoding='utf-8') as f: | |
| f.write(content) | |
| print("index.html patched successfully.") | |