Spaces:
Sleeping
Sleeping
Duplicate from Jishnnu/Detecting_COVID-19
Browse filesCo-authored-by: Jishnu Pillai Anilkumar <[email protected]>
- .gitattributes +34 -0
- Covid Dataset.csv +0 -0
- README.md +13 -0
- ann_model.h5 +3 -0
- app.py +69 -0
- dt_classifier_model.h5 +3 -0
- knn_classifier_model.h5 +3 -0
- logreg_model.h5 +3 -0
- requirements.txt +4 -0
- rf_classifier_model.h5 +3 -0
- stacking_classifier_model.h5 +3 -0
- svm_classifier_model.h5 +3 -0
- voting_classifier_model.h5 +3 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Covid Dataset.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Detecting COVID-19
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.29.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: Jishnnu/Detecting_COVID-19
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
ann_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:17e86be19b8aee961a1e8226f2ce26e3e34abbcd4ae62ae79398854d25ea21db
|
3 |
+
size 56008
|
app.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import joblib
|
4 |
+
from sklearn.preprocessing import LabelEncoder
|
5 |
+
|
6 |
+
# Load the dataset and get the column names
|
7 |
+
dataset = pd.read_csv('Covid Dataset.csv')
|
8 |
+
columns_to_drop = ['Wearing Masks', 'Sanitization from Market']
|
9 |
+
dataset = dataset.drop(columns_to_drop, axis=1)
|
10 |
+
column_names = dataset.columns.tolist()
|
11 |
+
|
12 |
+
# Define a function to make predictions using the selected models
|
13 |
+
def predict_covid(*symptoms):
|
14 |
+
# Convert None values to Falses
|
15 |
+
symptoms = [False if symptom is None else symptom for symptom in symptoms]
|
16 |
+
|
17 |
+
if sum(symptoms) == 0:
|
18 |
+
return "COVID-19 Negative"
|
19 |
+
|
20 |
+
# Load the saved models
|
21 |
+
model_logreg = joblib.load('logreg_model.h5')
|
22 |
+
model_rf_classifier = joblib.load('rf_classifier_model.h5')
|
23 |
+
model_dt_classifier = joblib.load('dt_classifier_model.h5')
|
24 |
+
model_knn_classifier = joblib.load('knn_classifier_model.h5')
|
25 |
+
model_svm_classifier = joblib.load('svm_classifier_model.h5')
|
26 |
+
model_ann_classifier = joblib.load('ann_model.h5')
|
27 |
+
voting_classifier = joblib.load('voting_classifier_model.h5')
|
28 |
+
stacking_classifier = joblib.load('stacking_classifier_model.h5')
|
29 |
+
|
30 |
+
# Prepare the input data
|
31 |
+
label_encoder = LabelEncoder()
|
32 |
+
input_data = pd.DataFrame([list(symptoms)], columns=column_names[:-1])
|
33 |
+
encoded_input_data = input_data.copy()
|
34 |
+
for column in encoded_input_data.columns:
|
35 |
+
if encoded_input_data[column].dtype == object:
|
36 |
+
encoded_input_data[column] = label_encoder.transform(encoded_input_data[column])
|
37 |
+
|
38 |
+
# Make predictions using the selected models
|
39 |
+
logreg_prediction = int(model_logreg.predict(encoded_input_data)[0])
|
40 |
+
rf_prediction = int(model_rf_classifier.predict(encoded_input_data)[0])
|
41 |
+
dt_prediction = int(model_dt_classifier.predict(encoded_input_data)[0])
|
42 |
+
knn_prediction = int(model_knn_classifier.predict(encoded_input_data)[0])
|
43 |
+
svm_prediction = int(model_svm_classifier.predict(encoded_input_data)[0])
|
44 |
+
ann_prediction = int(model_ann_classifier.predict(encoded_input_data)[0])
|
45 |
+
voting_prediction = int(voting_classifier.predict(encoded_input_data)[0])
|
46 |
+
stacking_prediction = int(stacking_classifier.predict(encoded_input_data)[0])
|
47 |
+
|
48 |
+
# Determine the overall prediction
|
49 |
+
prediction = 1 if sum([logreg_prediction, rf_prediction, dt_prediction, knn_prediction,
|
50 |
+
svm_prediction, ann_prediction, voting_prediction, stacking_prediction]) >= 4 else 0
|
51 |
+
|
52 |
+
# Return the prediction
|
53 |
+
return "COVID-19 Positive" if prediction == 1 else "COVID-19 Negative"
|
54 |
+
|
55 |
+
# Create a list of checkboxes for the dataset columns
|
56 |
+
checkboxes = [gr.inputs.Checkbox(label=column_name) for column_name in column_names[:-1]]
|
57 |
+
|
58 |
+
# Create the input interface with the checkboxes
|
59 |
+
inputs = checkboxes
|
60 |
+
|
61 |
+
# Create the output interface with the predicted labels
|
62 |
+
outputs = gr.outputs.Label(num_top_classes=1, label="COVID-19 Status")
|
63 |
+
title = "COVID-19 Detection"
|
64 |
+
description = "Select your symptoms and contact history to check if you have COVID-19"
|
65 |
+
final_model = gr.Interface(fn=predict_covid, inputs=inputs, outputs=outputs, title=title, description=description)
|
66 |
+
|
67 |
+
# Create the Gradio app
|
68 |
+
if __name__ == '__main__':
|
69 |
+
final_model.launch(inline=False)
|
dt_classifier_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:22a8226d1502588b878b9793735203fff1477577573bd1db93d984f9785f8610
|
3 |
+
size 7945
|
knn_classifier_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e54a043f4a9c4ffd391b3a53dcbd975382fd6fbbcda4a837d46a478e7a7aa061
|
3 |
+
size 744036
|
logreg_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c552e526f979da4ec6e990943ded54b960bfa9473510f1bbbe2049422d3d4f64
|
3 |
+
size 991
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
pandas
|
3 |
+
joblib
|
4 |
+
scikit-learn
|
rf_classifier_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5a352e0c96d95d578575036697ee75a3212ea7dc91770b2cda5fac29f131bcbe
|
3 |
+
size 1189097
|
stacking_classifier_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27cd49868848d0fbf5b420cd64d22e9190501bf284bce9e37bf62d4acdb615d8
|
3 |
+
size 4133300
|
svm_classifier_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a4521622ccdc2c7899b6d09666ffac4dd9316023720504ced326927717f0ad8d
|
3 |
+
size 66091
|
voting_classifier_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27cd49868848d0fbf5b420cd64d22e9190501bf284bce9e37bf62d4acdb615d8
|
3 |
+
size 4133300
|