-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
2329 lines (2022 loc) · 82.3 KB
/
app.py
File metadata and controls
2329 lines (2022 loc) · 82.3 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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import subprocess
import os
import json
from datetime import datetime
import hashlib
import threading
import queue
import time
from concurrent.futures import ThreadPoolExecutor
REQUIRED_PACKAGES = [
'flask',
'diffusers',
'transformers',
'torch',
'pillow',
'accelerate',
'safetensors',
'flask-session',
'opencv-python',
'numpy',
'onnxruntime',
'rembg',
'scikit-image',
]
def check_and_install_packages():
"""Smart package installer - only installs missing packages"""
print("🔍 Checking required packages...")
missing_packages = []
for package in REQUIRED_PACKAGES:
package_name = package.replace('-', '_').split('[')[0]
try:
__import__(package_name)
print(f"✓ {package} already installed")
except ImportError:
missing_packages.append(package)
print(f"✗ {package} not found")
if missing_packages:
print(f"\n📦 Installing {len(missing_packages)} missing package(s)...")
for package in missing_packages:
print(f"Installing {package}...")
try:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", package, "-q", "--no-cache-dir"],
timeout=300
)
print(f"✓ {package} installed")
except subprocess.TimeoutExpired:
print(f"⚠️ {package} installation timed out, skipping...")
except Exception as e:
print(f"⚠️ {package} installation failed: {e}")
else:
print("\n✅ All packages already installed!")
print("🎉 Setup complete!\n")
check_and_install_packages()
# Now import the packages
from flask import Flask, render_template_string, request, jsonify
from diffusers import (
StableDiffusionPipeline,
StableDiffusionImg2ImgPipeline,
StableDiffusionInpaintPipeline,
DPMSolverMultistepScheduler,
DPMSolverSinglestepScheduler,
EulerDiscreteScheduler,
EulerAncestralDiscreteScheduler,
DDIMScheduler,
LCMScheduler
)
import torch
from PIL import Image
import io
import base64
import cv2
import numpy as np
from rembg import remove
from skimage import restoration, filters
app = Flask(__name__)
app.secret_key = 'quantum_canvas_ultimate_V1_secret_key_2024'
# Global variables
pipelines = {}
current_model = None
is_generating = False
generation_progress = 0
generation_step = 0
total_steps = 0
generation_queue = queue.Queue()
executor = ThreadPoolExecutor(max_workers=4)
# History file
HISTORY_FILE = '/app/history.json'
FAVORITES_FILE = '/app/favorites.json'
MAX_HISTORY_ITEMS = 100
# Speed Presets
SPEED_PRESETS = {
'lightning': {'name': 'Lightning Fast', 'steps': 6, 'scheduler': 'lcm', 'description': '⚡ Ultra-fast (10-30s)'},
'fast': {'name': 'Fast', 'steps': 15, 'scheduler': 'euler_a', 'description': '🚀 Quick (1-2 min)'},
'balanced': {'name': 'Balanced', 'steps': 30, 'scheduler': 'dpm_multi', 'description': '⚖️ Default (3-5 min)'},
'quality': {'name': 'Quality', 'steps': 45, 'scheduler': 'dpm_multi', 'description': '💎 High Quality (5-8 min)'},
'ultra': {'name': 'Ultra Quality', 'steps': 70, 'scheduler': 'dpm_multi', 'description': '👑 Maximum (8-12 min)'}
}
# 50+ AI Models
AVAILABLE_MODELS = {
# SPEED-OPTIMIZED MODELS
'tiny-sd': {'name': 'Tiny SD', 'id': 'segmind/tiny-sd', 'description': 'Ultra-fast, lightweight', 'speed': '⚡⚡⚡', 'quality': '⭐⭐⭐', 'size': '300MB', 'category': 'speed', 'recommended': True},
'sd-turbo': {'name': 'SD Turbo', 'id': 'stabilityai/sd-turbo', 'description': 'Lightning-fast 1-4 steps', 'speed': '⚡⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '2GB', 'category': 'speed', 'recommended': True},
'lcm-sd': {'name': 'LCM SD v1.5', 'id': 'SimianLuo/LCM_Dreamshaper_v7', 'description': 'Latent Consistency 4-8 steps', 'speed': '⚡⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '2GB', 'category': 'speed', 'recommended': True},
# GENERAL PURPOSE
'stable-diffusion-v1-5': {'name': 'Stable Diffusion v1.5', 'id': 'runwayml/stable-diffusion-v1-5', 'description': 'Classic SD balanced', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '4GB', 'category': 'general', 'recommended': True},
'stable-diffusion-v2-1': {'name': 'Stable Diffusion v2.1', 'id': 'stabilityai/stable-diffusion-2-1', 'description': 'Improved v2.1', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '5GB', 'category': 'general', 'recommended': True},
'deliberate': {'name': 'Deliberate', 'id': 'XpucT/Deliberate', 'description': 'Versatile high-quality', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'general', 'recommended': True},
'dreamshaper': {'name': 'DreamShaper', 'id': 'Lykon/DreamShaper', 'description': 'Popular versatile', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'general', 'recommended': True},
'absolutereality': {'name': 'Absolute Reality', 'id': 'digiplay/AbsoluteReality_v1.8.1', 'description': 'Balanced realism', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'general', 'recommended': False},
# REALISTIC/PHOTOREALISTIC
'realistic-vision': {'name': 'Realistic Vision', 'id': 'SG161222/Realistic_Vision_V2.0', 'description': 'High-quality realistic', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'realistic', 'recommended': True},
'dreamlike-photoreal': {'name': 'Dreamlike Photoreal', 'id': 'dreamlike-art/dreamlike-photoreal-2.0', 'description': 'Photorealistic images', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'realistic', 'recommended': True},
'epicrealism': {'name': 'epiCRealism', 'id': 'emilianJR/epiCRealism', 'description': 'Epic photorealistic', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'realistic', 'recommended': False},
# ANIME/ILLUSTRATION
'anything-v5': {'name': 'Anything V5', 'id': 'stablediffusionapi/anything-v5', 'description': 'Latest anime model', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'anime', 'recommended': True},
'counterfeit': {'name': 'Counterfeit', 'id': 'gsdf/Counterfeit-V2.5', 'description': 'High-quality anime', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐⭐', 'size': '4GB', 'category': 'anime', 'recommended': True},
# ARTISTIC
'openjourney': {'name': 'OpenJourney', 'id': 'prompthero/openjourney', 'description': 'Midjourney-style artistic', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '4GB', 'category': 'artistic', 'recommended': True},
'van-gogh': {'name': 'Van Gogh Diffusion', 'id': 'dallinmackay/Van-Gogh-diffusion', 'description': 'Van Gogh painting style', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '2GB', 'category': 'artistic', 'recommended': False},
# 3D/CGI
'modelshoot': {'name': 'Modern Disney', 'id': 'nitrosocke/mo-di-diffusion', 'description': '3D Disney/Pixar style', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '4GB', 'category': '3d', 'recommended': True},
# FANTASY/SCI-FI
'scifi-diffusion': {'name': 'Sci-Fi Diffusion', 'id': 'stablediffusionapi/scifi-diffusion', 'description': 'Science fiction scenes', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '4GB', 'category': 'fantasy', 'recommended': True},
# SPECIAL STYLE
'ghibli-diffusion': {'name': 'Ghibli Diffusion', 'id': 'nitrosocke/Ghibli-Diffusion', 'description': 'Studio Ghibli art', 'speed': '⚡⚡', 'quality': '⭐⭐⭐⭐', 'size': '2GB', 'category': 'special', 'recommended': True},
}
# Image Processing Modules
IMAGE_MODULES = {
'text2img': {'name': 'Text to Image', 'icon': 'fa-font', 'description': 'Generate from text'},
'img2img': {'name': 'Image to Image', 'icon': 'fa-image', 'description': 'Transform existing images'},
'inpaint': {'name': 'Inpainting', 'icon': 'fa-paint-brush', 'description': 'Remove/replace objects'},
'upscale': {'name': 'Super Resolution', 'icon': 'fa-expand-arrows-alt', 'description': 'Upscale 2x-8x'},
'background-remove': {'name': 'Background Removal', 'icon': 'fa-cut', 'description': 'Remove background'},
'enhance': {'name': 'Face Enhancement', 'icon': 'fa-user-circle', 'description': 'Enhance faces'},
'restore': {'name': 'Image Restoration', 'icon': 'fa-magic', 'description': 'Restore old photos'},
'denoise': {'name': 'Denoise', 'icon': 'fa-adjust', 'description': 'Remove noise'},
'variation': {'name': 'Variations', 'icon': 'fa-random', 'description': 'Create variations'},
}
def load_history():
"""Load generation history"""
try:
if os.path.exists(HISTORY_FILE):
with open(HISTORY_FILE, 'r') as f:
return json.load(f)
return []
except Exception as e:
print(f"Error loading history: {e}")
return []
def save_history(history_item):
"""Save to history"""
try:
history = load_history()
history.insert(0, history_item)
history = history[:MAX_HISTORY_ITEMS]
os.makedirs(os.path.dirname(HISTORY_FILE) if os.path.dirname(HISTORY_FILE) else '.', exist_ok=True)
with open(HISTORY_FILE, 'w') as f:
json.dump(history, f, indent=2)
print(f"✓ Saved to history. Total: {len(history)}")
return True
except Exception as e:
print(f"Error saving history: {e}")
return False
def load_favorites():
"""Load favorite models"""
try:
if os.path.exists(FAVORITES_FILE):
with open(FAVORITES_FILE, 'r') as f:
return json.load(f)
return []
except Exception as e:
print(f"Error loading favorites: {e}")
return []
def save_favorites(favorites):
"""Save favorite models"""
try:
os.makedirs(os.path.dirname(FAVORITES_FILE) if os.path.dirname(FAVORITES_FILE) else '.', exist_ok=True)
with open(FAVORITES_FILE, 'w') as f:
json.dump(favorites, f, indent=2)
return True
except Exception as e:
print(f"Error saving favorites: {e}")
return False
def get_scheduler(scheduler_type, pipeline):
"""Get scheduler"""
schedulers = {
'lcm': LCMScheduler,
'dpm_single': DPMSolverSinglestepScheduler,
'dpm_multi': DPMSolverMultistepScheduler,
'euler': EulerDiscreteScheduler,
'euler_a': EulerAncestralDiscreteScheduler,
'ddim': DDIMScheduler,
}
scheduler_class = schedulers.get(scheduler_type, DPMSolverMultistepScheduler)
return scheduler_class.from_config(pipeline.scheduler.config)
def load_model(model_key='tiny-sd'):
"""Load AI model - CPU optimized with memory management"""
global pipelines, current_model
if model_key in pipelines:
print(f"Model {model_key} already loaded!")
current_model = model_key
return True
try:
model_info = AVAILABLE_MODELS.get(model_key)
if not model_info:
print(f"Model {model_key} not found!")
return False
# Clear other models to save memory - keep only one model loaded
if len(pipelines) > 0:
print("Clearing previous models to save memory...")
for key in list(pipelines.keys()):
del pipelines[key]
pipelines.clear()
import gc
gc.collect()
print(f"\n{'='*60}")
print(f"Loading: {model_info['name']}")
print(f"{'='*60}\n")
# Load only Text2Img pipeline initially - load others on demand
print("Loading Text2Img pipeline...")
pipeline = StableDiffusionPipeline.from_pretrained(
model_info['id'],
torch_dtype=torch.float32,
safety_checker=None,
requires_safety_checker=False,
low_cpu_mem_usage=True
)
pipeline = pipeline.to("cpu")
pipeline.enable_attention_slicing(1)
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config)
torch.set_num_threads(min(os.cpu_count(), 4)) # Limit threads to avoid overload
print("✓ Text2Img loaded")
# Create img2img from text2img components (saves memory)
print("Creating Img2Img pipeline from Text2Img components...")
img2img_pipeline = StableDiffusionImg2ImgPipeline(
vae=pipeline.vae,
text_encoder=pipeline.text_encoder,
tokenizer=pipeline.tokenizer,
unet=pipeline.unet,
scheduler=pipeline.scheduler,
safety_checker=None,
feature_extractor=pipeline.feature_extractor,
requires_safety_checker=False
)
print("✓ Img2Img created")
pipelines[model_key] = {
'text2img': pipeline,
'img2img': img2img_pipeline,
'info': model_info
}
current_model = model_key
print(f"\n✓ Model '{model_info['name']}' ready!\n")
return True
except Exception as e:
print(f"\n✗ Error loading model: {e}")
import traceback
traceback.print_exc()
return False
def upscale_image(image_data, scale=2):
"""Upscale image using advanced interpolation"""
try:
img_bytes = base64.b64decode(image_data)
nparr = np.frombuffer(img_bytes, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
height, width = img.shape[:2]
new_height = int(height * scale)
new_width = int(width * scale)
# Lanczos interpolation
upscaled = cv2.resize(img, (new_width, new_height), interpolation=cv2.INTER_LANCZOS4)
# Sharpening
kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
upscaled = cv2.filter2D(upscaled, -1, kernel)
# Enhance contrast
lab = cv2.cvtColor(upscaled, cv2.COLOR_BGR2LAB)
l, a, b = cv2.split(lab)
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
l = clahe.apply(l)
upscaled = cv2.merge([l, a, b])
upscaled = cv2.cvtColor(upscaled, cv2.COLOR_LAB2BGR)
_, buffer = cv2.imencode('.png', upscaled)
return base64.b64encode(buffer).decode()
except Exception as e:
print(f"Upscale error: {e}")
return None
def remove_background(image_data):
"""Remove background from image"""
try:
img_bytes = base64.b64decode(image_data)
input_img = Image.open(io.BytesIO(img_bytes))
# Remove background
output_img = remove(input_img)
buffered = io.BytesIO()
output_img.save(buffered, format="PNG")
return base64.b64encode(buffered.getvalue()).decode()
except Exception as e:
print(f"Background removal error: {e}")
return None
def denoise_image(image_data):
"""Denoise image"""
try:
img_bytes = base64.b64decode(image_data)
nparr = np.frombuffer(img_bytes, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
# Non-local means denoising
denoised = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 21)
_, buffer = cv2.imencode('.png', denoised)
return base64.b64encode(buffer).decode()
except Exception as e:
print(f"Denoise error: {e}")
return None
def restore_image(image_data):
"""Restore old/damaged images"""
try:
img_bytes = base64.b64decode(image_data)
nparr = np.frombuffer(img_bytes, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Denoise
denoised = restoration.denoise_tv_chambolle(img_gray, weight=0.1)
# Convert back to uint8
restored = (denoised * 255).astype(np.uint8)
restored = cv2.cvtColor(restored, cv2.COLOR_GRAY2BGR)
# Enhance
lab = cv2.cvtColor(restored, cv2.COLOR_BGR2LAB)
l, a, b = cv2.split(lab)
clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8,8))
l = clahe.apply(l)
restored = cv2.merge([l, a, b])
restored = cv2.cvtColor(restored, cv2.COLOR_LAB2BGR)
_, buffer = cv2.imencode('.png', restored)
return base64.b64encode(buffer).decode()
except Exception as e:
print(f"Restore error: {e}")
return None
# Enhanced HTML with Modern Improved UI
HTML_TEMPLATE = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quantum Canvas V1 Ultimate - AI Studio</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Poppins:wght@600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary: #6366f1;
--primary-light: #818cf8;
--primary-dark: #4f46e5;
--secondary: #ec4899;
--accent: #14b8a6;
--success: #10b981;
--warning: #f59e0b;
--error: #ef4444;
--dark-bg: #0a0e27;
--darker-bg: #050714;
--card-bg: rgba(20, 25, 45, 0.8);
--glass-bg: rgba(255, 255, 255, 0.05);
--border: rgba(255, 255, 255, 0.1);
--text-primary: #f1f5f9;
--text-secondary: #cbd5e1;
--text-tertiary: #94a3b8;
}
body.light-theme {
--dark-bg: #f1f5f9;
--darker-bg: #ffffff;
--card-bg: rgba(255, 255, 255, 0.9);
--glass-bg: rgba(0, 0, 0, 0.03);
--border: rgba(0, 0, 0, 0.1);
--text-primary: #0f172a;
--text-secondary: #475569;
--text-tertiary: #64748b;
}
body {
font-family: 'Inter', sans-serif;
background: var(--dark-bg);
color: var(--text-primary);
overflow-x: hidden;
}
/* Animated Background */
.bg-animation {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
overflow: hidden;
}
.bg-gradient {
position: absolute;
border-radius: 50%;
filter: blur(100px);
opacity: 0.4;
animation: float 25s ease-in-out infinite;
}
.bg-gradient-1 {
width: 700px;
height: 700px;
background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
top: -250px;
left: -250px;
}
.bg-gradient-2 {
width: 600px;
height: 600px;
background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
bottom: -200px;
right: -200px;
animation-delay: -8s;
}
.bg-gradient-3 {
width: 500px;
height: 500px;
background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
top: 50%;
left: 50%;
animation-delay: -15s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
33% { transform: translate(150px, -80px) scale(1.15) rotate(120deg); }
66% { transform: translate(-80px, 150px) scale(0.85) rotate(240deg); }
}
/* Container */
.app-container {
position: relative;
z-index: 1;
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* Header */
.header {
padding: 1.25rem 2.5rem;
background: var(--card-bg);
backdrop-filter: blur(30px);
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 100;
}
.logo {
display: flex;
align-items: center;
gap: 1.25rem;
}
.logo-icon {
width: 52px;
height: 52px;
background: linear-gradient(135deg, var(--primary), var(--secondary));
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
font-size: 26px;
box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5); }
50% { transform: scale(1.05); box-shadow: 0 12px 32px rgba(99, 102, 241, 0.7); }
}
.logo-text {
font-family: 'Poppins', sans-serif;
font-size: 1.75rem;
font-weight: 800;
background: linear-gradient(135deg, var(--primary), var(--secondary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
letter-spacing: -0.5px;
}
.badge {
padding: 5px 14px;
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
border-radius: 8px;
font-size: 0.65rem;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.5px;
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.header-actions {
display: flex;
gap: 1rem;
align-items: center;
}
.theme-toggle {
width: 45px;
height: 45px;
border-radius: 12px;
background: var(--glass-bg);
border: 1px solid var(--border);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
font-size: 1.2rem;
}
.theme-toggle:hover {
background: var(--primary);
color: white;
transform: scale(1.1) rotate(15deg);
box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}
/* Main Layout */
.main-layout {
display: grid;
grid-template-columns: 380px 1fr 320px;
gap: 1.5rem;
flex: 1;
padding: 2rem;
max-width: 1920px;
margin: 0 auto;
width: 100%;
}
.panel {
background: var(--card-bg);
backdrop-filter: blur(30px);
border: 1px solid var(--border);
border-radius: 20px;
padding: 2rem;
overflow-y: auto;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
/* Scrollbar */
.panel::-webkit-scrollbar {
width: 10px;
}
.panel::-webkit-scrollbar-track {
background: var(--glass-bg);
border-radius: 10px;
margin: 10px;
}
.panel::-webkit-scrollbar-thumb {
background: linear-gradient(180deg, var(--primary), var(--secondary));
border-radius: 10px;
border: 2px solid var(--card-bg);
}
.panel::-webkit-scrollbar-thumb:hover {
background: linear-gradient(180deg, var(--primary-light), var(--secondary));
}
/* Sections */
.section {
margin-bottom: 2.5rem;
}
.section:last-child {
margin-bottom: 0;
}
.section-title {
font-size: 0.95rem;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 1.5px;
margin-bottom: 1.25rem;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 0.75rem;
padding-bottom: 0.75rem;
border-bottom: 2px solid var(--border);
}
.section-title i {
font-size: 1.1rem;
color: var(--primary);
}
/* Module Tabs - Enhanced */
.module-tabs {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.75rem;
margin-bottom: 1.5rem;
}
.module-tab {
padding: 1rem 0.75rem;
background: var(--glass-bg);
border: 2px solid var(--border);
border-radius: 12px;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
text-align: center;
position: relative;
overflow: hidden;
}
.module-tab::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, var(--primary), var(--secondary));
opacity: 0;
transition: opacity 0.3s;
}
.module-tab:hover {
transform: translateY(-4px);
border-color: var(--primary);
box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}
.module-tab:hover::before {
opacity: 0.15;
}
.module-tab.active {
background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
border-color: var(--primary);
box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}
.module-tab.active::before {
opacity: 0.2;
}
.module-tab-content {
position: relative;
z-index: 1;
}
.module-tab i {
display: block;
font-size: 1.5rem;
margin-bottom: 0.5rem;
color: var(--primary);
}
.module-tab span {
font-size: 0.75rem;
font-weight: 700;
color: var(--text-primary);
}
/* Model Categories */
.model-categories {
display: flex;
gap: 0.5rem;
margin-bottom: 1rem;
flex-wrap: wrap;
}
.category-btn {
padding: 0.5rem 1rem;
background: var(--glass-bg);
border: 1px solid var(--border);
border-radius: 8px;
cursor: pointer;
transition: all 0.3s;
font-size: 0.8rem;
font-weight: 600;
color: var(--text-secondary);
}
.category-btn:hover {
background: var(--primary);
color: white;
border-color: var(--primary);
}
.category-btn.active {
background: var(--primary);
color: white;
border-color: var(--primary);
box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
/* Model Search */
.model-search {
position: relative;
margin-bottom: 1rem;
}
.model-search input {
width: 100%;
padding: 0.85rem 1rem 0.85rem 2.75rem;
background: var(--glass-bg);
border: 2px solid var(--border);
border-radius: 12px;
color: var(--text-primary);
font-family: 'Inter', sans-serif;
font-size: 0.9rem;
transition: all 0.3s;
}
.model-search input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
.model-search i {
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
color: var(--text-tertiary);
}
/* Model Grid - Enhanced */
.model-grid {
display: grid;
gap: 0.75rem;
max-height: 350px;
overflow-y: auto;
padding-right: 0.5rem;
}
.model-card {
padding: 1rem;
background: var(--glass-bg);
border: 2px solid var(--border);
border-radius: 12px;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
overflow: hidden;
}
.model-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 100%;
background: linear-gradient(180deg, var(--primary), var(--secondary));
transform: scaleY(0);
transition: transform 0.3s;
}
.model-card:hover {
border-color: var(--primary);
transform: translateX(4px);
box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}
.model-card:hover::before {
transform: scaleY(1);
}
.model-card.active {
background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.15));
border-color: var(--primary);
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.model-card.active::before {
transform: scaleY(1);
}
.model-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.model-name {
font-weight: 700;
font-size: 0.95rem;
color: var(--text-primary);
}
.favorite-btn {
background: none;
border: none;
cursor: pointer;
font-size: 1rem;
color: var(--text-tertiary);
transition: all 0.3s;
padding: 0.25rem;
}
.favorite-btn:hover {
color: var(--warning);
transform: scale(1.2);
}
.favorite-btn.active {
color: var(--warning);
}
.model-desc {
font-size: 0.8rem;
color: var(--text-tertiary);
margin-bottom: 0.5rem;
}
.model-meta {
display: flex;
gap: 1rem;
font-size: 0.75rem;
}
.model-meta span {
display: flex;
align-items: center;
gap: 0.25rem;
}
/* Input Groups - Enhanced */
.input-group {
margin-bottom: 1.5rem;
}
.input-label {
font-size: 0.9rem;
font-weight: 700;
margin-bottom: 0.75rem;
display: flex;
justify-content: space-between;
color: var(--text-primary);
}
.input-label-badge {
font-size: 0.8rem;
font-weight: 600;
padding: 0.25rem 0.75rem;
background: var(--primary);
color: white;
border-radius: 6px;
}
textarea, select, input[type="number"] {
width: 100%;
padding: 1rem;
background: var(--glass-bg);
border: 2px solid var(--border);
border-radius: 12px;
color: var(--text-primary);
font-family: 'Inter', sans-serif;
font-size: 0.9rem;
transition: all 0.3s;
}
textarea:focus, select:focus, input[type="number"]:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
textarea {
resize: vertical;
min-height: 100px;
}
input[type="range"] {
width: 100%;
height: 8px;
background: var(--glass-bg);
border-radius: 10px;
outline: none;
border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
appearance: none;
width: 20px;
height: 20px;
background: linear-gradient(135deg, var(--primary), var(--secondary));
border-radius: 50%;
cursor: pointer;
box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
transition: all 0.3s;
}
input[type="range"]::-webkit-slider-thumb:hover {
transform: scale(1.2);
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.6);
}
/* Buttons - Enhanced */
.btn {
padding: 1rem 1.75rem;
border: none;
border-radius: 12px;
font-weight: 700;
font-size: 0.95rem;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
align-items: center;
justify-content: center;
gap: 0.75rem;
position: relative;
overflow: hidden;
}
.btn::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
transform: translate(-50%, -50%);
transition: width 0.6s, height 0.6s;
}