-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
67 lines (56 loc) · 2.57 KB
/
Copy pathrun.py
File metadata and controls
67 lines (56 loc) · 2.57 KB
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
import os
import subprocess
import sys
def setup():
"""Setup the application"""
print("="*50)
print("SanDisk AI Smart Duplicate Finder")
print("="*50)
# Create directories
os.makedirs('uploads', exist_ok=True)
os.makedirs('static/thumbnails', exist_ok=True)
os.makedirs('models', exist_ok=True)
# Create sample files for testing
print("\n📁 Creating sample files for testing...")
# Sample images (create small colored images)
try:
from PIL import Image, ImageDraw
# Create sample images
for i in range(3):
img = Image.new('RGB', (200, 200), color=(73, 109, 137))
d = ImageDraw.Draw(img)
d.text((10,10), f"Sample {i+1}", fill=(255,255,255))
img.save(f'uploads/sample_image_{i+1}.jpg')
# Create duplicate images (exact copies)
import shutil
shutil.copy('uploads/sample_image_1.jpg', 'uploads/sample_image_1_copy.jpg')
shutil.copy('uploads/sample_image_2.jpg', 'uploads/sample_image_2_copy.jpg')
# Create near-duplicate (slightly modified)
img = Image.new('RGB', (200, 200), color=(73, 109, 137))
d = ImageDraw.Draw(img)
d.text((10,30), "Modified version", fill=(255,255,255))
img.save('uploads/sample_image_1_modified.jpg')
except Exception as e:
print(f"⚠️ Could not create images: {e}")
# Create text files as fallback
with open('uploads/doc1.txt', 'w') as f:
f.write("Artificial Intelligence and Machine Learning are transforming storage management.")
with open('uploads/doc2.txt', 'w') as f:
f.write("Artificial Intelligence and Machine Learning are transforming storage management.") # Exact duplicate
with open('uploads/doc3.txt', 'w') as f:
f.write("AI and ML technologies are revolutionizing how we manage data storage systems.") # Near duplicate
print("✅ Sample files created in 'uploads' folder")
print("\n🚀 Starting Flask server...")
print("📱 Open http://localhost:5000 in your browser")
print("="*50)
# Add this part to actually run the app
if __name__ == "__main__":
setup()
# Import and run the Flask app
try:
from app import app
app.run(debug=True, host='0.0.0.0', port=5000)
except ImportError as e:
print(f"❌ Error: Could not import app. Make sure app.py exists: {e}")
except Exception as e:
print(f"❌ Error starting server: {e}")