medbenhasan commited on
Commit
66df5ee
1 Parent(s): 8081a16

Update appointment.html

Browse files
Files changed (1) hide show
  1. appointment.html +24 -73
appointment.html CHANGED
@@ -136,82 +136,33 @@
136
 
137
  <!-- Appointment Start -->
138
  <h1>Speed Scan Form</h1>
139
- <form id="scanForm">
140
- <label for="imageUpload">Upload Your Medical Scan:</label>
141
- <input type="file" id="imageUpload" accept="image/*" required>
142
- <br>
143
- <label for="service">Choose the Service You Need:</label>
144
- <select id="service" required>
145
- <option value="detection">Tumor Detection</option>
146
- <option value="classification">Tumor Classification</option>
147
- </select>
148
- <br>
149
- <button type="button" onclick="startScan()">Start Scan</button>
150
- </form>
151
- <div id="result"></div>
152
- <div id="dimensions"></div>
153
-
154
- <script>
155
- async function startScan() {
156
- const fileInput = document.getElementById('imageUpload');
157
- const resultDiv = document.getElementById('result');
158
- const dimensionsDiv = document.getElementById('dimensions');
159
-
160
- if (fileInput.files.length === 0) {
161
- alert('Please upload an image file.');
162
- return;
163
- }
164
-
165
- const file = fileInput.files[0];
166
- const image = await loadImage(file);
167
-
168
- // Display image dimensions
169
- dimensionsDiv.innerHTML = `<strong>Image Dimensions:</strong> ${image.width} x ${image.height}`;
170
 
171
- try {
172
- // Load the model
173
- const model = await tf.loadLayersModel('model/ae_resnet.h5');
174
- console.log('Model loaded successfully.');
175
-
176
- // Preprocess the image
177
- const canvas = document.createElement('canvas');
178
- canvas.width = 224;
179
- canvas.height = 224;
180
- const ctx = canvas.getContext('2d');
181
- ctx.drawImage(image, 0, 0, 224, 224);
182
-
183
- // Convert to tensor
184
- const tensor = tf.browser.fromPixels(canvas)
185
- .toFloat()
186
- .expandDims(0) // Add batch dimension
187
- .div(tf.scalar(255)); // Normalize to [0, 1] range
188
-
189
- // Predict
190
- const predictions = await model.predict(tensor).data();
191
- console.log('Predictions:', predictions);
192
 
193
- // Display results
194
- const result = predictions[0] > 0.5 ? 'Tumor Detected' : 'No Tumor Detected';
195
- resultDiv.innerHTML = `<strong>Prediction Result:</strong> ${result}`;
196
- } catch (error) {
197
- console.error('Error during prediction:', error);
198
- resultDiv.innerHTML = `<strong>Prediction failed.</strong> Error: ${error.message}`;
199
- }
200
- }
201
 
202
- function loadImage(file) {
203
- return new Promise((resolve, reject) => {
204
- const reader = new FileReader();
205
- reader.onload = (event) => {
206
- const img = new Image();
207
- img.onload = () => resolve(img);
208
- img.onerror = (err) => reject(err);
209
- img.src = event.target.result;
210
- };
211
- reader.onerror = reject;
212
- reader.readAsDataURL(file);
213
- });
214
- }
 
 
 
 
215
  </script>
216
  <!-- Appointment End -->
217
 
 
136
 
137
  <!-- Appointment Start -->
138
  <h1>Speed Scan Form</h1>
139
+ <h1>Brain Tumor Detection with AI</h1>
140
+ <p>Upload an MRI image to detect if a brain tumor is present.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
+ <form id="upload-form">
143
+ <input type="file" id="file-input" accept="image/*">
144
+ <button type="submit">Submit</button>
145
+ </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
+ <p id="result"></p>
 
 
 
 
 
 
 
148
 
149
+ <script>
150
+ document.getElementById('upload-form').addEventListener('submit', function(e) {
151
+ e.preventDefault();
152
+ const fileInput = document.getElementById('file-input');
153
+ const formData = new FormData();
154
+ formData.append('file', fileInput.files[0]);
155
+
156
+ fetch('YOUR_API_URL/predict', {
157
+ method: 'POST',
158
+ body: formData
159
+ })
160
+ .then(response => response.json())
161
+ .then(data => {
162
+ document.getElementById('result').innerText = `Prediction: ${data.prediction}, Confidence: ${data.confidence}`;
163
+ })
164
+ .catch(error => console.error('Error:', error));
165
+ });
166
  </script>
167
  <!-- Appointment End -->
168