PrakhAI commited on
Commit
a68d07c
·
1 Parent(s): 456827e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -17
app.py CHANGED
@@ -30,16 +30,6 @@ cnn = CNN()
30
  params = cnn.init(jax.random.PRNGKey(0), jnp.ones([1, 28, 28, 1]))['params']
31
 
32
 
33
- class CNN2(nn.Module):
34
- """A simple CNN model."""
35
-
36
- @nn.compact
37
- def __call__(self, x):
38
- x = nn.Conv(features=32, kernel_size=(3, 3))(x)
39
- return x
40
-
41
- cnn2 = CNN2()
42
-
43
  fs = HfFileSystem()
44
  with fs.open("PrakhAI/HelloWorld/checkpoint.msgpack", "rb") as f:
45
  params = from_state_dict(params, msgpack_restore(f.read())["params"])
@@ -71,11 +61,8 @@ else:
71
  st.image(rescaled)
72
  brightness = jnp.array(rescaled)
73
  input = brightness.reshape(1, 28, 28, 1) / 255.
74
- conv = cnn2.apply({"params": {"Conv_0": params["Conv_0"]}}, input)
75
- print(type(conv))
76
- print(conv)
77
- print(conv.shape)
78
- print(dir(conv))
79
- print(conv.tolist())
80
- st.image(Image.fromarray(conv))
81
  st.write(cnn.apply({"params": params}, input).argmax(axis=1)[0])
 
 
 
 
 
30
  params = cnn.init(jax.random.PRNGKey(0), jnp.ones([1, 28, 28, 1]))['params']
31
 
32
 
 
 
 
 
 
 
 
 
 
 
33
  fs = HfFileSystem()
34
  with fs.open("PrakhAI/HelloWorld/checkpoint.msgpack", "rb") as f:
35
  params = from_state_dict(params, msgpack_restore(f.read())["params"])
 
61
  st.image(rescaled)
62
  brightness = jnp.array(rescaled)
63
  input = brightness.reshape(1, 28, 28, 1) / 255.
 
 
 
 
 
 
 
64
  st.write(cnn.apply({"params": params}, input).argmax(axis=1)[0])
65
+
66
+ with st.expander("See first convolutional layer"):
67
+ print(params["Conv_0"].shape)
68
+ print(params["Conv_0"].tolist())