m7mdal7aj commited on
Commit
42aac8e
1 Parent(s): e57843e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -13
app.py CHANGED
@@ -104,23 +104,54 @@ def image_qa_app(kbvqa):
104
  def run_inference():
105
  st.title("Run Inference")
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  # Initialize session state for the model
108
- if 'kbvqa' not in st.session_state:
109
- st.session_state['kbvqa'] = None
110
-
111
- # Button to load KBVQA models
112
- if st.button('Load KBVQA Model'):
113
- if st.session_state['kbvqa'] is not None:
114
- st.write("Model already loaded.")
115
- else:
116
- # Call the function to load models and show progress
117
- st.session_state['kbvqa'] = prepare_kbvqa_model('yolov5') # Replace with your model
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  if st.session_state['kbvqa']:
120
- st.write("Model is ready for inference.")
121
 
122
- if st.session_state['kbvqa']:
123
- image_qa_app(st.session_state['kbvqa'])
124
 
125
 
126
  # Main function
 
104
  def run_inference():
105
  st.title("Run Inference")
106
 
107
+ method = st.selectbox(
108
+ "Choose a method:",
109
+ ["Fine-Tuned Model", "In-Context Learning (n-shots)"],
110
+ index=0 # Default to the first option
111
+ )
112
+
113
+ detection_model = st.selectbox(
114
+ "Choose a model for object detection:",
115
+ ["yolov5", "detic"],
116
+ index=0 # Default to the first option
117
+ )
118
+
119
+ # Set default confidence based on the selected model
120
+ default_confidence = 0.2 if detection_model == "yolov5" else 0.4
121
+
122
+ # Slider for confidence level
123
+ confidence_level = st.slider(
124
+ "Select Detection Confidence Level",
125
+ min_value=0.1,
126
+ max_value=0.9,
127
+ value=default_confidence,
128
+ step=0.1
129
+ )
130
+
131
+
132
+
133
  # Initialize session state for the model
 
 
 
 
 
 
 
 
 
 
134
 
135
+ if method == "Fine-Tuned Model"
136
+ if 'kbvqa' not in st.session_state:
137
+ st.session_state['kbvqa'] = None
138
+
139
+ # Button to load KBVQA models
140
+ if st.button('Load KBVQA Model'):
141
+ if st.session_state['kbvqa'] is not None:
142
+ st.write("Model already loaded.")
143
+ else:
144
+ # Call the function to load models and show progress
145
+ st.session_state['kbvqa'] = prepare_kbvqa_model(detection_model)
146
+
147
+ if st.session_state['kbvqa']:
148
+ st.write("Model is ready for inference.")
149
+
150
  if st.session_state['kbvqa']:
151
+ image_qa_app(st.session_state['kbvqa'])
152
 
153
+ else:
154
+ st.write('Model is not ready for inference yet')
155
 
156
 
157
  # Main function