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
| bottom_bar_layout = QHBoxLayout() | |
| self.save_button = QPushButton('Save as file') | |
| self.save_button.clicked.connect(self.save_as_file) | |
| self.save_button.setFixedWidth(300) | |
| bottom_bar_layout.addWidget(self.save_button) | |
| self.percent_traced_label = QLabel() | |
| bottom_bar_layout.addWidget(self.percent_traced_label) | |
| main_layout.addLayout(top_bar_layout) | |
| main_layout.addLayout(image_bar_layout) |
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 choose_source_image(self): | |
| self.source_filename = QFileDialog.getOpenFileName()[0] | |
| self.source_image_data = cv2.imread(self.source_filename) | |
| source_image_resized = resize_image(self.source_image_data, self.max_img_width, self.max_img_height) | |
| self.source_image.setPixmap(pixmap_from_cv_image(source_image_resized)) | |
| def process_image(self): | |
| if self.source_image_data is None: | |
| error_dialog = QErrorMessage() | |
| error_dialog.showMessage('No image selected') |
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 resize_image(image_data, max_img_width, max_img_height): | |
| scale_percent = min(max_img_width / image_data.shape[1], max_img_height / image_data.shape[0]) | |
| width = int(image_data.shape[1] * scale_percent) | |
| height = int(image_data.shape[0] * scale_percent) | |
| newSize = (width, height) | |
| image_resized = cv2.resize(image_data, newSize, None, None, None, cv2.INTER_AREA) | |
| return image_resized | |
| def pixmap_from_cv_image(cv_image): |
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
| import sys | |
| from PyQt6.QtWidgets import QApplication, QHBoxLayout, QMainWindow, QPushButton, QSpinBox, QVBoxLayout, QWidget, QFileDialog, QLabel, QErrorMessage | |
| from PyQt6.QtGui import QImage, QPixmap | |
| import cv2 | |
| import numpy as np | |
| class ImageWidget(QLabel): | |
| def __init__(self, parent=None): | |
| super().__init__(parent) |
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
| import sys | |
| from PyQt6.QtWidgets import QApplication, QHBoxLayout, QMainWindow, QPushButton, QSpinBox, QVBoxLayout, QWidget, QFileDialog, QLabel, QErrorMessage | |
| from PyQt6.QtGui import QImage, QPixmap | |
| import cv2 | |
| import numpy as np |
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
| import pandas as pd | |
| import plotly.express as px | |
| from sklearn.feature_extraction.text import TfidfVectorizer | |
| import wikipedia | |
| import numpy as np | |
| from tqdm.notebook import tqdm | |
| import re | |
| import os | |
| from sklearn.metrics.pairwise import linear_kernel | |
| from surprise import Dataset |
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
| movies_df = pd.read_csv(f'{BASE_FOLDER}/MovieLens-1M/movies.dat', | |
| delimiter='::', engine= 'python', header=None, | |
| names=['movie_name', 'genre']) | |
| movies_df.head() |
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
| movie_name | genre | ||
|---|---|---|---|
| 1 | Toy Story (1995) | Animation|Children's|Comedy | |
| 2 | Jumanji (1995) | Adventure|Children's|Fantasy | |
| 3 | Grumpier Old Men (1995) | Comedy|Romance | |
| 4 | Waiting to Exhale (1995) | Comedy|Drama | |
| 5 | Father of the Bride Part II (1995) | Comedy |
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
| movies_df['genre'] = movies_df['genre'].apply(lambda x: x.split('|')) | |
| movies_df_exploded = movies_df.explode('genre') | |
| px.histogram(movies_df_exploded, x='genre', height=400, title='Movie count by genre').update_xaxes(categoryorder="total descending") |
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
| movies_df['year'] = movies_df['movie_name'].apply(lambda movie_name: re.search('\((\d*)\)', movie_name).groups(1)[0]) | |
| movie_count_by_year = px.histogram(movies_df, x='year', height=400, title='Movie count by year').update_xaxes(categoryorder="total descending") | |
| movie_count_by_year |