diff --git a/.gitignore b/.gitignore index 2eea525..0de1ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,32 @@ -.env \ No newline at end of file +# Python +*.pyc +__pycache__/ +*.pyo +*.pyd + +# Virtual environment +venv/ + +# Database +db.sqlite3 + +# Local settings +local_settings.py + +# Media and static files +/media/ +/static/ + +# Log files +*.log + +# Environment variables +.env + +# IDE files +.vscode/ +.idea/ + +# OS files +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/analyzer/extract_graph_data.py b/analyzer/extract_graph_data.py index 5e3f484..4c3b123 100644 --- a/analyzer/extract_graph_data.py +++ b/analyzer/extract_graph_data.py @@ -1,5 +1,6 @@ import cv2 import numpy as np +from scipy import stats def extract_graph_data(image_path): # Read the image @@ -26,4 +27,22 @@ def analyze_data(data_points): maxima = np.argmax(data_points, axis=0) minima = np.argmin(data_points, axis=0) - return minima, maxima \ No newline at end of file + return minima, maxima + +def predict_next_points(data_points, num_predictions=5): + # Convert data points to a time series (assuming equal time intervals) + x = np.arange(len(data_points)) + y = data_points[:, 1] # Assuming y-coordinates represent the data values + + # Perform linear regression + slope, intercept, _, _, _ = stats.linregress(x, y) + + # Predict next points + last_x = len(data_points) + predicted_points = [] + for i in range(num_predictions): + next_x = last_x + i + 1 + next_y = slope * next_x + intercept + predicted_points.append((next_x, next_y)) + + return predicted_points \ No newline at end of file diff --git a/analyzer/views.py b/analyzer/views.py index e17d438..10bcfb1 100644 --- a/analyzer/views.py +++ b/analyzer/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render from .forms import GraphUploadForm -from .extract_graph_data import extract_graph_data, analyze_data +from .extract_graph_data import extract_graph_data, analyze_data, predict_next_points import os from graph_analyzer.settings import BASE_DIR @@ -19,13 +19,14 @@ def upload_image(request): # Process image and get graph data data_points = extract_graph_data(image_path) minima, maxima = analyze_data(data_points) + predicted_points = predict_next_points(data_points) context = { 'minima': minima, - 'maxima': maxima + 'maxima': maxima, + 'predicted_points': predicted_points } return render(request, 'analyzer/index.html', context) else: form = GraphUploadForm() - return render(request, 'analyzer/index.html', {'form': form}) - + return render(request, 'analyzer/index.html', {'form': form}) \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index 32688ab..d5b9367 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/graph_analyzer/settings.py b/graph_analyzer/settings.py index 3d8267d..4cc52b5 100644 --- a/graph_analyzer/settings.py +++ b/graph_analyzer/settings.py @@ -158,7 +158,7 @@ ACCOUNT_AUTHENTICATION_METHOD='username_email' ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS=10 ACCOUNT_EMAIL_REQUIRED=True -ACCOUNT_EMAIL_VERIFICATION='None' +ACCOUNT_EMAIL_VERIFICATION='optional' ACCOUNT_FORMS = { 'signup': 'stellarledger.forms.CustomSignupForm', diff --git a/graph_analyzer/urls.py b/graph_analyzer/urls.py index 0998df7..a06c1e7 100644 --- a/graph_analyzer/urls.py +++ b/graph_analyzer/urls.py @@ -16,8 +16,14 @@ """ from django.contrib import admin from django.urls import path, include +from django.conf import settings +from django.conf.urls.static import static urlpatterns = [ path("admin/", admin.site.urls), path("", include("analyzer.urls")), ] + +if settings.DEBUG: + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/images/Average-network-throughput-vs-simulation-time-120-nodes-Fig-6-depicts-the-value-of.png b/images/Average-network-throughput-vs-simulation-time-120-nodes-Fig-6-depicts-the-value-of.png new file mode 100644 index 0000000..f80db1e Binary files /dev/null and b/images/Average-network-throughput-vs-simulation-time-120-nodes-Fig-6-depicts-the-value-of.png differ diff --git a/requirements.txt b/requirements.txt index 5eb052d..bf2e4c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,17 @@ -Django==5.0.3 -django-admin-sortable2==1.0.4 -django-allauth==0.61.1 -django-cors-headers==4.3.1 -django-countries==7.5.1 -django-timezone-field==6.1.0 -google-api-core==2.11.0 -google-api-python-client==2.37.0 -google-auth==2.16.2 -google-auth-httplib2==0.1.0 -numpy==1.26.4 -oauth2client==4.1.3 -oauthlib==3.2.2 -opencv-python==4.9.0.80 -pandas==2.2.1 -pip-tools==6.12.1 -virtualenv==20.20.0 \ No newline at end of file +asgiref==3.8.1 +certifi==2024.8.30 +cffi==1.17.1 +charset-normalizer==3.4.0 +cryptography==43.0.3 +Django==5.1.2 +django-allauth==65.0.2 +idna==3.10 +numpy==2.1.2 +opencv-python==4.10.0.84 +pillow==11.0.0 +pycparser==2.22 +PyJWT==2.9.0 +python-dotenv==1.0.1 +requests==2.32.3 +sqlparse==0.5.1 +urllib3==2.2.3 diff --git a/templates/analyzer/index.html b/templates/analyzer/index.html index 2bd9344..a706771 100644 --- a/templates/analyzer/index.html +++ b/templates/analyzer/index.html @@ -1,19 +1,71 @@ +{% load static %} - Document + Graph Analyzer + + -
- {% csrf_token %} - {{ form.as_p }} - -
-

Graph Analysis Results

-

Minima: {{ minima }}

-

Maxima: {{ maxima }}

+
+
+

Graph Analyzer

+
+
+
+
+
+ {% csrf_token %} +
+ + Select File + {{ form.image }} + No file chosen +
+ +
+
+ + {% if minima is not None and maxima is not None %} +
+

Graph Analysis Results

+
+

Minima: {{ minima }}

+

Maxima: {{ maxima }}

+
+
+ {% endif %} + + {% if predicted_points %} +
+

Predicted Next 5 Points

+ +
+ {% endif %} +
+ + + + \ No newline at end of file