poornesh110 commited on
Commit
ebafcec
1 Parent(s): 1438900

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -58
app.py CHANGED
@@ -6,55 +6,55 @@
6
  # In[1]:
7
 
8
 
9
- # import keras
10
- # get_ipython().run_line_magic('env', 'SM_FRAMEWORK=tf.keras')
11
- # import segmentation_models as sm
12
- # import glob
13
- # import matplotlib.pyplot as plt
14
- # from scipy import ndimage
15
- # from scipy.ndimage import label, generate_binary_structure
16
- # import radiomics
17
- # import cv2
18
- # import SimpleITK as sitk
19
- # import six
20
- # import numpy as np
21
- # import pandas as pd
22
- # import seaborn as sns
23
- # import matplotlib.pyplot as plt
24
- # from sklearn.model_selection import train_test_split
25
- # get_ipython().run_line_magic('matplotlib', 'inline')
26
- # from sklearn.feature_selection import SelectKBest
27
- # from sklearn.feature_selection import mutual_info_classif
28
- # from sklearn.ensemble import RandomForestClassifier
29
- # from sklearn.feature_selection import RFE
30
- # from sklearn.metrics import roc_auc_score
31
- # from sklearn.feature_selection import SelectFromModel
32
- # from sklearn.linear_model import Lasso, LogisticRegression
33
- # from sklearn.preprocessing import StandardScaler
34
- # from sklearn.decomposition import PCA
35
- # from sklearn.svm import LinearSVC
36
- # from sklearn.datasets import load_iris
37
- # from sklearn.feature_selection import SelectFromModel
38
- # from sklearn.feature_selection import mutual_info_classif as MIC
39
- # from sklearn.feature_selection import mutual_info_classif, mutual_info_regression
40
- # from sklearn.feature_selection import SelectKBest, SelectPercentile
41
- # from sklearn.feature_selection import SequentialFeatureSelector
42
- # from sklearn.neighbors import KNeighborsClassifier
43
- # from sklearn.linear_model import LogisticRegression
44
- # from sklearn.ensemble import RandomForestClassifier
45
- # from sklearn.svm import SVC
46
- # from sklearn.metrics import f1_score
47
- # from sklearn.model_selection import cross_validate
48
- # from sklearn.tree import DecisionTreeClassifier
49
- # from sklearn.linear_model import Perceptron
50
- # from sklearn.model_selection import RandomizedSearchCV
51
- # from sklearn.model_selection import GridSearchCV
52
-
53
- # import warnings
54
- # warnings.filterwarnings('ignore')
55
- # import os
56
-
57
- # os.environ["CUDA_VISIBLE_DEVICES"] = "1"
58
 
59
 
60
  # # Defining the path to Model and Images
@@ -72,15 +72,15 @@ path_base_model = './/models//'
72
 
73
 
74
  BACKBONE = 'efficientnetb0'
75
- model1 = segmentation_models.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
76
- model2 = segmentation_models.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
77
- model3 = segmentation_models.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
78
 
79
  BACKBONE = 'efficientnetb7'
80
- model4 = segmentation_models.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
81
- model5 = segmentation_models.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
82
 
83
- preprocess_input = segmentation_models.get_preprocessing(BACKBONE)
84
 
85
  model1.load_weights(path_base_model + 'model1.hdf5')
86
  model2.load_weights(path_base_model + 'model2.hdf5')
@@ -96,11 +96,11 @@ model5.load_weights(path_base_model + 'model5.hdf5')
96
 
97
  def preprocessing_HE(img_):
98
 
99
- hist, bins = numpy.histogram(img_.flatten(), 256,[0,256])
100
  cdf = hist.cumsum()
101
- cdf_m = numpy.ma.masked_equal(cdf,0)
102
  cdf_m = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())
103
- cdf = numpy.ma.filled(cdf_m,0).astype('uint8')
104
 
105
  img_2 = cdf[img_]
106
 
 
6
  # In[1]:
7
 
8
 
9
+ import keras
10
+ get_ipython().run_line_magic('env', 'SM_FRAMEWORK=tf.keras')
11
+ import segmentation_models as sm
12
+ import glob
13
+ import matplotlib.pyplot as plt
14
+ from scipy import ndimage
15
+ from scipy.ndimage import label, generate_binary_structure
16
+ import radiomics
17
+ import cv2
18
+ import SimpleITK as sitk
19
+ import six
20
+ import numpy as np
21
+ import pandas as pd
22
+ import seaborn as sns
23
+ import matplotlib.pyplot as plt
24
+ from sklearn.model_selection import train_test_split
25
+ get_ipython().run_line_magic('matplotlib', 'inline')
26
+ from sklearn.feature_selection import SelectKBest
27
+ from sklearn.feature_selection import mutual_info_classif
28
+ from sklearn.ensemble import RandomForestClassifier
29
+ from sklearn.feature_selection import RFE
30
+ from sklearn.metrics import roc_auc_score
31
+ from sklearn.feature_selection import SelectFromModel
32
+ from sklearn.linear_model import Lasso, LogisticRegression
33
+ from sklearn.preprocessing import StandardScaler
34
+ from sklearn.decomposition import PCA
35
+ from sklearn.svm import LinearSVC
36
+ from sklearn.datasets import load_iris
37
+ from sklearn.feature_selection import SelectFromModel
38
+ from sklearn.feature_selection import mutual_info_classif as MIC
39
+ from sklearn.feature_selection import mutual_info_classif, mutual_info_regression
40
+ from sklearn.feature_selection import SelectKBest, SelectPercentile
41
+ from sklearn.feature_selection import SequentialFeatureSelector
42
+ from sklearn.neighbors import KNeighborsClassifier
43
+ from sklearn.linear_model import LogisticRegression
44
+ from sklearn.ensemble import RandomForestClassifier
45
+ from sklearn.svm import SVC
46
+ from sklearn.metrics import f1_score
47
+ from sklearn.model_selection import cross_validate
48
+ from sklearn.tree import DecisionTreeClassifier
49
+ from sklearn.linear_model import Perceptron
50
+ from sklearn.model_selection import RandomizedSearchCV
51
+ from sklearn.model_selection import GridSearchCV
52
+
53
+ import warnings
54
+ warnings.filterwarnings('ignore')
55
+ import os
56
+
57
+ os.environ["CUDA_VISIBLE_DEVICES"] = "1"
58
 
59
 
60
  # # Defining the path to Model and Images
 
72
 
73
 
74
  BACKBONE = 'efficientnetb0'
75
+ model1 = sm.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
76
+ model2 = sm.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
77
+ model3 = sm.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
78
 
79
  BACKBONE = 'efficientnetb7'
80
+ model4 = sm.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
81
+ model5 = sm.Unet(BACKBONE, input_shape = (IMAGE_SIZE[0],IMAGE_SIZE[1],IMAGE_SIZE[2]),classes=1, activation='sigmoid',encoder_weights='imagenet')
82
 
83
+ preprocess_input = sm.get_preprocessing(BACKBONE)
84
 
85
  model1.load_weights(path_base_model + 'model1.hdf5')
86
  model2.load_weights(path_base_model + 'model2.hdf5')
 
96
 
97
  def preprocessing_HE(img_):
98
 
99
+ hist, bins = np.histogram(img_.flatten(), 256,[0,256])
100
  cdf = hist.cumsum()
101
+ cdf_m = np.ma.masked_equal(cdf,0)
102
  cdf_m = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())
103
+ cdf = np.ma.filled(cdf_m,0).astype('uint8')
104
 
105
  img_2 = cdf[img_]
106