creek

The AI Image Editor of 2030
commit 6ab46e163b4d5c9881c83d4bba8b0538618010fd
parent 59bde2c04e73707ddf3411dcf488e29d2342e0fb
Author: Nilotpal Gupta <nilotpalgupta0701@gmail.com>
Date:   Fri, 28 Nov 2025 00:12:29 +0530

fix python models

Diffstat:

2 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/android/app/src/main/python/analyze_layout.py b/android/app/src/main/python/analyze_layout.py @@ -227,24 +227,15 @@ def analyze_single_image(img_path): 'Diagonals & Triangles': diagonals_triangles_score(lines, contours, centroid, img.shape) } - # 5. Sort and get top 5 - sorted_features = sorted(scores.items(), key=lambda x: x[1], reverse=True) - top5 = {} - for k, v in sorted_features[:5]: - top5[k] = float(v) - - # 6. Return JSON result - result = { + return json.dumps({ "success": True, - "predictions": {k: float(v) for k, v in scores.items()}, - "best": top5, - "image_name": os.path.basename(img_path) - } - - return json.dumps(result) + "scores": scores, + "error": None + }) except Exception as e: return json.dumps({ - "error": str(e), - "success": False - }) + "success": False, + "scores": {}, + "error": str(e) + }) +\ No newline at end of file diff --git a/android/app/src/main/python/color_style_infer.py b/android/app/src/main/python/color_style_infer.py @@ -157,14 +157,14 @@ def analyze_color_style(image_path): try: model_data = _load_model_if_needed() if model_data is None: - return json.dumps({"success": False, "error": "Model failed to load"}) + return json.dumps({"success": False, "scores": {}, "error": "Model failed to load"}) if not os.path.exists(image_path): - return json.dumps({"success": False, "error": f"Image not found at: {image_path}"}) + return json.dumps({"success": False, "scores": {}, "error": f"Image not found at: {image_path}"}) img = cv2.imread(image_path) if img is None: - return json.dumps({"success": False, "error": "CV2 could not read image"}) + return json.dumps({"success": False, "scores": {}, "error": "CV2 could not read image"}) # Extract Features raw_features = { @@ -188,11 +188,11 @@ def analyze_color_style(image_path): sorted_features = sorted(results.items(), key=lambda x: x[1], reverse=True) response = { "success": True, - "predictions": {k: float(v) for k, v in results.items()}, - "best": {sorted_features[0][0]: float(sorted_features[0][1])}, + "scores": {k: float(v) for k, v in sorted_features}, #[:3] + "error": None, } return json.dumps(response, cls=NumpyEncoder) except Exception as e: - return json.dumps({"success": False, "error": f"Python Exception: {str(e)} | {traceback.format_exc()}"}) + return json.dumps({"success": False, "scores": {}, "error": f"Python Exception: {str(e)} | {traceback.format_exc()}"}) +\ No newline at end of file