mbrad commited on
Commit
247054e
1 Parent(s): 71b0e85

Upload 4 files

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -0
  2. app.py +55 -0
  3. model1.keras +3 -0
  4. model3.keras +3 -0
  5. requirements.txt +5 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model1.keras filter=lfs diff=lfs merge=lfs -text
37
+ model3.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ import matplotlib.patches
5
+ import numpy as np
6
+ from sklearn.model_selection import train_test_split
7
+ import tensorflow as tf
8
+ import keras
9
+ from tensorflow.keras.models import Sequential
10
+ from tensorflow.keras.layers import Dense
11
+
12
+ NN = keras.models.load_model('/content/drive/MyDrive/Final_Project/model1.keras')
13
+ CNN = keras.models.load_model('/content/drive/MyDrive/Final_Project/model3.keras')
14
+
15
+ # Specify image module
16
+ input_module1 = gr.File(label = "Input Image File (Must be 128x128 Greyscale)")
17
+
18
+ # Specify method dropdown menu
19
+ input_module2 = gr.Dropdown(choices=['Convolutional Neural Network', 'Neural Network'], label = "Method")
20
+
21
+ # Specify output 1
22
+ output_module1 = gr.Plot(label = "Predicted Box")
23
+
24
+ def multi_inputs(input1, input2):
25
+ import numpy as np
26
+ ## processing inputs
27
+ #input1= input1[:,:,0]
28
+ photo = plt.imread(input1)
29
+ Dcells = 128*128
30
+ if input2 == "Neural Network":
31
+ flattened = photo.reshape(1,Dcells)
32
+ predicted_box = NN.predict((flattened))
33
+ box_x = predicted_box[0,0]
34
+ box_y = predicted_box[0,1]
35
+ box_width = predicted_box[0,2]
36
+ box_height = predicted_box[0,3]
37
+ plt.imshow(photo, cmap='gray')
38
+ plt.gca().add_patch(matplotlib.patches.Rectangle((box_x, box_y), box_width, box_height, ec='r', fc='none'))
39
+ plt.gca().annotate("NN", xy = (0,0), xytext = (box_x, box_y+box_height+4), color='r',fontsize = 8)
40
+ else:
41
+ shaped = photo.reshape(1,128,128)
42
+ predicted_box = CNN.predict(shaped)
43
+ box_x = predicted_box[0,0]
44
+ box_y = predicted_box[0,1]
45
+ box_width = predicted_box[0,2]
46
+ box_height = predicted_box[0,3]
47
+ plt.imshow(photo, cmap='gray')
48
+ plt.gca().add_patch(matplotlib.patches.Rectangle((box_x, box_y), box_width, box_height, ec='r', fc='none'))
49
+ plt.gca().annotate("CNN", xy = (0,0), xytext = (box_x, box_y+box_height+4), color='r',fontsize = 8)
50
+ return plt
51
+
52
+ gr.Interface(fn=multi_inputs,
53
+ inputs=[input_module1, input_module2],
54
+ outputs=[output_module1]
55
+ ).launch(debug = True)
model1.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c646d8f0b0e9dedf7196b506cfbba5604809c7ff56394ca3a37b4e5d16b76e71
3
+ size 82544785
model3.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db1913e473cee2b629c10fa35475e39868da97fba0c07c6db0a687d011fd036e
3
+ size 209843323
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy
2
+ keras
3
+ pandas
4
+ tensorflow
5
+ matplotlib