Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,67 +1,67 @@
|
|
1 |
-
# import streamlit as st
|
2 |
-
# import train
|
3 |
-
# # import tr
|
4 |
-
# # import prd
|
5 |
-
# x = st.slider('Select a value')
|
6 |
-
# st.write(x, 'squared is', x * 86)
|
7 |
-
# st.write(x, 'squared is', x * 86)
|
8 |
-
|
9 |
import streamlit as st
|
10 |
-
import
|
11 |
-
import
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
model = from_pretrained_keras("okeowo1014/catsanddogsmodel")
|
17 |
|
18 |
-
# Load the saved model (replace with your model filename)
|
19 |
-
# model = tf.keras.models.load_model('cat_dog_classifier.keras')
|
20 |
|
21 |
-
# Image dimensions for the model
|
22 |
-
img_width, img_height = 224, 224
|
23 |
|
24 |
|
25 |
-
def preprocess_image(img):
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
|
33 |
-
def predict_class(image):
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
|
41 |
-
def display_results(class_name, probability):
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
|
54 |
-
def main():
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import train
|
3 |
+
# import tr
|
4 |
+
# import prd
|
5 |
+
x = st.slider('Select a value')
|
6 |
+
st.write(x, 'squared is', x * 86)
|
7 |
+
st.write(x, 'squared is', x * 86)
|
8 |
+
|
9 |
+
# import streamlit as st
|
10 |
+
# import cv2
|
11 |
+
# import numpy as np
|
12 |
+
# from tensorflow.keras.preprocessing import image
|
13 |
+
# import tensorflow as tf
|
14 |
+
# from huggingface_hub import from_pretrained_keras
|
15 |
|
16 |
+
# model = from_pretrained_keras("okeowo1014/catsanddogsmodel")
|
17 |
|
18 |
+
# # Load the saved model (replace with your model filename)
|
19 |
+
# # model = tf.keras.models.load_model('cat_dog_classifier.keras')
|
20 |
|
21 |
+
# # Image dimensions for the model
|
22 |
+
# img_width, img_height = 224, 224
|
23 |
|
24 |
|
25 |
+
# def preprocess_image(img):
|
26 |
+
# """Preprocesses an image for prediction."""
|
27 |
+
# img = cv2.resize(img, (img_width, img_height))
|
28 |
+
# img = img.astype('float32') / 255.0
|
29 |
+
# img = np.expand_dims(img, axis=0)
|
30 |
+
# return img
|
31 |
|
32 |
|
33 |
+
# def predict_class(image):
|
34 |
+
# """Predicts image class and probabilities."""
|
35 |
+
# preprocessed_img = preprocess_image(image)
|
36 |
+
# prediction = model.predict(preprocessed_img)
|
37 |
+
# class_names = ['cat', 'dog'] # Adjust class names according to your model
|
38 |
+
# return class_names[np.argmax(prediction)], np.max(prediction)
|
39 |
|
40 |
|
41 |
+
# def display_results(class_name, probability):
|
42 |
+
# """Displays prediction results in a progress bar style."""
|
43 |
+
# st.write(f"**Predicted Class:** {class_name}")
|
44 |
|
45 |
+
# # Create a progress bar using st.progress
|
46 |
+
# progress = st.progress(0)
|
47 |
+
# for i in range(100):
|
48 |
+
# progress.progress(i + 1)
|
49 |
+
# if i == int(probability * 100):
|
50 |
+
# break
|
51 |
+
# st.write(f"**Probability:** {probability:.2f}")
|
52 |
|
53 |
|
54 |
+
# def main():
|
55 |
+
# """Main app function."""
|
56 |
+
# st.title("Image Classifier")
|
57 |
+
# st.write("Upload an image to classify it as cat or dog.")
|
58 |
|
59 |
+
# uploaded_file = st.file_uploader("Choose an image...", type="jpg")
|
60 |
+
# if uploaded_file is not None:
|
61 |
+
# image = cv2.imdecode(np.frombuffer(uploaded_file.read(), np.uint8), cv2.IMREAD_COLOR)
|
62 |
+
# st.image(image, caption="Uploaded Image", use_column_width=True)
|
63 |
|
64 |
+
# predicted_class, probability = predict_class(image)
|
65 |
+
# display_results(predicted_class, probability)
|
66 |
|
67 |
+
# main()
|