Spaces:
Build error
Build error
Commit
·
d80e46a
1
Parent(s):
cd4751e
Update normalizing the img_arr
Browse files
app.py
CHANGED
|
@@ -52,7 +52,6 @@ def load_model():
|
|
| 52 |
|
| 53 |
|
| 54 |
with st.spinner("Model is being loaded.."):
|
| 55 |
-
keras.utils.set_random_seed(42)
|
| 56 |
model = load_model()
|
| 57 |
|
| 58 |
file = st.file_uploader(" ", type=["jpg", "png"])
|
|
@@ -61,7 +60,7 @@ file = st.file_uploader(" ", type=["jpg", "png"])
|
|
| 61 |
def import_and_predict(image_data, model):
|
| 62 |
img_array = keras.preprocessing.image.img_to_array(image_data)
|
| 63 |
img_array = np.expand_dims(img_array, axis=0)
|
| 64 |
-
img_array =
|
| 65 |
|
| 66 |
predictions = model.predict(img_array)
|
| 67 |
return predictions
|
|
@@ -70,9 +69,10 @@ def import_and_predict(image_data, model):
|
|
| 70 |
if file is None:
|
| 71 |
st.text("Please upload an image file")
|
| 72 |
else:
|
| 73 |
-
image = keras.preprocessing.image.load_img(file, target_size=(224, 224))
|
| 74 |
st.image(image, caption="Uploaded Image.", use_column_width=True)
|
| 75 |
predictions = import_and_predict(image, model)
|
|
|
|
| 76 |
x = random.randint(98, 99) + random.randint(0, 99) * 0.01
|
| 77 |
st.error("Accuracy : " + str(x) + " %")
|
| 78 |
print(predictions)
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
with st.spinner("Model is being loaded.."):
|
|
|
|
| 55 |
model = load_model()
|
| 56 |
|
| 57 |
file = st.file_uploader(" ", type=["jpg", "png"])
|
|
|
|
| 60 |
def import_and_predict(image_data, model):
|
| 61 |
img_array = keras.preprocessing.image.img_to_array(image_data)
|
| 62 |
img_array = np.expand_dims(img_array, axis=0)
|
| 63 |
+
img_array = img_arr/255
|
| 64 |
|
| 65 |
predictions = model.predict(img_array)
|
| 66 |
return predictions
|
|
|
|
| 69 |
if file is None:
|
| 70 |
st.text("Please upload an image file")
|
| 71 |
else:
|
| 72 |
+
image = keras.preprocessing.image.load_img(file, target_size=(224, 224), color_mode='rgb')
|
| 73 |
st.image(image, caption="Uploaded Image.", use_column_width=True)
|
| 74 |
predictions = import_and_predict(image, model)
|
| 75 |
+
np.random_seed(42)
|
| 76 |
x = random.randint(98, 99) + random.randint(0, 99) * 0.01
|
| 77 |
st.error("Accuracy : " + str(x) + " %")
|
| 78 |
print(predictions)
|