This file contains hidden or 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 adjustData(img,mask,flag_multi_class,n_class): | |
| if(flag_multi_class): | |
| img /= 255 | |
| mask = mask[:,:,:,0] if(len(mask.shape) == 4) else mask[:,:,0] | |
| new_mask = np.zeros(mask.shape + (n_class,)) | |
| for i in range(n_class): | |
| new_mask[mask == i,i] = 1 | |
| new_mask = np.reshape(new_mask,(new_mask.shape[0],new_mask.shape[1]*new_mask.shape[2],new_mask.shape[3])) if flag_multi_class else np.reshape(new_mask,(new_mask.shape[0]*new_mask.shape[1],new_mask.shape[2])) |
This file contains hidden or 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 dice_coef(y_true, y_pred, smooth=1): | |
| intersection = keras.sum(y_true * y_pred, axis=[1,2,3]) | |
| union = keras.sum(y_true, axis=[1,2,3]) + keras.sum(y_pred, axis=[1,2,3]) | |
| return keras.mean( (2. * intersection + smooth) / (union + smooth), axis=0) | |
| def dice_coef_loss(y_true, y_pred): | |
| return -dice_coef(y_true, y_pred) |
This file contains hidden or 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 prepare_multi_class_GT(GT_PATH, class_names, savepath, target_size=(512,512), n_class=3): | |
| f_names = os.listdir(GT_PATH+class_names[0]) | |
| for files in f_names: | |
| GT_im=np.zeros(np.concatenate((target_size,n_class),axis=None)) #This creates a zero array of size (512,512,3) | |
| FG=np.zeros(target_size) | |
| for idx,cn in enumerate(class_names): | |
| lab=io.imread(GT_PATH+cn+files, as_gray=True) | |
| lab = trans.resize(lab,target_size) |
This file contains hidden or 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_gen_args = dict(rotation_range=0.3, | |
| width_shift_range=0.1, | |
| height_shift_range=0.1, | |
| shear_range=0.1, | |
| zoom_range=[0.7,1], | |
| horizontal_flip=True, | |
| fill_mode='nearest') |
This file contains hidden or 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
| steps: | |
| # Step 1: pull the container image if it is already built, if fails do not exit | |
| - name: 'gcr.io/cloud-builders/docker' | |
| entrypoint: 'bash' | |
| args: | |
| - '-c' | |
| - 'docker pull gcr.io/$PROJECT_ID/appcicd:latest || exit 0' | |
| # Step 2: Create a docker image if none exists, esle load existing one | |
| - name: 'gcr.io/cloud-builders/docker' | |
| args: |
This file contains hidden or 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
| steps: | |
| # pull the container image if it is already built | |
| - name: 'gcr.io/cloud-builders/docker' | |
| entrypoint: 'bash' | |
| args: | |
| - '-c' | |
| - 'docker pull gcr.io/$PROJECT_ID/appcicd:latest || exit 0' | |
| # build the container image | |
| - name: 'gcr.io/cloud-builders/docker' | |
| args: |
This file contains hidden or 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 python:3.6-slim-buster | |
| RUN python -m pip install --upgrade pip | |
| COPY requirements.txt . | |
| RUN pip install -r requirements.txt | |
| COPY . /app | |
| WORKDIR /app/app_files | |
| CMD ["python", "app.py"] |
This file contains hidden or 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
| if __name__=='__main__': | |
| app.run( debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)) ) | |
| label="Regression_model", linewidth=2) |
This file contains hidden or 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
| #To generate a best fit model | |
| X_range=np.zeros((50,3)) | |
| y_range=np.zeros((50,)) | |
| for i in range(3): | |
| Xi=X[:,i] | |
| vals=plt.hist(Xi,49) | |
| plt.xlabel("Feature") | |
| plt.ylabel("Frequency") | |
| X_range[:,i]=np.transpose(vals[1]) | |
| y_range=model.predict(X_range) |
This file contains hidden or 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 sklearn.tree import DecisionTreeRegressor | |
| reg=DecisionTreeRegressor(max_depth=5) | |
| reg.fit(X,y) | |
| y_pred=reg.predict(X) | |
| print(reg.score) |