Aryan-EcoClim commited on
Commit
54c78cd
·
1 Parent(s): 324e51f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -63,7 +63,7 @@ elif mode == "Train Mode":
63
  st.header("Train the model with a new image and label")
64
 
65
  # Image upload section
66
- file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
67
  if file:
68
  try:
69
  image = preprocess_image(file)
@@ -77,7 +77,14 @@ elif mode == "Train Mode":
77
  # Update the model with the user-provided image and label
78
  target = np.zeros(len(labels))
79
  target[labels.index(user_label)] = 1
80
- tf.train.batch(image, target)
 
 
 
 
 
 
 
81
  st.success(f'Model has been trained with the new image and label.')
82
  except Exception as e:
83
- st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
 
63
  st.header("Train the model with a new image and label")
64
 
65
  # Image upload section
66
+ file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
67
  if file:
68
  try:
69
  image = preprocess_image(file)
 
77
  # Update the model with the user-provided image and label
78
  target = np.zeros(len(labels))
79
  target[labels.index(user_label)] = 1
80
+
81
+ # Reshape the image to match the model's input shape
82
+ image = tf.image.resize(image, (224, 224)) # adjust the size as needed
83
+ image = tf.expand_dims(image, axis=0)
84
+
85
+ # Train the model
86
+ model.fit(image, target, epochs=1) # You might want to adjust the number of epochs
87
+
88
  st.success(f'Model has been trained with the new image and label.')
89
  except Exception as e:
90
+ st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")