Files
Asep Haryana Saputra 15c6be9e84 feat: implement backend image classification with TensorFlow.js model
- Extend shared types for image classification, including PredictionProbability, UploaderMetadata, and ImageClassificationRecord.
- Create image_classifications table in the database with necessary fields and foreign key constraints.
- Implement disease mappers to convert database rows to shared disease records.
- Develop uploader client to handle image uploads to external service.
- Create image model service to load and classify images using TensorFlow.js.
- Add API routes for image classification, including GET for history and POST for new classifications.
- Implement frontend components for image classification form and display results.
- Update dashboard to integrate image classification functionality and display results.
- Document implementation plan for backend image classification.
2026-05-22 15:13:22 +00:00

18 lines
779 B
SQL

CREATE TABLE IF NOT EXISTS "image_classifications" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"predicted_disease_slug" varchar(80) NOT NULL,
"confidence" real NOT NULL,
"probabilities" jsonb NOT NULL,
"image_url" text NOT NULL,
"original_file_name" varchar(240) NOT NULL,
"uploader_public_id" varchar(160) NOT NULL,
"uploader_payload" jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "image_classifications" ADD CONSTRAINT "image_classifications_predicted_disease_slug_disease_catalog_slug_fk" FOREIGN KEY ("predicted_disease_slug") REFERENCES "public"."disease_catalog"("slug") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;