From ebac0989176c45e9540617e8735a3044672a01f4 Mon Sep 17 00:00:00 2001 From: nisalrenuja Date: Mon, 4 Nov 2024 16:36:26 +0530 Subject: [PATCH] ui changes --- src/app/coco-ssd/page.js | 105 ++++++----- src/app/mobilenet/page.js | 178 +++++++++--------- src/components/pages/home/TensorFlowModels.js | 42 +++-- 3 files changed, 168 insertions(+), 157 deletions(-) diff --git a/src/app/coco-ssd/page.js b/src/app/coco-ssd/page.js index 3044d0f..62dc1bb 100644 --- a/src/app/coco-ssd/page.js +++ b/src/app/coco-ssd/page.js @@ -11,7 +11,6 @@ import ImageUploader from "@/components/pages/coco-ssd/ImageUploader"; import DetectedObjectsList from "@/components/pages/coco-ssd/DetectedObjectsList"; import Header from "@/components/common/Header"; import Footer from "@/components/common/Footer"; -import { Github } from "lucide-react"; export default function ObjectDetection() { const canvasRef = useRef(null); @@ -97,61 +96,65 @@ export default function ObjectDetection() { return (
- - - - COCO-SSD Model - - - - {loadingState.loading && loadingState.progress < 100 && ( -
-

Loading model...

- -
- )} +
+ + + + COCO-SSD Model + + + + {loadingState.loading && loadingState.progress < 100 && ( +
+

+ Loading model... +

+ +
+ )} - {error && ( - - Error - {error} - - )} + {error && ( + + Error + {error} + + )} -
- +
+ -
- {uploadedImage && ( - <> - Uploaded - - - )} +
+ {uploadedImage && ( + <> + Uploaded + + + )} +
-
- {detectedObjects.length > 0 && ( - - )} - - + {detectedObjects.length > 0 && ( + + )} + + +
); diff --git a/src/app/mobilenet/page.js b/src/app/mobilenet/page.js index 26b573b..0c5f579 100644 --- a/src/app/mobilenet/page.js +++ b/src/app/mobilenet/page.js @@ -4,6 +4,8 @@ import { useState, useEffect, useMemo } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import ImageUploader from "@/components/pages/coco-ssd/ImageUploader"; import { Progress } from "@/components/ui/progress"; import { Upload, Github } from "lucide-react"; import { loadModel, loadImage } from "@/utils/imageProcessing"; @@ -18,15 +20,22 @@ export default function MobileNet() { const [selectedFile, setSelectedFile] = useState(null); const [imagePreview, setImagePreview] = useState(null); const [error, setError] = useState(null); + const [loadingState, setLoadingState] = useState({ + loading: true, + progress: 0, + }); useEffect(() => { const loadTensorFlowModel = async () => { try { + setLoadingState({ loading: true, progress: 10 }); const loadedModel = await loadModel(); setModel(loadedModel); + setLoadingState({ loading: false, progress: 100 }); } catch (error) { console.error("Error loading the model:", error); setError("Failed to load the model. Please try again later."); + setLoadingState({ loading: false, progress: 100 }); } }; loadTensorFlowModel(); @@ -98,96 +107,93 @@ export default function MobileNet() {
- + - MobileNet Model + + MobileNet Model + - -
-
- - + + {loadingState.loading && loadingState.progress < 100 && ( +
+

+ Loading model... +

+ +
+ )} + + {error && ( + + Error + {error} + + )} + +
+ + +
+ {imagePreview && ( + <> + Preview + + )}
- - {imagePreview && ( -
-

Image Preview:

- Preview -
- )} - - {isAnalyzing && } - - {error &&

{error}

} - - {predictions.length > 0 && ( -
-

Results:

-
    - {predictions.map((pred, index) => ( -
  • -
    - {pred.className} - - (Learn More) - -
    - -
    - -
    - -
    - {(pred.probability * 100).toFixed(2)}% -
    -
  • - ))} -
- - -
- )}
+ + {isAnalyzing && } + + {predictions.length > 0 && ( +
+

Results:

+
    + {predictions.map((pred, index) => ( +
  • +
    + {pred.className} + + (Learn More) + +
    + +
    + +
    + +
    + {(pred.probability * 100).toFixed(2)}% +
    +
  • + ))} +
+ + +
+ )}
diff --git a/src/components/pages/home/TensorFlowModels.js b/src/components/pages/home/TensorFlowModels.js index c0861b7..4de8e27 100644 --- a/src/components/pages/home/TensorFlowModels.js +++ b/src/components/pages/home/TensorFlowModels.js @@ -12,28 +12,30 @@ import { ArrowRight, Brain, Camera, Mic, FileText } from "lucide-react"; const models = [ { title: "MobileNet", - description: "Classify images into predefined categories", - icon: Camera, + description: + "A lightweight, efficient deep learning model designed for mobile and embedded devices, optimized for tasks like image classification and object detection.", + // icon: Camera, link: "/mobilenet", }, { - title: "Natural Language Processing", - description: "Process and analyze human language", - icon: FileText, - link: "/models/nlp", - }, - { - title: "Speech Recognition", - description: "Convert spoken language into text", - icon: Mic, - link: "/models/speech-recognition", - }, - { - title: "Neural Network", - description: "Build and train custom neural networks", - icon: Brain, - link: "/models/neural-network", + title: "COCO-SSD", + description: + "An object detection model trained on the COCO dataset, capable of identifying and localizing multiple objects in images in real-time.", + // icon: FileText, + link: "/coco-ssd", }, + // { + // title: "Speech Recognition", + // description: "Convert spoken language into text", + // icon: Mic, + // link: "/models/speech-recognition", + // }, + // { + // title: "Neural Network", + // description: "Build and train custom neural networks", + // icon: Brain, + // link: "/models/neural-network", + // }, ]; export default function TensorFlowModels() { @@ -43,9 +45,9 @@ export default function TensorFlowModels() { {models.map((model, index) => ( -
+ {/*
-
+
*/} {model.title} {model.description}