Update app.py
Browse files
app.py
CHANGED
@@ -16,11 +16,11 @@ theme = gr.themes.Base(
|
|
16 |
API_KEY = os.getenv("API_KEY")
|
17 |
|
18 |
# BRAIN_TUMOR_API_URL = "https://api-inference.huggingface.co/models/Devarshi/Brain_Tumor_Classification"
|
19 |
-
|
20 |
# ALZHEIMER_API_URL = "https://api-inference.huggingface.co/models/AhmadHakami/alzheimer-image-classification-google-vit-base-patch16"
|
21 |
# headers = {"Authorization": "Bearer "+API_KEY+"", 'Content-Type': 'application/json'}
|
22 |
alzheimer_classifier = pipeline("image-classification", model="AhmadHakami/alzheimer-image-classification-google-vit-base-patch16")
|
23 |
-
breast_cancer_classifier = pipeline("image-classification", model="MUmairAB/Breast_Cancer_Detector")
|
24 |
brain_tumor_classifier = pipeline("image-classification", model="Devarshi/Brain_Tumor_Classification")
|
25 |
|
26 |
# Create a function to Detect/Classify Alzheimer
|
@@ -34,11 +34,18 @@ def classify_alzheimer(image):
|
|
34 |
|
35 |
# Create a function to Detect/Classify Breast_Cancer
|
36 |
def classify_breast_cancer(image):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
|
44 |
# Create a function to Detect/Classify Brain_Tumor
|
|
|
16 |
API_KEY = os.getenv("API_KEY")
|
17 |
|
18 |
# BRAIN_TUMOR_API_URL = "https://api-inference.huggingface.co/models/Devarshi/Brain_Tumor_Classification"
|
19 |
+
BREAST_CANCER_API_URL = "https://api-inference.huggingface.co/models/MUmairAB/Breast_Cancer_Detector"
|
20 |
# ALZHEIMER_API_URL = "https://api-inference.huggingface.co/models/AhmadHakami/alzheimer-image-classification-google-vit-base-patch16"
|
21 |
# headers = {"Authorization": "Bearer "+API_KEY+"", 'Content-Type': 'application/json'}
|
22 |
alzheimer_classifier = pipeline("image-classification", model="AhmadHakami/alzheimer-image-classification-google-vit-base-patch16")
|
23 |
+
# breast_cancer_classifier = pipeline("image-classification", model="MUmairAB/Breast_Cancer_Detector")
|
24 |
brain_tumor_classifier = pipeline("image-classification", model="Devarshi/Brain_Tumor_Classification")
|
25 |
|
26 |
# Create a function to Detect/Classify Alzheimer
|
|
|
34 |
|
35 |
# Create a function to Detect/Classify Breast_Cancer
|
36 |
def classify_breast_cancer(image):
|
37 |
+
image_data = np.array(image, dtype=np.uint8)
|
38 |
+
_, buffer = cv2.imencode('.jpg', image_data)
|
39 |
+
binary_data = buffer.tobytes()
|
40 |
+
|
41 |
+
response = requests.post(BREAST_CANCER_API_URL, headers=headers, data=binary_data)
|
42 |
+
result = {}
|
43 |
+
print(response.json())
|
44 |
+
for ele in response.json():
|
45 |
+
label, score = ele.values()
|
46 |
+
result[label] = score
|
47 |
+
|
48 |
+
return result
|
49 |
|
50 |
|
51 |
# Create a function to Detect/Classify Brain_Tumor
|