atlury commited on
Commit
3633b59
·
verified ·
1 Parent(s): 076b6ec

Upload 13 files

Browse files
digital.human.video.css CHANGED
@@ -420,3 +420,55 @@
420
  max-height: 150px;
421
  }
422
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  max-height: 150px;
421
  }
422
  }
423
+
424
+
425
+ /* New: Image Upload and Canvas Section Styling */
426
+ .video-image-section {
427
+ flex: 1;
428
+ display: flex;
429
+ flex-direction: column;
430
+ gap: 15px;
431
+ background-color: #ffffff;
432
+ padding: 15px;
433
+ border-radius: 12px;
434
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
435
+ transition: background 0.3s, box-shadow 0.3s;
436
+ }
437
+
438
+ .video-image-section h3 {
439
+ margin-bottom: 10px;
440
+ color: #00796B;
441
+ }
442
+
443
+ #video-image-upload {
444
+ padding: 10px;
445
+ border: 1px solid #cccccc;
446
+ border-radius: 8px;
447
+ font-size: 1em;
448
+ transition: border-color 0.3s, box-shadow 0.3s;
449
+ }
450
+
451
+ #video-image-upload:hover {
452
+ border-color: #00796B;
453
+ box-shadow: 0 0 5px rgba(0, 121, 107, 0.5);
454
+ }
455
+
456
+ #video-image-canvas {
457
+ width: 100%;
458
+ height: auto;
459
+ border: 1px solid #e0e0e0;
460
+ border-radius: 12px;
461
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
462
+ background-color: #f9f9f9;
463
+ }
464
+
465
+ @media (max-width: 800px) {
466
+ .video-card {
467
+ flex-direction: column;
468
+ }
469
+
470
+ /* Adjust Image Section for Smaller Screens */
471
+ .video-image-section {
472
+ width: 100%;
473
+ }
474
+ }
digital.human.video.js CHANGED
@@ -14,7 +14,7 @@ document.addEventListener("DOMContentLoaded", () => {
14
  const videoAvailableModels = webllm.prebuiltAppConfig.model_list.map(
15
  (m) => m.model_id
16
  );
17
- let videoSelectedModel = "Llama-3.2-3B-Instruct-q4f16_1-MLC"; // Default model
18
 
19
  function videoUpdateEngineInitProgressCallback(report) {
20
  console.log("Digital Human Video Initialize", report.progress);
@@ -609,4 +609,39 @@ document.addEventListener("DOMContentLoaded", () => {
609
  // Ensure Stop button is disabled after speech ends
610
  document.getElementById("video-stop_button").disabled = true;
611
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  });
 
14
  const videoAvailableModels = webllm.prebuiltAppConfig.model_list.map(
15
  (m) => m.model_id
16
  );
17
+ let videoSelectedModel = "Phi-3.5-vision-instruct-q4f16_1-MLC"; // Default model
18
 
19
  function videoUpdateEngineInitProgressCallback(report) {
20
  console.log("Digital Human Video Initialize", report.progress);
 
609
  // Ensure Stop button is disabled after speech ends
610
  document.getElementById("video-stop_button").disabled = true;
611
  });
612
+
613
+
614
+ // Event Listener for Image Upload
615
+ document.getElementById("video-image-upload").addEventListener("change", function (e) {
616
+ const file = e.target.files[0];
617
+ if (!file) {
618
+ return;
619
+ }
620
+
621
+ const canvas = document.getElementById("video-image-canvas");
622
+ const ctx = canvas.getContext("2d");
623
+ const img = new Image();
624
+
625
+ img.onload = function () {
626
+ // Resize canvas to match image
627
+ canvas.width = img.width;
628
+ canvas.height = img.height;
629
+ // Draw image on canvas
630
+ ctx.drawImage(img, 0, 0);
631
+ logMessage("Image uploaded and displayed on canvas.", "system");
632
+ };
633
+
634
+ img.onerror = function () {
635
+ alert("Failed to load the image. Please try a different file.");
636
+ logMessage("Failed to load the uploaded image.", "error");
637
+ };
638
+
639
+ // Read the image file as a Data URL
640
+ const reader = new FileReader();
641
+ reader.onload = function (event) {
642
+ img.src = event.target.result;
643
+ };
644
+ reader.readAsDataURL(file);
645
+ });
646
+
647
  });
finalwork4.html CHANGED
@@ -127,7 +127,6 @@
127
 
128
 
129
 
130
-
131
  <!-- --------------------Digital Human Mentor Video Content Starts---------------- -->
132
  <div id="video" class="content-section hidden">
133
  <div class="card video-card">
@@ -208,6 +207,13 @@
208
  <p>Model Initialized: <span id="video-selected-model">N/A</span></p>
209
  </div>
210
  </div>
 
 
 
 
 
 
 
211
  </div>
212
  </div>
213
  <!-- --------------------Digital Human Mentor Video Content Ends----------------- -->
 
127
 
128
 
129
 
 
130
  <!-- --------------------Digital Human Mentor Video Content Starts---------------- -->
131
  <div id="video" class="content-section hidden">
132
  <div class="card video-card">
 
207
  <p>Model Initialized: <span id="video-selected-model">N/A</span></p>
208
  </div>
209
  </div>
210
+
211
+ <!-- New: Image Upload and Canvas Section -->
212
+ <div class="video-image-section">
213
+ <h3>Upload and Analyze Image</h3>
214
+ <input type="file" id="video-image-upload" accept="image/*" />
215
+ <canvas id="video-image-canvas"></canvas>
216
+ </div>
217
  </div>
218
  </div>
219
  <!-- --------------------Digital Human Mentor Video Content Ends----------------- -->
index.html CHANGED
@@ -127,7 +127,6 @@
127
 
128
 
129
 
130
-
131
  <!-- --------------------Digital Human Mentor Video Content Starts---------------- -->
132
  <div id="video" class="content-section hidden">
133
  <div class="card video-card">
@@ -208,6 +207,13 @@
208
  <p>Model Initialized: <span id="video-selected-model">N/A</span></p>
209
  </div>
210
  </div>
 
 
 
 
 
 
 
211
  </div>
212
  </div>
213
  <!-- --------------------Digital Human Mentor Video Content Ends----------------- -->
 
127
 
128
 
129
 
 
130
  <!-- --------------------Digital Human Mentor Video Content Starts---------------- -->
131
  <div id="video" class="content-section hidden">
132
  <div class="card video-card">
 
207
  <p>Model Initialized: <span id="video-selected-model">N/A</span></p>
208
  </div>
209
  </div>
210
+
211
+ <!-- New: Image Upload and Canvas Section -->
212
+ <div class="video-image-section">
213
+ <h3>Upload and Analyze Image</h3>
214
+ <input type="file" id="video-image-upload" accept="image/*" />
215
+ <canvas id="video-image-canvas"></canvas>
216
+ </div>
217
  </div>
218
  </div>
219
  <!-- --------------------Digital Human Mentor Video Content Ends----------------- -->