fixed
Browse files- __pycache__/config.cpython-312.pyc +0 -0
- app/__init__.py +6 -0
- app/__pycache__/__init__.cpython-311.pyc +0 -0
- app/__pycache__/__init__.cpython-312.pyc +0 -0
- app/__pycache__/forms.cpython-312.pyc +0 -0
- app/models/__pycache__/__init__.cpython-312.pyc +0 -0
- app/models/__pycache__/google_ad.cpython-312.pyc +0 -0
- app/routes/__pycache__/__init__.cpython-312.pyc +0 -0
- app/routes/__pycache__/api.cpython-312.pyc +0 -0
- app/routes/__pycache__/auth.cpython-312.pyc +0 -0
- app/routes/__pycache__/compliance.cpython-312.pyc +0 -0
- app/routes/__pycache__/dashboard.cpython-312.pyc +0 -0
- app/routes/__pycache__/google_ads.cpython-312.pyc +0 -0
- app/routes/__pycache__/test.cpython-312.pyc +0 -0
- app/routes/compliance.py +7 -0
- app/services/__pycache__/ai_processor.cpython-312.pyc +0 -0
- app/services/__pycache__/google_scraper.cpython-312.pyc +0 -0
- app/services/ai_processor.py +15 -4
- app/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- app/utils/__pycache__/decorators.cpython-312.pyc +0 -0
- app/utils/__pycache__/validators.cpython-312.pyc +0 -0
__pycache__/config.cpython-312.pyc
ADDED
|
Binary file (2.78 kB). View file
|
|
|
app/__init__.py
CHANGED
|
@@ -23,6 +23,12 @@ login.login_view = 'auth.login'
|
|
| 23 |
celery = Celery(__name__)
|
| 24 |
cache = None # Initialize later when app context is available
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
def create_app(config_class=None):
|
| 27 |
logger.info("Starting application initialization...")
|
| 28 |
|
|
|
|
| 23 |
celery = Celery(__name__)
|
| 24 |
cache = None # Initialize later when app context is available
|
| 25 |
|
| 26 |
+
# Set up user loader for Flask-Login
|
| 27 |
+
@login.user_loader
|
| 28 |
+
def load_user(user_id):
|
| 29 |
+
from .models import User
|
| 30 |
+
return User.query.get(int(user_id))
|
| 31 |
+
|
| 32 |
def create_app(config_class=None):
|
| 33 |
logger.info("Starting application initialization...")
|
| 34 |
|
app/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (8.16 kB). View file
|
|
|
app/__pycache__/__init__.cpython-312.pyc
CHANGED
|
Binary files a/app/__pycache__/__init__.cpython-312.pyc and b/app/__pycache__/__init__.cpython-312.pyc differ
|
|
|
app/__pycache__/forms.cpython-312.pyc
ADDED
|
Binary file (1.26 kB). View file
|
|
|
app/models/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (3.46 kB). View file
|
|
|
app/models/__pycache__/google_ad.cpython-312.pyc
ADDED
|
Binary file (3.82 kB). View file
|
|
|
app/routes/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (156 Bytes). View file
|
|
|
app/routes/__pycache__/api.cpython-312.pyc
ADDED
|
Binary file (2.97 kB). View file
|
|
|
app/routes/__pycache__/auth.cpython-312.pyc
ADDED
|
Binary file (2.64 kB). View file
|
|
|
app/routes/__pycache__/compliance.cpython-312.pyc
ADDED
|
Binary file (2.39 kB). View file
|
|
|
app/routes/__pycache__/dashboard.cpython-312.pyc
ADDED
|
Binary file (1.48 kB). View file
|
|
|
app/routes/__pycache__/google_ads.cpython-312.pyc
ADDED
|
Binary file (9.18 kB). View file
|
|
|
app/routes/__pycache__/test.cpython-312.pyc
ADDED
|
Binary file (636 Bytes). View file
|
|
|
app/routes/compliance.py
CHANGED
|
@@ -9,6 +9,13 @@ logger = logging.getLogger(__name__)
|
|
| 9 |
|
| 10 |
compliance_bp = Blueprint('compliance', __name__)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
@compliance_bp.route('/anonymize/<ad_id>', methods=['POST'])
|
| 13 |
@login_required
|
| 14 |
@admin_required
|
|
|
|
| 9 |
|
| 10 |
compliance_bp = Blueprint('compliance', __name__)
|
| 11 |
|
| 12 |
+
@compliance_bp.route('/report', methods=['GET'])
|
| 13 |
+
@login_required
|
| 14 |
+
def compliance_report():
|
| 15 |
+
"""Render the compliance report page."""
|
| 16 |
+
ads = Ad.query.all()
|
| 17 |
+
return render_template('compliance_report.html', ads=ads)
|
| 18 |
+
|
| 19 |
@compliance_bp.route('/anonymize/<ad_id>', methods=['POST'])
|
| 20 |
@login_required
|
| 21 |
@admin_required
|
app/services/__pycache__/ai_processor.cpython-312.pyc
ADDED
|
Binary file (5.78 kB). View file
|
|
|
app/services/__pycache__/google_scraper.cpython-312.pyc
ADDED
|
Binary file (8.71 kB). View file
|
|
|
app/services/ai_processor.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
| 1 |
-
import cv2
|
| 2 |
-
import pytesseract
|
| 3 |
-
from transformers import pipeline
|
| 4 |
from pathlib import Path
|
| 5 |
import logging
|
| 6 |
|
|
@@ -22,17 +19,29 @@ class AIPipeline:
|
|
| 22 |
if not (weights_path.exists() and config_path.exists()):
|
| 23 |
logger.warning("YOLOv4 files not found. Please run setup_yolo.py first.")
|
| 24 |
else:
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
except Exception as e:
|
| 28 |
logger.error(f"Error initializing AI Pipeline: {e}")
|
| 29 |
raise
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def _ensure_nlp_loaded(self):
|
| 32 |
"""Ensure NLP model is loaded before use."""
|
| 33 |
if self.nlp is None:
|
| 34 |
try:
|
| 35 |
logger.info("Loading NLP model...")
|
|
|
|
|
|
|
| 36 |
self.nlp = pipeline("text-classification", model="roberta-base")
|
| 37 |
logger.info("NLP model loaded successfully")
|
| 38 |
except Exception as e:
|
|
@@ -68,6 +77,7 @@ class AIPipeline:
|
|
| 68 |
if not media or not hasattr(media, 'type') or media.type != "image":
|
| 69 |
return None
|
| 70 |
try:
|
|
|
|
| 71 |
return pytesseract.image_to_string(media.path)
|
| 72 |
except Exception as e:
|
| 73 |
logger.error(f"OCR error: {e}")
|
|
@@ -77,6 +87,7 @@ class AIPipeline:
|
|
| 77 |
if not media or not hasattr(media, 'type') or media.type != "image" or not self.detector:
|
| 78 |
return None
|
| 79 |
try:
|
|
|
|
| 80 |
img = cv2.imread(media.path)
|
| 81 |
blob = cv2.dnn.blobFromImage(img, 1/255, (416, 416), swapRB=True, crop=False)
|
| 82 |
self.detector.setInput(blob)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from pathlib import Path
|
| 2 |
import logging
|
| 3 |
|
|
|
|
| 19 |
if not (weights_path.exists() and config_path.exists()):
|
| 20 |
logger.warning("YOLOv4 files not found. Please run setup_yolo.py first.")
|
| 21 |
else:
|
| 22 |
+
# Lazy load OpenCV
|
| 23 |
+
self._setup_detector(str(weights_path), str(config_path))
|
| 24 |
|
| 25 |
except Exception as e:
|
| 26 |
logger.error(f"Error initializing AI Pipeline: {e}")
|
| 27 |
raise
|
| 28 |
|
| 29 |
+
def _setup_detector(self, weights_path, config_path):
|
| 30 |
+
"""Set up the object detector with the given weights and config."""
|
| 31 |
+
try:
|
| 32 |
+
import cv2
|
| 33 |
+
self.detector = cv2.dnn.readNet(weights_path, config_path)
|
| 34 |
+
except Exception as e:
|
| 35 |
+
logger.error(f"Error setting up detector: {e}")
|
| 36 |
+
self.detector = None
|
| 37 |
+
|
| 38 |
def _ensure_nlp_loaded(self):
|
| 39 |
"""Ensure NLP model is loaded before use."""
|
| 40 |
if self.nlp is None:
|
| 41 |
try:
|
| 42 |
logger.info("Loading NLP model...")
|
| 43 |
+
# Import transformers only when needed
|
| 44 |
+
from transformers import pipeline
|
| 45 |
self.nlp = pipeline("text-classification", model="roberta-base")
|
| 46 |
logger.info("NLP model loaded successfully")
|
| 47 |
except Exception as e:
|
|
|
|
| 77 |
if not media or not hasattr(media, 'type') or media.type != "image":
|
| 78 |
return None
|
| 79 |
try:
|
| 80 |
+
import pytesseract
|
| 81 |
return pytesseract.image_to_string(media.path)
|
| 82 |
except Exception as e:
|
| 83 |
logger.error(f"OCR error: {e}")
|
|
|
|
| 87 |
if not media or not hasattr(media, 'type') or media.type != "image" or not self.detector:
|
| 88 |
return None
|
| 89 |
try:
|
| 90 |
+
import cv2
|
| 91 |
img = cv2.imread(media.path)
|
| 92 |
blob = cv2.dnn.blobFromImage(img, 1/255, (416, 416), swapRB=True, crop=False)
|
| 93 |
self.detector.setInput(blob)
|
app/utils/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (155 Bytes). View file
|
|
|
app/utils/__pycache__/decorators.cpython-312.pyc
ADDED
|
Binary file (2.53 kB). View file
|
|
|
app/utils/__pycache__/validators.cpython-312.pyc
ADDED
|
Binary file (1.65 kB). View file
|
|
|