Compare commits
4 Commits
c6cec3dede
...
c39b811a3c
| Author | SHA1 | Date | |
|---|---|---|---|
| c39b811a3c | |||
| b0a6c4d2ec | |||
| 0b1971ed0b | |||
| d6951cbbcf |
+3
-3
@@ -29,10 +29,10 @@ curl -X POST "https://smartwave.matthiasg.dev/alert" \
|
|||||||
## Jobs
|
## Jobs
|
||||||
|
|
||||||
### Trigger Server CVE Audit
|
### Trigger Server CVE Audit
|
||||||
`curl http://smartwave.matthiasg.dev/debug/run-job/server_cve_audit_job`
|
`curl https://smartwave.matthiasg.dev/debug/run-job/server_cve_audit_job`
|
||||||
|
|
||||||
### Trigger Client IP Audit
|
### Trigger Client IP Audit
|
||||||
`curl http://smartwave.matthiasg.dev/debug/run-job/client_ip_audit_job`
|
`curl https://smartwave.matthiasg.dev/debug/run-job/client_ip_audit_job`
|
||||||
|
|
||||||
### Trigger Telemetry Request
|
### Trigger Telemetry Request
|
||||||
`curl http://smartwave.matthiasg.dev/debug/run-job/request_telemetry_job`
|
`curl https://smartwave.matthiasg.dev/debug/run-job/request_telemetry_job`
|
||||||
@@ -10,7 +10,7 @@ class MicrowaveDishAnalyzer:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Constant scale ratio: Centimeters per Pixel.
|
# Constant scale ratio: Centimeters per Pixel.
|
||||||
CM_PER_PIXEL: float = 0.002592593
|
CM_PER_PIXEL: float = 0.005925926
|
||||||
|
|
||||||
def __init__(self, cm_per_pixel: Optional[float] = None):
|
def __init__(self, cm_per_pixel: Optional[float] = None):
|
||||||
if cm_per_pixel is not None:
|
if cm_per_pixel is not None:
|
||||||
|
|||||||
+22
-14
@@ -3,34 +3,42 @@ from pydantic import BaseModel, Field
|
|||||||
from APIs.aichat import generate
|
from APIs.aichat import generate
|
||||||
import shared.config as config
|
import shared.config as config
|
||||||
|
|
||||||
|
class UtensilMaterialCheck(BaseModel):
|
||||||
|
object_name: str = Field(
|
||||||
|
description="Name of utensil or container seen (e.g., spoon, fork, tray)."
|
||||||
|
)
|
||||||
|
is_metal: bool = Field(
|
||||||
|
description="True ONLY if the object is made of metal, stainless steel, or aluminum."
|
||||||
|
)
|
||||||
|
|
||||||
class DishSafetyResult(BaseModel):
|
class DishSafetyResult(BaseModel):
|
||||||
visible_objects: list[str] = Field(
|
utensils_and_containers: list[UtensilMaterialCheck] = Field(
|
||||||
description="List physical container items and utensils visible in the image."
|
description="List each visible non-food object and check if it is made of metal."
|
||||||
)
|
)
|
||||||
material_analysis: str = Field(
|
material_analysis: str = Field(
|
||||||
description="Brief description of container material (e.g., standard plastic tray, glass bowl)."
|
description="Short description of the materials present."
|
||||||
)
|
)
|
||||||
detected_hazards: list[str] = Field(
|
detected_hazards: list[str] = Field(
|
||||||
description="List of visually confirmed metal or foil hazards. MUST be empty [] if no metal or foil is present."
|
description="List objects from utensils_and_containers where is_metal is True."
|
||||||
)
|
)
|
||||||
is_safe: bool = Field(
|
is_safe: bool = Field(
|
||||||
description="Set to True if detected_hazards is empty. Set to False ONLY if metal or aluminum foil is present."
|
description="True if detected_hazards is completely empty []. False if ANY metal is found."
|
||||||
)
|
)
|
||||||
warning_message: str = Field(
|
warning_message: str = Field(
|
||||||
description="Short warning if is_safe is False, otherwise an empty string."
|
description="If is_safe is False, set to 'REMOVE METAL UTENSIL OR FOIL BEFORE MICROWAVING'. Otherwise empty ''."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_dish_safety(image_path: str) -> dict:
|
def check_dish_safety(image_path: str) -> dict:
|
||||||
prompt = (
|
prompt = (
|
||||||
"Analyze this food image for microwave safety.\n\n"
|
"Analyze this microwave dish image strictly for EQUIPMENT DAMAGE HAZARDS (Metal, Steel, Aluminum Foil).\n\n"
|
||||||
"DEFAULT ASSUMPTION:\n"
|
"GOAL:\n"
|
||||||
"- Assume the dish is SAFE (is_safe = True, detected_hazards = []).\n"
|
"Identify if any metallic item (metal spoon, fork, knife, aluminum foil, wire) is inside the dish.\n\n"
|
||||||
"- Standard food (meat, vegetables, potatoes) and standard containers (black plastic meal trays, plastic bowls, ceramic, glass) are 100% SAFE for microwaves.\n\n"
|
"RULES:\n"
|
||||||
"STRICT HAZARD RULE:\n"
|
"1. Examine all utensils carefully, even in dim lighting or dark spots.\n"
|
||||||
"- Flag as UNSAFE ONLY if you can literally see actual metal cutlery (metal spoon/fork/knife), aluminum foil packaging, or metal foil trim in the image.\n"
|
"2. Spoons, forks, and knives are often STAINLESS STEEL / METAL. If a spoon or fork is visible, mark is_metal = True unless it is clearly bright colored plastic.\n"
|
||||||
"- Do NOT invent or hallucinate hazards. If you do not see shiny metal or aluminum foil, detected_hazards MUST be an empty list []."
|
"3. Ignore chemical or health concerns (plastic cancer risks are IRRELEVANT). Focus ONLY on spark/fire hazards (metal, foil).\n"
|
||||||
|
"4. If ANY utensil is metal: set is_metal=True, add it to detected_hazards, and set is_safe=False."
|
||||||
)
|
)
|
||||||
|
|
||||||
response_raw = generate(
|
response_raw = generate(
|
||||||
|
|||||||
@@ -817,16 +817,16 @@ async def monitor_dish_height_task():
|
|||||||
|
|
||||||
if dist is not None:
|
if dist is not None:
|
||||||
# Hysteresis Thresholds:
|
# Hysteresis Thresholds:
|
||||||
# - Must be > 2.5 cm to detect dish insertion
|
# - Must be > 1.2 cm to detect dish insertion
|
||||||
# - Must be < 1.2 cm to detect dish removal
|
# - Must be < 0.8 cm to detect dish removal
|
||||||
if dist > 2.5:
|
if dist > 1.2:
|
||||||
consecutive_present += 1
|
consecutive_present += 1
|
||||||
consecutive_absent = 0
|
consecutive_absent = 0
|
||||||
elif dist < 1.2:
|
elif dist < 0.8:
|
||||||
consecutive_absent += 1
|
consecutive_absent += 1
|
||||||
consecutive_present = 0
|
consecutive_present = 0
|
||||||
else:
|
else:
|
||||||
# Dead-zone (1.2cm to 2.5cm) -> Noise buffer
|
# Dead-zone (1.2cm to 0.8cm) -> Noise buffer
|
||||||
consecutive_present = 0
|
consecutive_present = 0
|
||||||
consecutive_absent = 0
|
consecutive_absent = 0
|
||||||
|
|
||||||
@@ -848,7 +848,7 @@ async def monitor_dish_height_task():
|
|||||||
ir_data_cache.pop(mw_id, None)
|
ir_data_cache.pop(mw_id, None)
|
||||||
ir_data_events.pop(mw_id, None)
|
ir_data_events.pop(mw_id, None)
|
||||||
|
|
||||||
await asyncio.sleep(0.3)
|
await asyncio.sleep(0.7)
|
||||||
|
|
||||||
# --- BOOTSTRAP ---
|
# --- BOOTSTRAP ---
|
||||||
async def main():
|
async def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user