VeduCo commited on
Commit
97a07cf
·
verified ·
1 Parent(s): aeb9640

Update example.py

Browse files
Files changed (1) hide show
  1. example.py +19 -22
example.py CHANGED
@@ -1,22 +1,19 @@
1
-
2
- from shepards_gift_tool import BrainTumorClassifier
3
-
4
- # 1. Create an instance of the classifier.
5
- print("Initializing Shepard's Gift classifier...")
6
- classifier = BrainTumorClassifier()
7
- print("Classifier ready.")
8
-
9
- # 2. Define the path to the image the user wants to analyze.
10
- image_to_test = "path/to/your/mri_scan.jpg"
11
-
12
- # 3. Get the prediction.
13
- print(f"\nAnalyzing image: {image_to_test}")
14
- result = classifier.predict(image_to_test)
15
-
16
- # 4. Print the clean, simple result.
17
- print("\n--- 🏆 Analysis Complete ---")
18
- if "error" in result:
19
- print(f"An error occurred: {result['error']}")
20
- else:
21
- print(f"Predicted Class: {result['predicted_class']}")
22
- print(f"Confidence: {result['confidence']}")
 
1
+ import os
2
+ os.environ["KERAS_BACKEND"] = "tensorflow"
3
+
4
+ import keras
5
+ from huggingface_hub import hf_hub_download
6
+ from PIL import Image
7
+ import numpy as np
8
+
9
+ # 1. Download the model file
10
+ print("--- Downloading model... ---")
11
+ model_path = hf_hub_download(
12
+ repo_id="VeduCo/D-Shepard-p1-57",
13
+ filename="ShepardsGift_final_model.keras" # Important: Use the correct filename
14
+ )
15
+
16
+ # 2. Load the model
17
+ model = keras.saving.load_model(model_path)
18
+ print("--- Model loaded successfully! ---")
19
+ model.summary()