This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [['TATA','BIRLA'],['JIO','TATA'],['AMBANI']] | |
pd.DataFrame(data) | |
""" | |
0 1 | |
0 TATA BIRLA | |
1 JIO TATA | |
2 AMBANI None | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model Name | Validation Accuracy | Trainable params | |
---|---|---|---|
Unet resblock | 0.8925 | 1206163 | |
Efficient Unet | 0.9183 | 10816611 | |
Double Unet | 0.9158 | 29290274 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KERAS_MODEL_NAME = "tf_effienet_Unet_brain_final" | |
effienet_Unet_model.save(KERAS_MODEL_NAME) | |
#Save this folder permanent storage for future use. | |
#reloading the model | |
tf.keras.backend.clear_session() | |
reloaded_model = build_effienet_unet(input_shape) | |
reloaded_model.load_weights("/content/tf_effienet_Unet_brain_final") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.losses import binary_crossentropy | |
import keras.backend as K | |
import tensorflow as tf | |
smooth=1e-6 | |
def tversky(y_true, y_pred): | |
y_true_pos = K.flatten(y_true) | |
y_pred_pos = K.flatten(y_pred) | |
true_pos = K.sum(y_true_pos * y_pred_pos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/Nupurgopali/Brain-tumor-classification-using-CNN/blob/master/convolutional_neural_network.py | |
simple_classifer = tf.keras.models.Sequential() | |
simple_classifer.add(tf.keras.layers.Conv2D(filters=64, kernel_size=3, activation='relu', input_shape=[256, 256, 3])) | |
simple_classifer.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=1)) | |
simple_classifer.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, activation='relu')) | |
simple_classifer.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w = 256 | |
h = 256 | |
def image_augmentation(image_path, mask_path): | |
""" | |
Takes the path of image and mask and apply any one of the image augmentation and save the image | |
""" | |
I = cv2.imread(image_path) | |
J = cv2.imread(image_path) | |
oper = np.random.randint(low= 1, high=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ax = images_df["is_tumor"].value_counts().plot(kind = "bar",title = "Is_tumor",color=['g','r'] ) | |
for patch in ax.patches: | |
ax.annotate(xy = (patch.get_x() + 0.25 ,patch.get_height()+0.5 ),s = str(patch.get_height()) ) | |
print("Percentage of patients with no tumor", str( (images_df["is_tumor"].value_counts()[0]/ images_df["is_tumor"].value_counts().sum() ) *100) ) | |
print("Percentage of patients with tumor", str( (images_df["is_tumor"].value_counts()[1]/ images_df["is_tumor"].value_counts().sum() ) *100) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def istumor(mask_img): | |
""" | |
Finding wheather the mask has tumor or not | |
""" | |
mask_img = cv2.imread(mask_img) | |
k = np.max(mask_img) | |
return 1 if k > 0 else 0 | |
images_df["is_tumor"] = images_df['MRI_mask'].apply(istumor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in stock_selected: | |
fetch_data(symbol = i) | |
time.sleep(10) | |
print(i) | |
print(len(os.listdir("stock_data"))) # 156 stocks data downloaded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f_and_o = pd.read_csv("FandO.csv") # File containing the F&O stocks. | |
stock_selected = [] | |
for i in f_and_o['Symbol'].values: | |
stock_selected.append(i) | |
# Removing the index future and option contracts | |
stock_selected.remove('NIFTY') | |
stock_selected.remove('BANKNIFTY') | |
stock_selected.remove('FINNIFTY') |