Spaces:
Runtime error
Runtime error
Commit ·
67d3aa0
1
Parent(s): 523a6d5
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
-
from keras.preprocessing import image
|
| 4 |
from keras.models import load_model
|
| 5 |
|
| 6 |
|
|
@@ -32,14 +32,24 @@ def predict_breed(image_file):
|
|
| 32 |
def main():
|
| 33 |
st.title('Dog Breed Classification')
|
| 34 |
uploaded_file = st.file_uploader('Choose an image of a dog', type=['jpg', 'jpeg', 'png'])
|
| 35 |
-
|
| 36 |
if uploaded_file is not None:
|
| 37 |
image_file = uploaded_file.name
|
| 38 |
with open(image_file, 'wb') as f:
|
| 39 |
f.write(uploaded_file.getbuffer())
|
| 40 |
predicted_class = predict_breed(image_file)
|
| 41 |
st.image(uploaded_file, caption=f'Predicted class: {predicted_class}', use_column_width=True)
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
if __name__ == '__main__':
|
| 45 |
main()
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
+
from tensorflow.keras.preprocessing import image
|
| 4 |
from keras.models import load_model
|
| 5 |
|
| 6 |
|
|
|
|
| 32 |
def main():
|
| 33 |
st.title('Dog Breed Classification')
|
| 34 |
uploaded_file = st.file_uploader('Choose an image of a dog', type=['jpg', 'jpeg', 'png'])
|
|
|
|
| 35 |
if uploaded_file is not None:
|
| 36 |
image_file = uploaded_file.name
|
| 37 |
with open(image_file, 'wb') as f:
|
| 38 |
f.write(uploaded_file.getbuffer())
|
| 39 |
predicted_class = predict_breed(image_file)
|
| 40 |
st.image(uploaded_file, caption=f'Predicted class: {predicted_class}', use_column_width=True)
|
| 41 |
+
|
| 42 |
+
# Add a button to trigger image upload
|
| 43 |
+
if st.button('Upload Image'):
|
| 44 |
+
uploaded_file = st.file_uploader('Choose an image of a dog', type=['jpg', 'jpeg', 'png'])
|
| 45 |
+
if uploaded_file is not None:
|
| 46 |
+
image_file = uploaded_file.name
|
| 47 |
+
with open(image_file, 'wb') as f:
|
| 48 |
+
f.write(uploaded_file.getbuffer())
|
| 49 |
+
predicted_class = predict_breed(image_file)
|
| 50 |
+
st.image(uploaded_file, caption=f'Predicted class: {predicted_class}', use_column_width=True)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
if __name__ == '__main__':
|
| 54 |
main()
|
| 55 |
+
|