🔧 HTML
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
I Have made a project using HTML and teachable machine in which I Had trained the AI Model to understand few book names by showing book's cover to it and the html will give the summary of the corresponding Book. The code is :
<!DOCTYPE html>
Teachable Machine Book Summary
<br> body { font-family: Arial, sans-serif; }<br> #summary-container { margin-top: 20px; }<br>
Teachable Machine Image Model
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@teachablemachine/image@latest/dist/teachablemachine-image.min.js"></script>
<script type="text/javascript">
const URL = "./my_model/"; // Ensure model files are correctly placed here
let model, webcam;
// Start as soon as the page loads
window.onload = async function() {
try {
console.log("Attempting to load model...");
const modelURL = URL + "model.json";
const metadataURL = URL + "metadata.json";
// Load the model
model = await tmImage.load(modelURL, metadataURL);
console.log("Model loaded!");
// Set up the webcam
const flip = true; // Flip the webcam
webcam = new tmImage.Webcam(200, 200, flip); // Create the webcam instance
await webcam.setup(); // Request permission to access the webcam
console.log("Webcam setup complete!");
await webcam.play(); // Start the webcam stream
document.getElementById("webcam-container").appendChild(webcam.canvas); // Add webcam to page
// Begin the loop to run predictions
window.requestAnimationFrame(loop);
} catch (error) {
console.error("Error during initialization:", error);
}
};
// Loop to continuously predict
async function loop() {
try {
webcam.update(); // Update the webcam frame
await predict(); // Make predictions
window.requestAnimationFrame(loop); // Keep the loop going
} catch (error) {
console.error("Error during loop:", error);
}
}
// Simple prediction function to check if the model works
async function predict() {
try {
const prediction = await model.predict(webcam.canvas);
console.log(prediction); // Log the predictions for debugging
} catch (error) {
console.error("Error during prediction:", error);
}
}
</script>
When I run this i am only getting "Teachable Machine Image Model" in the body.
I am a beginner and What should I do?
🔧 2/10 HTML | 30 Days of HTML CSS JS
📈 8.37 Punkte
🔧 Programmierung
🕵️ http://natco.gov.pk/emails/html.html
📈 8.37 Punkte
🕵️ Hacking
🕵️ WP HTML Mail < 2.9.1 - HTML Injection
📈 8.37 Punkte
🕵️ Sicherheitslücken