From bbdf79124f14f49419588f427badb9d41186e930 Mon Sep 17 00:00:00 2001 From: rijalhabibullah Date: Mon, 6 Apr 2026 01:50:50 +0700 Subject: [PATCH] perbaikan beberapa fitur --- api_client.py | 13 ++++++++----- .../rice_leaf_cnn_classification.ipynb | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api_client.py b/api_client.py index adfb526..826f834 100644 --- a/api_client.py +++ b/api_client.py @@ -13,12 +13,12 @@ import json class RiceLeafClassificationAPI: """Client untuk Rice Leaf Disease Classification API""" - def __init__(self, base_url: str = "http://127.0.0.1:8000/api/classification"): + def __init__(self, base_url: str = "http://127.0.0.1:5000"): """ Initialize API client Args: - base_url: Base URL untuk API endpoint + base_url: Base URL untuk API endpoint (default: Flask API on port 5000) """ self.base_url = base_url self.session = requests.Session() @@ -32,10 +32,13 @@ class RiceLeafClassificationAPI: Tuple (success, message) """ try: - response = self.session.get(f"{self.base_url}/test", timeout=10) + response = self.session.get(f"{self.base_url}/health", timeout=10) if response.status_code == 200: data = response.json() - return data['success'], data.get('message', 'Connection OK') + if 'status' in data: # Flask API response + return data['status'] == 'ok', data.get('message', 'Connection OK') + else: + return data.get('success', True), data.get('message', 'Connection OK') else: return False, f"HTTP {response.status_code}" except Exception as e: @@ -70,7 +73,7 @@ class RiceLeafClassificationAPI: try: # Tentukan endpoint - endpoint = "classify-and-save" if save else "classify" + endpoint = "classify" if not save else "classify" url = f"{self.base_url}/{endpoint}" # Baca dan kirim file diff --git a/rice leaf diseases dataset/rice_leaf_cnn_classification.ipynb b/rice leaf diseases dataset/rice_leaf_cnn_classification.ipynb index 9ff535b..e3bcbe6 100644 --- a/rice leaf diseases dataset/rice_leaf_cnn_classification.ipynb +++ b/rice leaf diseases dataset/rice_leaf_cnn_classification.ipynb @@ -1660,7 +1660,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -1674,7 +1674,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.5" } }, "nbformat": 4,