qwerty45-uiop commited on
Commit
1384952
Β·
verified Β·
1 Parent(s): e4021dd

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +55 -77
src/streamlit_app.py CHANGED
@@ -12,11 +12,8 @@ import numpy as np
12
  import re
13
  import plotly.express as px
14
  import plotly.graph_objects as go
15
- from plotly.subplots import make_subplots
16
- from typing import Optional, Tuple, List, Dict, Any
17
  import json
18
- from datetime import datetime, timedelta
19
- import time
20
 
21
  # βœ… MUST be the first Streamlit command
22
  st.set_page_config(
@@ -25,60 +22,6 @@ st.set_page_config(
25
  page_icon="🧠",
26
  initial_sidebar_state="expanded"
27
  )
28
- # Custom CSS for better styling
29
- st.markdown("""
30
- <style>
31
- .main-header {
32
- font-size: 3rem;
33
- font-weight: bold;
34
- text-align: center;
35
- background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
36
- -webkit-background-clip: text;
37
- -webkit-text-fill-color: transparent;
38
- margin-bottom: 2rem;
39
- }
40
- .metric-card {
41
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
42
- padding: 1rem;
43
- border-radius: 10px;
44
- color: white;
45
- margin: 0.5rem 0;
46
- }
47
- .model-card {
48
- border: 2px solid #e0e0e0;
49
- border-radius: 10px;
50
- padding: 1rem;
51
- margin: 0.5rem 0;
52
- background: white;
53
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
54
- }
55
- .performance-badge {
56
- padding: 0.25rem 0.5rem;
57
- border-radius: 15px;
58
- font-size: 0.8rem;
59
- font-weight: bold;
60
- color: white;
61
- }
62
- .badge-ultra-high { background: #8B5CF6; }
63
- .badge-high { background: #3B82F6; }
64
- .badge-good { background: #10B981; }
65
- .badge-moderate { background: #F59E0B; }
66
- .badge-low { background: #EF4444; }
67
- .badge-ultra-low { background: #6B7280; }
68
- .stTabs [data-baseweb="tab-list"] {
69
- gap: 2px;
70
- }
71
- .stTabs [data-baseweb="tab"] {
72
- height: 50px;
73
- padding-left: 20px;
74
- padding-right: 20px;
75
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
76
- border-radius: 10px 10px 0 0;
77
- color: white;
78
- font-weight: bold;
79
- }
80
- </style>
81
- """, unsafe_allow_html=True)
82
 
83
  # Enhanced data loading with error handling
84
  @st.cache_data
@@ -130,14 +73,42 @@ def extract_numeric_ram(ram) -> Optional[int]:
130
 
131
  # Quantization options and size calculations
132
  QUANTIZATION_FORMATS = {
133
- "FP16": {"multiplier": 1.0, "description": "Full precision, best quality", "icon": "πŸ”₯"},
134
- "8-bit": {"multiplier": 0.5, "description": "50% smaller, good quality", "icon": "⚑"},
135
- "4-bit": {"multiplier": 0.25, "description": "75% smaller, acceptable quality", "icon": "πŸ’Ž"},
136
- "2-bit": {"multiplier": 0.125, "description": "87.5% smaller, experimental", "icon": "πŸ§ͺ"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
 
139
  def calculate_quantized_size(base_size_str, quant_format):
140
- """Calculate quantized model size"""
141
  size_match = re.search(r'(\d+\.?\d*)', base_size_str)
142
  if not size_match:
143
  return base_size_str
@@ -148,7 +119,13 @@ def calculate_quantized_size(base_size_str, quant_format):
148
  multiplier = QUANTIZATION_FORMATS[quant_format]["multiplier"]
149
  new_size = base_size * multiplier
150
 
151
- return f"{new_size:.1f}{unit}"
 
 
 
 
 
 
152
 
153
  # Enhanced LLM database with more models and metadata
154
  LLM_DATABASE = {
@@ -271,20 +248,21 @@ LLM_DATABASE = {
271
  }
272
 
273
  # GPU compatibility database
 
274
  GPU_DATABASE = {
275
- "RTX 3060": {"vram": 8, "performance": "mid", "architecture": "Ampere"},
276
- "RTX 3070": {"vram": 8, "performance": "high", "architecture": "Ampere"},
277
- "RTX 3080": {"vram": 10, "performance": "high", "architecture": "Ampere"},
278
- "RTX 3090": {"vram": 24, "performance": "ultra", "architecture": "Ampere"},
279
- "RTX 4060": {"vram": 8, "performance": "mid", "architecture": "Ada Lovelace"},
280
- "RTX 4070": {"vram": 12, "performance": "high", "architecture": "Ada Lovelace"},
281
- "RTX 4080": {"vram": 16, "performance": "ultra", "architecture": "Ada Lovelace"},
282
- "RTX 4090": {"vram": 24, "performance": "ultra", "architecture": "Ada Lovelace"},
283
- "Apple M1": {"vram": 8, "performance": "mid", "architecture": "Apple Silicon"},
284
- "Apple M2": {"vram": 16, "performance": "high", "architecture": "Apple Silicon"},
285
- "Apple M3": {"vram": 24, "performance": "ultra", "architecture": "Apple Silicon"},
286
- "RX 6700 XT": {"vram": 12, "performance": "mid", "architecture": "RDNA 2"},
287
- "RX 7900 XTX": {"vram": 24, "performance": "ultra", "architecture": "RDNA 3"},
288
  }
289
 
290
  def get_gpu_recommendations(gpu_name, ram_gb):
 
12
  import re
13
  import plotly.express as px
14
  import plotly.graph_objects as go
15
+ from typing import Optional, Tuple, List, Dict
 
16
  import json
 
 
17
 
18
  # βœ… MUST be the first Streamlit command
19
  st.set_page_config(
 
22
  page_icon="🧠",
23
  initial_sidebar_state="expanded"
24
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  # Enhanced data loading with error handling
27
  @st.cache_data
 
73
 
74
  # Quantization options and size calculations
75
  QUANTIZATION_FORMATS = {
76
+ "FP16": {
77
+ "multiplier": 1.0,
78
+ "description": "Full precision, best quality",
79
+ "icon": "πŸ”₯",
80
+ "quality": "Excellent",
81
+ "speed": "Moderate",
82
+ "memory_efficiency": "Low"
83
+ },
84
+ "8-bit": {
85
+ "multiplier": 0.5,
86
+ "description": "50% smaller, good quality",
87
+ "icon": "⚑",
88
+ "quality": "Very Good",
89
+ "speed": "Good",
90
+ "memory_efficiency": "Good"
91
+ },
92
+ "4-bit": {
93
+ "multiplier": 0.25,
94
+ "description": "75% smaller, acceptable quality",
95
+ "icon": "πŸ’Ž",
96
+ "quality": "Good",
97
+ "speed": "Very Good",
98
+ "memory_efficiency": "Excellent"
99
+ },
100
+ "2-bit": {
101
+ "multiplier": 0.125,
102
+ "description": "87.5% smaller, experimental",
103
+ "icon": "πŸ§ͺ",
104
+ "quality": "Fair",
105
+ "speed": "Excellent",
106
+ "memory_efficiency": "Outstanding"
107
+ }
108
  }
109
 
110
  def calculate_quantized_size(base_size_str, quant_format):
111
+ """Calculate quantized model size with better formatting"""
112
  size_match = re.search(r'(\d+\.?\d*)', base_size_str)
113
  if not size_match:
114
  return base_size_str
 
119
  multiplier = QUANTIZATION_FORMATS[quant_format]["multiplier"]
120
  new_size = base_size * multiplier
121
 
122
+ # Smart unit conversion
123
+ if unit.upper() == "GB" and new_size < 1:
124
+ return f"{new_size * 1024:.0f}MB"
125
+ elif unit.upper() == "MB" and new_size > 1024:
126
+ return f"{new_size / 1024:.1f}GB"
127
+ else:
128
+ return f"{new_size:.1f}{unit}"
129
 
130
  # Enhanced LLM database with more models and metadata
131
  LLM_DATABASE = {
 
248
  }
249
 
250
  # GPU compatibility database
251
+ # Enhanced GPU compatibility database with more details
252
  GPU_DATABASE = {
253
+ "RTX 3060": {"vram": 8, "performance": "mid", "architecture": "Ampere", "tensor_cores": "2nd gen", "memory_bandwidth": "360 GB/s"},
254
+ "RTX 3070": {"vram": 8, "performance": "high", "architecture": "Ampere", "tensor_cores": "2nd gen", "memory_bandwidth": "448 GB/s"},
255
+ "RTX 3080": {"vram": 10, "performance": "high", "architecture": "Ampere", "tensor_cores": "2nd gen", "memory_bandwidth": "760 GB/s"},
256
+ "RTX 3090": {"vram": 24, "performance": "ultra", "architecture": "Ampere", "tensor_cores": "2nd gen", "memory_bandwidth": "936 GB/s"},
257
+ "RTX 4060": {"vram": 8, "performance": "mid", "architecture": "Ada Lovelace", "tensor_cores": "4th gen", "memory_bandwidth": "272 GB/s"},
258
+ "RTX 4070": {"vram": 12, "performance": "high", "architecture": "Ada Lovelace", "tensor_cores": "4th gen", "memory_bandwidth": "504 GB/s"},
259
+ "RTX 4080": {"vram": 16, "performance": "ultra", "architecture": "Ada Lovelace", "tensor_cores": "4th gen", "memory_bandwidth": "716 GB/s"},
260
+ "RTX 4090": {"vram": 24, "performance": "ultra", "architecture": "Ada Lovelace", "tensor_cores": "4th gen", "memory_bandwidth": "1008 GB/s"},
261
+ "Apple M1": {"vram": 8, "performance": "mid", "architecture": "Apple Silicon", "tensor_cores": "None", "memory_bandwidth": "68.25 GB/s"},
262
+ "Apple M2": {"vram": 16, "performance": "high", "architecture": "Apple Silicon", "tensor_cores": "None", "memory_bandwidth": "100 GB/s"},
263
+ "Apple M3": {"vram": 24, "performance": "ultra", "architecture": "Apple Silicon", "tensor_cores": "None", "memory_bandwidth": "150 GB/s"},
264
+ "RX 6700 XT": {"vram": 12, "performance": "mid", "architecture": "RDNA 2", "tensor_cores": "None", "memory_bandwidth": "384 GB/s"},
265
+ "RX 7900 XTX": {"vram": 24, "performance": "ultra", "architecture": "RDNA 3", "tensor_cores": "None", "memory_bandwidth": "960 GB/s"},
266
  }
267
 
268
  def get_gpu_recommendations(gpu_name, ram_gb):