AI-Enthusiast11 commited on
Commit
d9a88ad
·
verified ·
1 Parent(s): 6e73edb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from image_classification import classify_image # Import from image_classification.py
3
+
4
+ # Title and description for your app
5
+ st.title("Image Classifier")
6
+ st.write("This app classifies uploaded images using a pre-trained TensorFlow model.")
7
+
8
+ # Allow users to upload an image
9
+ uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])
10
+
11
+ if uploaded_image is not None:
12
+ # Convert uploaded image to a format suitable for classification
13
+ image = cv2.imdecode(np.frombuffer(uploaded_image.read(), np.uint8), cv2.IMREAD_COLOR) # Assuming OpenCV is used for conversion
14
+
15
+ # Perform classification using your function
16
+ try:
17
+ predicted_label, probability = classify_image(image)
18
+ st.write("Classified as:")
19
+ st.write(f"- {predicted_label}: {probability:.4f}")
20
+ except Exception as e: # Catch potential errors during classification
21
+ st.error(f"Error during classification: {e}")
22
+ else:
23
+ st.write("Upload an image to classify it.")