Update: Remove database dependency and optimize code
Browse files- app.py +0 -14
- requirements.txt +8 -7
app.py
CHANGED
|
@@ -12,7 +12,6 @@ import logging
|
|
| 12 |
from dotenv import load_dotenv
|
| 13 |
from mo_optimizer import MOPrintOptimizer
|
| 14 |
from core.analysis import DefectDetector, ImageProcessor
|
| 15 |
-
from core.database import PrintJob
|
| 16 |
from datetime import datetime
|
| 17 |
import requests
|
| 18 |
from PIL import Image
|
|
@@ -106,19 +105,6 @@ def on_message(client, userdata, message):
|
|
| 106 |
})
|
| 107 |
# update interface display
|
| 108 |
s3_image.update(value=image_url)
|
| 109 |
-
|
| 110 |
-
# record to database
|
| 111 |
-
if hasattr(demo, 'db_manager'):
|
| 112 |
-
job = demo.db_manager.session.query(PrintJob).filter_by(
|
| 113 |
-
square_id=data.get("square_id"),
|
| 114 |
-
status="printing"
|
| 115 |
-
).first()
|
| 116 |
-
if job:
|
| 117 |
-
job.match_image(
|
| 118 |
-
image_url,
|
| 119 |
-
datetime.strptime(data.get("timestamp"), "%Y-%m-%d %H:%M:%S")
|
| 120 |
-
)
|
| 121 |
-
demo.db_manager.session.commit()
|
| 122 |
|
| 123 |
elif "status" in message.topic:
|
| 124 |
# update status
|
|
|
|
| 12 |
from dotenv import load_dotenv
|
| 13 |
from mo_optimizer import MOPrintOptimizer
|
| 14 |
from core.analysis import DefectDetector, ImageProcessor
|
|
|
|
| 15 |
from datetime import datetime
|
| 16 |
import requests
|
| 17 |
from PIL import Image
|
|
|
|
| 105 |
})
|
| 106 |
# update interface display
|
| 107 |
s3_image.update(value=image_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
elif "status" in message.topic:
|
| 110 |
# update status
|
requirements.txt
CHANGED
|
@@ -2,25 +2,26 @@
|
|
| 2 |
gradio>=4.0.0
|
| 3 |
|
| 4 |
# Core Data Processing
|
| 5 |
-
numpy>=1.
|
| 6 |
pandas>=1.3.0
|
| 7 |
scipy>=1.7.0
|
| 8 |
|
| 9 |
# Image Processing
|
| 10 |
-
opencv-python
|
| 11 |
-
scikit-image>=0.
|
| 12 |
-
Pillow>=
|
| 13 |
|
| 14 |
# Machine Learning
|
| 15 |
-
scikit-learn>=
|
| 16 |
hdbscan>=0.8.29
|
| 17 |
|
| 18 |
# Communication
|
| 19 |
paho-mqtt>=1.6.1
|
| 20 |
|
| 21 |
# Configuration
|
| 22 |
-
python-dotenv>=0.
|
| 23 |
|
| 24 |
# Utilities
|
| 25 |
tqdm>=4.62.0
|
| 26 |
-
matplotlib>=3.4.0
|
|
|
|
|
|
| 2 |
gradio>=4.0.0
|
| 3 |
|
| 4 |
# Core Data Processing
|
| 5 |
+
numpy>=1.24.0
|
| 6 |
pandas>=1.3.0
|
| 7 |
scipy>=1.7.0
|
| 8 |
|
| 9 |
# Image Processing
|
| 10 |
+
opencv-python>=4.8.0
|
| 11 |
+
scikit-image>=0.21.0
|
| 12 |
+
Pillow>=10.0.0
|
| 13 |
|
| 14 |
# Machine Learning
|
| 15 |
+
scikit-learn>=1.3.0
|
| 16 |
hdbscan>=0.8.29
|
| 17 |
|
| 18 |
# Communication
|
| 19 |
paho-mqtt>=1.6.1
|
| 20 |
|
| 21 |
# Configuration
|
| 22 |
+
python-dotenv>=1.0.0
|
| 23 |
|
| 24 |
# Utilities
|
| 25 |
tqdm>=4.62.0
|
| 26 |
+
matplotlib>=3.4.0
|
| 27 |
+
requests>=2.31.0
|