Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prediction #52

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 34 additions & 39 deletions templates/camera.html
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<title>Camera OCR</title>
</head>
<body>
<!-- Include other HTML elements -->
{% extends 'base.html' %} {% import "bootstrap/wtf.html" as wtf %} {% block
title %}Camera{% endblock title %} {% block body %}
<!-- Include other HTML elements -->
<video id="cameraFeed" autoplay></video>
<button id="captureButton">Capture</button>
<div id="result"></div>

<script>
const video = document.getElementById('cameraFeed');
const captureButton = document.getElementById('captureButton');
const resultDiv = document.getElementById('result');

async function startCamera() {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
video.srcObject = stream;
}

captureButton.addEventListener('click', async () => {
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
const ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

const imageData = canvas.toDataURL('image/jpeg'); // Convert to image data

// Send imageData to backend
const response = await fetch('/process_image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ image: imageData }),
});

const data = await response.json();
resultDiv.textContent = data.text; // Display sample text
const video = document.getElementById("cameraFeed");
const captureButton = document.getElementById("captureButton");
const resultDiv = document.getElementById("result");

async function startCamera() {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
video.srcObject = stream;
}

captureButton.addEventListener("click", async () => {
const canvas = document.createElement("canvas");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
const ctx = canvas.getContext("2d");
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

const imageData = canvas.toDataURL("image/jpeg"); // Convert to image data

// Send imageData to backend
const response = await fetch("/process_image", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ image: imageData }),
});

startCamera();
const data = await response.json();
resultDiv.textContent = data.text; // Display sample text
});

startCamera();
</script>

</body>
</html>
{% endblock body %}
77 changes: 24 additions & 53 deletions templates/prediction.html
Original file line number Diff line number Diff line change
@@ -1,59 +1,30 @@
{% extends 'base.html' %} {% import "bootstrap/wtf.html" as wtf %} {% block
title %}Prediction{% endblock title %} {% block body %}

<h1>Disease Predictor</h1>
<!-- Inline styles for the form -->
<form
method="POST"
action="{{url_for('disease_prediction')}}"
style="
display: flex;
flex-direction: column;
align-items: center;
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
background: linear-gradient(to bottom, #ffffff, #f9f9f9);
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
max-width: 400px;
border-radius: 10px;
"
>
{% extends 'base.html' %}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}Prediction{% endblock title %}

{% block body %}

<h1 style="text-align: center; color: #333; text-shadow: 2px 2px 4px #000;">Disease Predictor</h1>

<form method="POST" action="{{url_for('disease_prediction')}}"
style="display: flex; flex-direction: column; align-items: center; margin: 40px auto; padding: 30px; border: 3px solid #ccc; border-radius: 20px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); background: linear-gradient(to bottom, #fafafa, #f0f0f0); max-width: 400px; transition: all 0.3s ease;">

{{ form.hidden_tag() }}
<label for="symptoms" style="font-weight: bold; margin-bottom: 10px"
>Select Symptoms:</label
>
{{ form.symptomp_list(style="width: 100%; padding: 10px; margin-bottom: 20px;
border: 1px solid #ccc; border-radius: 5px;") }}
<br />
<button
type="submit"
style="
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
"
>
Predict Disease
</button>

<label for="symptoms" style="font-size: 1.2rem; font-weight: bold; margin-bottom: 20px; color: #333;">Select Symptoms:</label>

{{ form.symptomp_list(style="width: 100%; padding: 12px; margin-bottom: 20px; border: 2px solid #ccc; border-radius: 10px; box-shadow: inset 0 1px 1px rgba(0,0,0,.075); transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;") }}

<button type="submit" style="background-color: #007bff; color: white; border: none; padding: 12px 24px; font-size: 1rem; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,.2); cursor: pointer; transition: background-color 0.3s ease; hover: background-color: #0056b3;">Predict Disease</button>

</form>
<!-- Inline styles for the result div -->
<div
id="result"
style="
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
background: linear-gradient(to bottom, #ffffff, #f9f9f9);
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
max-width: 400px;
border-radius: 10px;
"
>

<div id="result"
style="margin: 40px auto; padding: 30px; border: 3px solid #ccc; border-radius: 20px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); background: linear-gradient(to bottom, #fafafa, #f0f0f0); max-width: 400px; transition: all 0.3s ease;">

{{result}}

</div>

{% endblock body %}