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
import cv2 | |
img1 = cv2.imread('image1_add.jpg', 1) | |
#or | |
#img1 = cv2.imread('C:\\Users\\Admin\\Downloads\\image1_add.jpg', 1) | |
cv2.imshow('Image 1', img1) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
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
import cv2 | |
img = cv2.imread('flower_image.jpg', 1) | |
#or | |
#img = cv2.imread('C:\\Users\\Admin\\Downloads\\flower_image.jpg', 1) | |
cv2.imshow('Coloured Image', img) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
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
import cv2 | |
img = cv2.imread('flower_image.jpg', cv2.IMREAD_UNCHANGED) | |
#or | |
#img = cv2.imread('C:\\Users\\Admin\\Downloads\\flower_image.jpg', cv2.IMREAD_UNCHANGED) | |
cv2.imshow('Unchanged Image', img) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
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
import cv2 | |
img = cv2.imread('flower_image.jpg', 1) | |
#or | |
#img = cv2.imread('C:\\Users\\Admin\\Downloads\\flower_image.jpg', 1) | |
cv2.imshow('Colour Image', img) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
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
import cv2 | |
img = cv2.imread('flower_image.jpg', 0) | |
#or | |
#img = cv2.imread('C:\\Users\\Admin\\Downloads\\flower_image.jpg', 0) |
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
import cv2 | |
img = cv2.imread('flower_image.jpg', 1) | |
#or | |
#img = cv2.imread('C:\\Users\\Admin\\Downloads\\flower_image.jpg', 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
# get summary with classical LexRank algorithm | |
summary = lxr.get_summary(sentences, summary_size=2, threshold=.1) | |
print(summary) | |
# get summary with continuous LexRank | |
summary_cont = lxr.get_summary(sentences, threshold=None) | |
print(summary_cont) |
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
#remove stopwords | |
lxr = LexRank(documents, stopwords=STOPWORDS['en']) | |
sentences = [ | |
'One of David Cameron\'s closest friends and Conservative allies, ' | |
'George Osborne rose rapidly after becoming MP for Tatton in 2001.', | |
'Michael Howard promoted him from shadow chief secretary to the ' | |
'Treasury to shadow chancellor in May 2005, at the age of 34.', |
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
! wget http://mlg.ucd.ie/files/datasets/bbc-fulltext.zip | |
! unzip bbc-fulltext.zip | |
project_path = "/text_summarization/" | |
documents = [] | |
documents_dir = Path('/content/bbc/entertainment') | |
for file_path in documents_dir.files('*.txt'): | |
with file_path.open(mode='rt', encoding='utf-8') as fp: |
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 lexrank import LexRank | |
from lexrank.mappings.stopwords import STOPWORDS | |
import pandas as pd | |
import numpy as np | |
from path import Path |