Aryan-EcoClim commited on
Commit
48fa5e6
·
1 Parent(s): 6011ff1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -115,6 +115,7 @@ if mode == "Predict Mode":
115
  except Exception as e:
116
  st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
117
 
 
118
  elif mode == "Train Mode":
119
  # Train the model with a new image and label
120
  st.header("Train the model with a new image and label")
@@ -132,11 +133,10 @@ elif mode == "Train Mode":
132
  # Train button
133
  if st.button('Train Model'):
134
  # Update the model with the user-provided image and label
135
-
136
- # You might want to adjust the number of epochs
137
-
138
- for i in range(2):
139
- model.fit(image, user_label, epochs=1, batch_size=32)
140
  st.success(f'Model has been trained with the new image and label.')
141
  except Exception as e:
142
  st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
 
115
  except Exception as e:
116
  st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
117
 
118
+
119
  elif mode == "Train Mode":
120
  # Train the model with a new image and label
121
  st.header("Train the model with a new image and label")
 
133
  # Train button
134
  if st.button('Train Model'):
135
  # Update the model with the user-provided image and label
136
+ image = image[np.newaxis, ...] # Add a batch dimension
137
+ label_index = labels.index(user_label)
138
+ label_one_hot = tf.one_hot(label_index, len(labels))
139
+ model.fit(image, label_one_hot, epochs=2, batch_size=1)
 
140
  st.success(f'Model has been trained with the new image and label.')
141
  except Exception as e:
142
  st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")