Update app.py
Browse files
app.py
CHANGED
@@ -18,19 +18,26 @@ API_KEY = os.getenv("API_KEY")
|
|
18 |
|
19 |
# BRAIN_TUMOR_API_URL = "https://api-inference.huggingface.co/models/Devarshi/Brain_Tumor_Classification"
|
20 |
BREAST_CANCER_API_URL = "https://api-inference.huggingface.co/models/MUmairAB/Breast_Cancer_Detector"
|
21 |
-
|
22 |
headers = {"Authorization": "Bearer "+API_KEY+"", 'Content-Type': 'application/json'}
|
23 |
-
alzheimer_classifier = pipeline("image-classification", model="dewifaj/alzheimer_mri_classification")
|
24 |
# breast_cancer_classifier = pipeline("image-classification", model="MUmairAB/Breast_Cancer_Detector")
|
25 |
brain_tumor_classifier = pipeline("image-classification", model="Devarshi/Brain_Tumor_Classification")
|
26 |
|
27 |
# Create a function to Detect/Classify Alzheimer
|
28 |
def classify_alzheimer(image):
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
# Create a function to Detect/Classify Breast_Cancer
|
|
|
18 |
|
19 |
# BRAIN_TUMOR_API_URL = "https://api-inference.huggingface.co/models/Devarshi/Brain_Tumor_Classification"
|
20 |
BREAST_CANCER_API_URL = "https://api-inference.huggingface.co/models/MUmairAB/Breast_Cancer_Detector"
|
21 |
+
ALZHEIMER_API_URL = "https://api-inference.huggingface.co/models/dewifaj/alzheimer_mri_classification"
|
22 |
headers = {"Authorization": "Bearer "+API_KEY+"", 'Content-Type': 'application/json'}
|
23 |
+
# alzheimer_classifier = pipeline("image-classification", model="dewifaj/alzheimer_mri_classification")
|
24 |
# breast_cancer_classifier = pipeline("image-classification", model="MUmairAB/Breast_Cancer_Detector")
|
25 |
brain_tumor_classifier = pipeline("image-classification", model="Devarshi/Brain_Tumor_Classification")
|
26 |
|
27 |
# Create a function to Detect/Classify Alzheimer
|
28 |
def classify_alzheimer(image):
|
29 |
+
image_data = np.array(image, dtype=np.uint8)
|
30 |
+
_, buffer = cv2.imencode('.jpg', image_data)
|
31 |
+
binary_data = buffer.tobytes()
|
32 |
+
|
33 |
+
response = requests.post(ALZHEIMER_API_URL, headers=headers, data=binary_data)
|
34 |
+
result = {}
|
35 |
+
print(response.json())
|
36 |
+
for ele in response.json():
|
37 |
+
label, score = ele.values()
|
38 |
+
result[label] = score
|
39 |
+
|
40 |
+
return result
|
41 |
|
42 |
|
43 |
# Create a function to Detect/Classify Breast_Cancer
|