Professional Documents
Culture Documents
Documentation 64
Documentation 64
CERTIFICATE
External Examiner
DECLARATION
We here by declare that the project entitled, “HEART DISEASES PREDICTION” done at
VIVA College, has not been in any case duplicated to submit to any other university for the award of
any degree. To the best of my knowledge other than me, no one has submitted to any other university.
The project is done in partial fulfilment of the requirements for the award of degree of BACHELOR
OF SCIENCE (COMPUTER SCIENCE) to be submitted as final semester project as part of our
curriculum.
AJAI RADHAKRISHNAN
ACKNOWLEDGEMENT
The gratification and joy that accompanies the successful completion of any task would be
incomplete without the humble and deep-felt expression of gratitude to everyone who has made it
possible.
After month of hard work, I am very happy to present my last year's project. But it wouldn't be
right to do so without thanking those who have helped me in completion of my project. So I would
like to take full advantage of this opportunity to think each and every person who helped me
throughout the completion of my project that is respected teachers, friends, and family.
I express my sincere gratitude to towards our internal guide DR. Priyanka Brid who gave me
unconditional support from the starting point of the project.
I give my special thanks to my Respected H.O.D MRS. Jagruti Raut for encouraging me to
complete this project, guiding me and helping me out through all the obstacles in the project.
I would sincerely thanks to the peoples who guided us throughout the course for this project
work. I would like to express our sincere thanks to DR. Priyanka Brid for his guidance,
encouragement, co-operation and suggestions given to us at progressing stages of the project.
INDEX
2. MODULES 6
3. REQUIREMENTS(H/W -S/W) 7
4. GANTT CHART 8
5. SEQUENCE DIAGRAM 9
6. ACTIVITY DIAGRAM 10
7. CODING 11
8. SCREENSHOTS 20
10. REFERENCE 23
INTRODUCTION :-
Heart disease is a major public health problem worldwide, and accurate prediction of the risk of heart
disease is essential for prevention and early detection. Machine learning (ML) algorithms have the
potential to improve the accuracy of heart disease prediction by analyzing large amounts of data and
identifying complex patterns and relationships. Once the dataset has been assembled, it can be split into
training and testing sets, and a machine learning algorithm can be trained on the training set to learn the
patterns and relationships between the features and outcomes. There are various machine learning
algorithms that can be used for heart disease prediction, including decision trees, logistic regression,
support vector machines, and neural networks.Overall, machine learning has the potential to
significantly improve heart disease prediction and prevention by identifying individuals at high risk for
developing heart disease and enabling targeted interventions to reduce that risk.
REQUIREMENTS:-
HARDWARE–
● Windows – version 7 or +
● RAM– 2GB or more
SOFTWARE –
● Visual Studio Code for Integrated Development Environment.
● Browser for accessing the web application.
FRONT END-
HTML
CSS FRAMEWORK - BOOTSTRAP
JAVASCRIPT. REACT
BACK END-
Programming language - PYTHON. .
Framework – FAST API.
GANTT CHART:-
SEQUENCE DIAGRAM: -
ACTIVITY DIAGRAM:-
CODING:-
BACKEND:
main.py (contain API relates codes)
import uvicorn
import numpy as np
api = FastAPI()
api.add_middleware(
CORSMiddleware,
allow_origins=ALLOWED_ORIGINS,
allow_credentials=ALLOWED_CREDENTIALS,
allow_methods=ALLOWED_METHODS,
allow_headers=ALLOWED_HEADERS,
)
model = load_model("potatoes.h5")
@api.get("/ping")
async def ping():
return "Hello, I'm alive"
@api.post("/api/predict")
async def predict(
file: UploadFile = File(...)
):
image_array = image_to_ndarray(await file.read())
image_batch = np.expand_dims(image_array, 0)
predictions = model.predict(image_batch)
predicted_class = CLASS_NAMES[np.argmax(predictions[0])]
confidence = np.ndarray.max(predictions[0]).item()
return {
'class': predicted_class,
'confidence': confidence
}
if __name__ == "__main__":
uvicorn.run(api, host="localhost", port=8000)
BASE_DIR = Path(__file__).resolve().parent
MODEL_DIR = BASE_DIR / "models"
CLASS_NAMES = ['Early Blight', 'Late Blight', 'Healthy']
# Cors
ALLOWED_METHODS = ['*']
ALLOWED_HEADERS = ['*']
ALLOWED_CREDENTIALS = True
ALLOWED_ORIGINS = ['*']
import numpy as np
FRONTEND:
grow: {
flexGrow: 1,
},
clearButton: {
width: "-webkit-fill-available",
borderRadius: "15px",
padding: "15px 22px",
color: "#000000a6",
fontSize: "20px",
fontWeight: 900,
},
root: {
maxWidth: 345,
flexGrow: 1,
},
media: {
height: 400,
},
paper: {
padding: theme.spacing(2),
margin: 'auto',
maxWidth: 500,
},
gridContainer: {
justifyContent: "center",
padding: "4em 1em 0 1em",
},
mainContainer: {
backgroundImage: `url(${image})`,
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
backgroundSize: 'auto',
height: "100vh",
overflow: "hidden",
backgroundAttachment: 'fixed',
},
imageCard: {
margin: "auto",
maxWidth: 400,
height: 500,
backgroundColor: 'transparent',
boxShadow: '0px 9px 70px 0px rgb(0 0 0 / 30%) !important',
borderRadius: '15px',
},
imageCardEmpty: {
height: 'auto',
},
noImage: {
margin: "auto",
width: 400,
height: "400 !important",
},
input: {
display: 'none',
},
uploadIcon: {
background: 'white',
},
tableContainer: {
backgroundColor: 'transparent !important',
boxShadow: 'none !important',
},
table: {
backgroundColor: 'transparent !important',
},
tableHead: {
backgroundColor: 'transparent !important',
},
tableRow: {
backgroundColor: 'transparent !important',
},
tableCell: {
fontSize: '22px',
backgroundColor: 'transparent !important',
borderColor: 'transparent !important',
color: '#000000a6 !important',
fontWeight: 'bolder',
padding: '1px 24px 1px 16px',
},
tableCell1: {
fontSize: '14px',
backgroundColor: 'transparent !important',
borderColor: 'transparent !important',
color: '#000000a6 !important',
fontWeight: 'bolder',
padding: '1px 24px 1px 16px',
},
tableBody: {
backgroundColor: 'transparent !important',
},
text: {
color: 'white !important',
textAlign: 'center',
},
buttonGrid: {
maxWidth: "416px",
width: "100%",
},
detail: {
backgroundColor: 'white',
display: 'flex',
justifyContent: 'center',
flexDirection: 'column',
alignItems: 'center',
},
appbar: {
background: '#363636',
boxShadow: 'none',
color: 'white'
},
loader: {
color: '#be6a77 !important',
}
}));
export const ImageUpload = () => {
const classes = useStyles();
const [selectedFile, setSelectedFile] = useState();
const [preview, setPreview] = useState();
const [data, setData] = useState();
const [image, setImage] = useState(false);
const [isLoading, setIsloading] = useState(false);
let confidence = 0;
setData(res.data);
}
setIsloading(false);
}
}
useEffect(() => {
if (!selectedFile) {
setPreview(undefined);
return;
}
const objectUrl = URL.createObjectURL(selectedFile);
setPreview(objectUrl);
}, [selectedFile]);
useEffect(() => {
if (!preview) {
return;
}
setIsloading(true);
sendFile();
}, [preview]);
if (data) {
confidence = (parseFloat(data.confidence) * 100).toFixed(2);
return (
<React.Fragment>
<AppBar position="static" className={classes.appbar}>
<Toolbar>
<Typography className={classes.title} variant="h6" noWrap>
Potato Disease Classification
</Typography>
<div className={classes.grow} />
<Avatar src={logo}></Avatar>
</Toolbar>
</AppBar>
<Container maxWidth={false} className={classes.mainContainer} disableGutters={true}>
<Grid
className={classes.gridContainer}
container
direction="row"
justify="center"
alignItems="center"
spacing={2}
>
<Grid item xs={12}>
<Card className={`${classes.imageCard} ${!image ? classes.imageCardEmpty : ''}`}>
{image && <CardActionArea>
<CardMedia
className={classes.media}
image={preview}
component="image"
title="Contemplative Reptile"
/>
</CardActionArea>
}
{!image && <CardContent className={classes.content}>
<DropzoneArea
acceptedFiles={['image/*']}
dropzoneText={"Drag and drop an image of a potato plant leaf to process"}
onChange={onSelectFile}
/>
</CardContent>}
{data && <CardContent className={classes.detail}>
<TableContainer component={Paper} className={classes.tableContainer}>
<Table className={classes.table} size="small" aria-label="simple table">
<TableHead className={classes.tableHead}>
<TableRow className={classes.tableRow}>
<TableCell className={classes.tableCell1}>Label:</TableCell>
<TableCell align="right" className={classes.tableCell1}>Confidence:</TableCell>
</TableRow>
</TableHead>
<TableBody className={classes.tableBody}>
<TableRow className={classes.tableRow}>
<TableCell component="th" scope="row" className={classes.tableCell}>
{data.class}
</TableCell>
<TableCell align="right" className={classes.tableCell}>{confidence}%</TableCell>
</TableRow>
</TableBody>
</Table>
</TableContainer>
</CardContent>}
{isLoading && <CardContent className={classes.detail}>
<CircularProgress color="secondary" className={classes.loader} />
<Typography className={classes.title} variant="h6" noWrap>
Processing
</Typography>
</CardContent>}
</Card>
</Grid>
{data &&
<Grid item className={classes.buttonGrid} >
SCREENSHOTS:-
PROCESSING SCREEN
REFERENCE:-
1. WWW.GOOGLE.COM
2. WWW.YOUTUBE.COM
3. WWW.GITHUB.COM