Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,17 +31,27 @@ sample_images = ["Files/sample1.jpg", "Files/sample2.jpg", "Files/sample3.jpg",
|
|
31 |
def run_inference():
|
32 |
st.title("Run Inference")
|
33 |
|
|
|
|
|
|
|
|
|
34 |
# Button to load KBVQA models
|
35 |
if st.button('Load KBVQA Models'):
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
|
39 |
-
if kbvqa:
|
40 |
st.write("Model is ready for inference.")
|
41 |
-
image_qa_app(kbvqa)
|
42 |
else:
|
43 |
st.write("Please load the model first")
|
44 |
|
|
|
|
|
|
|
|
|
45 |
|
46 |
def image_qa_app(kbvqa):
|
47 |
# Initialize session state for storing the current image and its Q&A history
|
@@ -123,4 +133,4 @@ def main():
|
|
123 |
run_object_detection()
|
124 |
|
125 |
if __name__ == "__main__":
|
126 |
-
main()
|
|
|
31 |
def run_inference():
|
32 |
st.title("Run Inference")
|
33 |
|
34 |
+
# Initialize session state for the model
|
35 |
+
if 'kbvqa' not in st.session_state:
|
36 |
+
st.session_state['kbvqa'] = None
|
37 |
+
|
38 |
# Button to load KBVQA models
|
39 |
if st.button('Load KBVQA Models'):
|
40 |
+
if st.session_state['kbvqa'] is not None:
|
41 |
+
st.write("Model already loaded.")
|
42 |
+
else:
|
43 |
+
# Call the function to load models and show progress
|
44 |
+
st.session_state['kbvqa'] = prepare_kbvqa_model('yolov5') # Replace with your model
|
45 |
|
46 |
+
if st.session_state['kbvqa']:
|
47 |
st.write("Model is ready for inference.")
|
|
|
48 |
else:
|
49 |
st.write("Please load the model first")
|
50 |
|
51 |
+
if st.session_state['kbvqa']:
|
52 |
+
image_qa_app(st.session_state['kbvqa'])
|
53 |
+
|
54 |
+
|
55 |
|
56 |
def image_qa_app(kbvqa):
|
57 |
# Initialize session state for storing the current image and its Q&A history
|
|
|
133 |
run_object_detection()
|
134 |
|
135 |
if __name__ == "__main__":
|
136 |
+
main()
|