import streamlit as st import tensorflow as tf from tensorflow.keras.preprocessing import image import numpy as np import matplotlib.pyplot as plt from PIL import Image # Streamlit app st.title("Deep Learning for Military Aircraft Recognition in Satellite Imagery") # Load the model model = tf.keras.models.load_model( "MilSat224.keras", compile=False, safe_mode=False ) # Create a mapping for class indices to class names class_indices = { 0: 'A-10', 1: 'B-1', 2: 'B-2', 3: 'B-52', 4: 'Bareland', 5: 'C-130', 6: 'K/C-135', 7: 'C-17', 8: 'C-5', 9: 'E-3', 10: 'KC-10', } ################################################################# ellsworth = """ """ macdill = """ """ whiteman = """ """ elmendorf = """ """ minot = """ """ ramstein = """ """ mcguire = """ """ ####################### eielson = """ """ beale = """ """ edwards = """ """ vandenberg = """ """ andrews = """ """ cannon = """ """ altus = """ """ andersen = """ """ col4 = st.columns(1) with col4[0]: st.subheader("Aircraft Types Included in Model Training:") st.markdown(""" - A-10 - B-1 - B-2 - B-52 - C-130 - K/C-135 - K/C-10 - C-17 - C-5 - E-3 - Bare Terrain """) st.subheader("Detailed Workflow:") st.write("1. Select an available base from the dropdown menu or navigate to a base using google maps") st.write("2. Identify a suitable aircraft parked on the ramp") st.write("3. Use a capture tool to screenshot a satellite image of selected singular aircraft") st.write("4. Upload your captured image") st.write("5. View model prediction of aircraft type") selected_base = st.selectbox("Select a base to view satellite imagery:", ["Ellsworth AFB","MacDill AFB","Whiteman AFB", "Elmendorf AFB","Minot AFB","Ramstein AB", "McGuire AFB","Eielson AFB","Beale AFB", "Edwards AFB","Vandenberg AFB","Andrews AFB", "Cannon AFB","Altus AFB","Andersen (Guam)"]) # Display the selected map if selected_base == "Ellsworth AFB": st.markdown(ellsworth, unsafe_allow_html=True) elif selected_base == "MacDill AFB": st.markdown(macdill, unsafe_allow_html=True) elif selected_base == "Whiteman AFB": st.markdown(whiteman, unsafe_allow_html=True) elif selected_base == "Elmendorf AFB": st.markdown(elmendorf, unsafe_allow_html=True) elif selected_base == "Minot AFB": st.markdown(minot, unsafe_allow_html=True) elif selected_base == "Ramstein AB": st.markdown(ramstein, unsafe_allow_html=True) elif selected_base == "McGuire AFB": st.markdown(mcguire, unsafe_allow_html=True) elif selected_base == "Eielson AFB": st.markdown(eielson, unsafe_allow_html=True) elif selected_base == "Beale AFB": st.markdown(beale, unsafe_allow_html=True) elif selected_base == "Edwards AFB": st.markdown(edwards, unsafe_allow_html=True) elif selected_base == "Vandenberg AFB": st.markdown(vandenberg, unsafe_allow_html=True) elif selected_base == "Andrews AFB": st.markdown(andrews, unsafe_allow_html=True) elif selected_base == "Cannon AFB": st.markdown(cannon, unsafe_allow_html=True) elif selected_base == "Altus AFB": st.markdown(altus, unsafe_allow_html=True) elif selected_base == "Andersen (Guam)": st.markdown(andersen, unsafe_allow_html=True) # Upload image uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Open and display the uploaded image img = Image.open(uploaded_file).convert("RGB") st.image(img, caption='Uploaded Image', width=300) # Preprocess the image img = img.resize((224, 224)) # Resize to 224x224 img_array = image.img_to_array(img) # Convert to array img_array = np.expand_dims(img_array, axis=0) # Expand dimensions img_array /= 255.0 # Normalize if needed # Make prediction predictions = model.predict(img_array) predicted_class_index = np.argmax(predictions, axis=1)[0] predicted_class_name = class_indices.get(predicted_class_index, "Unknown Class") # Display the result st.metric("Predicted Aircraft:", predicted_class_name)