muqtasid87 commited on
Commit
b05c339
Β·
verified Β·
1 Parent(s): 067fa6f
Files changed (1) hide show
  1. app.py +106 -0
app.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import app_qwen
3
+ import project.app_florence as app_florence
4
+ import project.app_combined as app_combined
5
+
6
+ # Set page configuration
7
+ st.set_page_config(
8
+ page_title="Vehicle Analysis Suite",
9
+ page_icon="πŸš—",
10
+ layout="wide",
11
+ initial_sidebar_state="expanded" # Show sidebar by default
12
+ )
13
+
14
+ # Custom CSS for the sidebar and main content
15
+ st.markdown("""
16
+ <style>
17
+ .block-container {padding-top: 1rem; padding-bottom: 0rem;}
18
+ .element-container {margin-bottom: 0.5rem;}
19
+ .stButton button {width: 100%;}
20
+ h1 {margin-bottom: 1rem;}
21
+ .sidebar-content {
22
+ padding: 1rem;
23
+ }
24
+ .app-header {
25
+ text-align: center;
26
+ padding: 1rem;
27
+ background-color: #f0f2f6;
28
+ border-radius: 0.5rem;
29
+ margin-bottom: 2rem;
30
+ }
31
+ </style>
32
+ """, unsafe_allow_html=True)
33
+
34
+ def main():
35
+ # Sidebar for app selection
36
+ with st.sidebar:
37
+ st.markdown("### πŸš— Vehicle Analysis Suite")
38
+ st.markdown("---")
39
+ app_mode = st.radio(
40
+ "Select Analysis Mode:",
41
+ ["Qwen2-VL Classifier", "Florence-2 Detector", "Combined Pipeline"],
42
+ index=0, # Default to Qwen2-VL
43
+ key="app_selection"
44
+ )
45
+
46
+ st.markdown("---")
47
+ st.markdown("""
48
+ ### About the Models:
49
+
50
+ **Qwen2-VL Classifier**
51
+ - Quick vehicle classification
52
+ - Single-word output
53
+ - Optimized for vehicle types
54
+
55
+ **Florence-2 Detector**
56
+ - Visual object detection
57
+ - Bounding box visualization
58
+ - Detailed spatial analysis
59
+
60
+ **Combined Pipeline**
61
+ - Two-stage analysis
62
+ - Classification + Detection
63
+ - Comprehensive results
64
+ """)
65
+
66
+ # Clear previous app states when switching
67
+ if 'last_app' not in st.session_state:
68
+ st.session_state.last_app = None
69
+
70
+ if st.session_state.last_app != app_mode:
71
+ # Clear relevant session state variables
72
+ for key in list(st.session_state.keys()):
73
+ if key not in ['app_selection', 'last_app']:
74
+ del st.session_state[key]
75
+ st.session_state.last_app = app_mode
76
+
77
+ # Main content area
78
+ if app_mode == "Qwen2-VL Classifier":
79
+ st.markdown("""
80
+ <div class='app-header'>
81
+ <h1>πŸ€– Qwen2-VL Vehicle Classifier</h1>
82
+ <p>Specialized in quick and accurate vehicle type classification</p>
83
+ </div>
84
+ """, unsafe_allow_html=True)
85
+ app_qwen.main()
86
+
87
+ elif app_mode == "Florence-2 Detector":
88
+ st.markdown("""
89
+ <div class='app-header'>
90
+ <h1>πŸ” Florence-2 Vehicle Detector</h1>
91
+ <p>Advanced visual detection with bounding box visualization</p>
92
+ </div>
93
+ """, unsafe_allow_html=True)
94
+ app_florence.main()
95
+
96
+ else: # Combined Pipeline
97
+ st.markdown("""
98
+ <div class='app-header'>
99
+ <h1>πŸš€ Combined Analysis Pipeline</h1>
100
+ <p>Comprehensive vehicle analysis using both models</p>
101
+ </div>
102
+ """, unsafe_allow_html=True)
103
+ app_combined.main()
104
+
105
+ if __name__ == "__main__":
106
+ main()