PrakhAI commited on
Commit
9c58490
·
1 Parent(s): c9b6e3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -43,6 +43,12 @@ else:
43
  st.image(rescaled)
44
  input = jnp.array(rescaled).reshape(1, 28, 28, 1) / 255.
45
  st.write("Model Prediction: " + cnn.apply({"params": params}, input).argmax(axis=1)[0])
 
 
 
 
 
 
46
 
47
  def gridify(kernel, grid, kernel_size, scaling=5, padding=1):
48
  scaled_and_padded = np.pad(np.repeat(np.repeat(kernel, repeats=scaling, axis=0), repeats=scaling, axis=1), ((padding,),(padding,),(0,),(0,)), 'constant', constant_values=(-1,))
 
43
  st.image(rescaled)
44
  input = jnp.array(rescaled).reshape(1, 28, 28, 1) / 255.
45
  st.write("Model Prediction: " + cnn.apply({"params": params}, input).argmax(axis=1)[0])
46
+ input = jnp.array([jnp.array(Image.open(uploaded_file).convert("HSV").split()[2].resize((28, 28))).reshape(1, 28, 28, 1) / 255. for uploaded_file in uploaded_files])
47
+ prediction = cnn.apply({"params": params}, input)
48
+ for (index, image) in enumerate(uploaded_files):
49
+ st.image(Image.open(image))
50
+ st.write("Model Prediction: " + prediction[index].argmax(axis=0)[0])
51
+
52
 
53
  def gridify(kernel, grid, kernel_size, scaling=5, padding=1):
54
  scaled_and_padded = np.pad(np.repeat(np.repeat(kernel, repeats=scaling, axis=0), repeats=scaling, axis=1), ((padding,),(padding,),(0,),(0,)), 'constant', constant_values=(-1,))