create app that detects cloud components in the uploaded architecture diagram
To upload files, please first save the app
import streamlit as st
import tensorflow as tf
from PIL import Image
import numpy as np
# Set page title
st.title("Cloud Architecture Component Detector")
# Add description
st.write("""
Upload an architecture diagram and this app will attempt to detect cloud components in it.
The model is trained to recognize common cloud architecture components like:
- Servers/VMs
- Databases
- Storage
- Load Balancers
- Containers
""")
# File uploader
uploaded_file = st.file_uploader("Choose an architecture diagram...", type=['png', 'jpg', 'jpeg'])
if uploaded_file is not None:
# Display the uploaded image
image = Image.open(uploaded_file)
st.image(image, caption='Uploaded Architecture Diagram', use_column_width=True)
# Add processing button
if st.button('Detect Components'):
# Show processing message
with st.spinner('Processing image...'):
try:
# Prepare the image
img = image.resize((224, 224)) # Resize to model input size
img_array = np.array(img)
img_array = img_array / 255.0 # Normalize
img_array = np.expand_dims(img_array, axis=0)
# For demo purposes, we'll simulate detections
# In a real app, you would:
# 1. Load a trained model
# 2. Run inference on the image
# 3. Process the results
# Simulated detections
detections = {
"VM/Server": 0.92,
"Database": 0.85,
"Storage": 0.78,
"Load Balancer": 0.65,
"Container": 0.89
}
# Display results
st.subheader("Detected Components:")
for component, confidence in detections.items():
st.write(f"{component}: {confidence*100:.1f}% confidence")
# Add some visual flair for successful processing
st.success("Processing complete!")
st.balloons()
except Exception as e:
st.error(f"Error processing image: {str(e)}")
# Add usage instructions
st.markdown("""
### Instructions:
1. Upload an architecture diagram in PNG, JPG, or JPEG format
2. Click 'Detect Components' to analyze the image
3. View the detected components and their confidence scores
### Note:
This is a demo application. In a production environment, you would need:
- A properly trained deep learning model
- More robust image processing
- Additional component types
- Proper error handling
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?