From 42808c39df96a80e83925ffcce0132b4088b8b79 Mon Sep 17 00:00:00 2001 From: Stanislas Lange Date: Sat, 21 Oct 2023 19:24:00 +0200 Subject: [PATCH] Update dependencies to make the app run again --- app/__init__.py | 10 ++++++---- app/forms.py | 4 +--- app/routes.py | 11 ++++------- app/utils/kmeans.py | 2 -- app/utils/knn.py | 5 +++-- config.py | 1 + requirements.txt | 32 ++++++++++++++++---------------- 7 files changed, 31 insertions(+), 34 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 34b5f19..dd22d01 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,10 +1,12 @@ import logging import os -from flask_uploads import UploadSet, IMAGES, configure_uploads +from logging.handlers import RotatingFileHandler + from flask import Flask +from flask_bootstrap import Bootstrap4 +from flask_uploads import IMAGES, UploadSet, configure_uploads + from config import Config -from flask_bootstrap import Bootstrap -from logging.handlers import RotatingFileHandler app = Flask(__name__) app.config.from_object(Config) @@ -24,7 +26,7 @@ file_handler.setLevel(logging.INFO) app.logger.addHandler(file_handler) -bootstrap = Bootstrap(app) +bootstrap = Bootstrap4(app) images = UploadSet('images', IMAGES) configure_uploads(app, images) diff --git a/app/forms.py b/app/forms.py index 8fd1f81..3a1bee9 100644 --- a/app/forms.py +++ b/app/forms.py @@ -1,11 +1,9 @@ -from flask_uploads import IMAGES, UploadSet, configure_uploads from flask_wtf import FlaskForm +from flask_wtf.file import FileAllowed, FileField, FileRequired from wtforms import IntegerField -from flask_wtf.file import FileField, FileAllowed, FileRequired from wtforms.fields.simple import SubmitField from app import images -from app import app class UploadForm(FlaskForm): diff --git a/app/routes.py b/app/routes.py index f453083..e27ad82 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,17 +1,14 @@ import os -import numbers -from flask import render_template, request, abort -from flask.helpers import url_for -from werkzeug import redirect, secure_filename +from flask import render_template, request +from flask.json import jsonify +from webcolors import hex_to_rgb +from werkzeug.utils import secure_filename from app import app -from app import images from app.forms import UploadForm from app.utils.kmeans import Kmeans from app.utils.knn import Knn -from webcolors import hex_to_rgb -from flask.json import jsonify ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg']) diff --git a/app/utils/kmeans.py b/app/utils/kmeans.py index 8ee9b6d..a6766bc 100644 --- a/app/utils/kmeans.py +++ b/app/utils/kmeans.py @@ -1,6 +1,5 @@ import cv2 import imutils - from sklearn.cluster import KMeans from webcolors import rgb_to_hex @@ -18,7 +17,6 @@ def clusterize(self): # and improve the quality of the clustering self.model = KMeans(n_clusters = self.clusters, init = 'k-means++', - n_jobs = -1, n_init = 10, max_iter = 300, algorithm='elkan') diff --git a/app/utils/knn.py b/app/utils/knn.py index 54897ed..ddead4c 100644 --- a/app/utils/knn.py +++ b/app/utils/knn.py @@ -1,6 +1,7 @@ -from sklearn.neighbors import KNeighborsClassifier -from sklearn import preprocessing import pandas as pd +from sklearn import preprocessing +from sklearn.neighbors import KNeighborsClassifier + class Knn: diff --git a/config.py b/config.py index c731c6c..e94ec2c 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,6 @@ import os + class Config(object): SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess' UPLOADS_DEFAULT_DEST = os.environ.get('UPLOADS_DEFAULT_DEST') or '/tmp' diff --git a/requirements.txt b/requirements.txt index a2d8dc2..7321306 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,17 @@ -Flask==1.1.2 -opencv-python==4.2.0.34 -opencv-python-headless==4.2.0.34 -Werkzeug<1 +Flask==3.0.0 +opencv-python==4.8.1.78 +opencv-python-headless==4.8.1.78 +Werkzeug==3.0.0 sklearn==0.0 -python-dotenv==0.13.0 -Flask-WTF==0.14.3 -WTForms==2.3.1 -Flask-Uploads==0.2.1 -numpy==1.18.4 -Pillow==7.1.2 -psycopg2==2.8.5 -gunicorn==20.0.4 -webcolors==1.11.1 -pandas==1.0.3 -Bootstrap-Flask==1.3.1 -imutils==0.5.3 +python-dotenv==1.0.0 +Flask-WTF==1.2.1 +WTForms==3.1.0 +Flask-Reuploaded==1.4.0 +numpy==1.26.1 +Pillow==10.1.0 +psycopg2==2.9.9 +gunicorn==21.2.0 +webcolors==1.13 +pandas==2.1.1 +Bootstrap-Flask==2.3.2 +imutils==0.5.4