Skip to content

jahriko/scanseta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scanseta

Scanseta is a prescription scanning system with:

  • A React + TypeScript frontend for uploading prescription images and viewing extracted data.
  • A FastAPI backend for OCR extraction, medication parsing, FDA verification, and PNDF enrichment.

Monorepo Overview

  • frontend/: Vite + React + TypeScript application.
  • backend/: FastAPI API and ML/scraper pipeline.
  • setup.ps1: One-time setup script for backend + frontend.
  • dev.ps1: Starts backend and frontend in separate PowerShell windows.

Prerequisites

  • Python 3.8+
  • Node.js + npm
  • Windows PowerShell (recommended for provided scripts)

Quick Start (Windows)

From repo root:

.\setup.ps1
.\dev.ps1

What this does:

  • Creates backend/.venv (if missing)
  • Installs backend requirements from backend/requirements.txt
  • Installs Playwright Chromium for backend scrapers
  • Installs frontend npm dependencies
  • Creates frontend/.env.local with VITE_API_BASE_URL=http://localhost:8000 (if missing)
  • Launches backend on http://localhost:8000 and frontend on Vite dev server (usually http://localhost:5173)

Manual Setup

Backend

cd backend
python -m venv .venv
.\.venv\Scripts\pip.exe install -r requirements.txt
.\.venv\Scripts\python.exe -m playwright install chromium
.\.venv\Scripts\python.exe run_server.py

Frontend

cd frontend
npm install
Set-Content -Path .env.local -Value "VITE_API_BASE_URL=http://localhost:8000"
npm run dev

Optional config check:

cd frontend
npm run check-env

Configuration

Frontend Environment Variables

  • VITE_API_BASE_URL (required)
    • Must start with http:// or https://
    • Must not end with /
    • Local default: http://localhost:8000

Backend Environment Variables (optional)

  • HF_BASE_MODEL (default: Qwen/Qwen2.5-VL-7B-Instruct)
  • HF_ADAPTER_REPO (default: scanseta/qwen_prescription_model)
  • HF_HOME (default: ./hf_home)
  • TRANSFORMERS_CACHE (default: ./hf_cache)
  • HF_OFFLOAD_DIR (default: ./offload)
  • Post-processing tuning vars used in backend/main.py:
    • LEXICON_PATH
    • MAX_EDIT_DISTANCE
    • MIN_SIMILARITY
    • NGRAM_N
    • PLAUSIBILITY_THRESHOLD
    • MAX_CANDIDATES

API Endpoints

Base URL: http://localhost:8000

  • GET / - API status summary
  • GET /health - health status and model/device info
  • GET /model-status - detailed model status
  • GET /load-model - load/reload model
  • POST /scan - scan one prescription image
  • POST /scan-batch - scan multiple prescription images
  • POST /enrich-medications - enrich manually provided medication names

Examples:

curl http://localhost:8000/health
curl "http://localhost:8000/load-model"
curl -X POST "http://localhost:8000/enrich-medications" `
  -H "Content-Type: application/json" `
  -d "{\"drug_names\":[\"paracetamol\",\"ibuprofen\"]}"
curl -X POST "http://localhost:8000/scan" `
  -F "file=@C:\path\to\prescription.jpg"

Project Structure

scanseta/
|- setup.ps1
|- dev.ps1
|- frontend/
|  |- package.json
|  |- .env.local (local)
|  |- src/lib/config.ts
|  `- src/lib/prescription-api.ts
`- backend/
   |- main.py
   |- run_server.py
   |- requirements.txt
   |- data/
   `- src/
      |- scrapers/
      `- post_processing/

Troubleshooting

  • 503 Model not loaded on /scan:
    • Call GET /load-model first, then retry.
  • Frontend cannot call backend:
    • Check frontend/.env.local and ensure VITE_API_BASE_URL is set correctly.
    • Restart frontend dev server after changing env files.
  • Playwright errors during enrichment:
    • Reinstall browser: .\.venv\Scripts\python.exe -m playwright install chromium
  • Windows async/subprocess errors with Playwright:
    • Use python run_server.py (it sets the Windows event loop policy correctly).

Notes

  • This project is for prescription text extraction and medication data enrichment workflows.
  • Output should be reviewed by qualified professionals before clinical use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •