How siddarammanur656/dermascan-ai- works
Purpose and Entry Point
DermaScan AI is a single-process Python/Streamlit dermatology-assistance application. It accepts lesion images for local dual-model classification and provides a multilingual skin-care chat assistant backed by Google Gemini, with optional speech input/output. The runtime entry point is app.py; launch through streamlit run app.py.
Paths: app.py, requirements.txt, README.md
Streamlit UI and Session Boundary
app.py owns the interactive UI: image upload, side-by-side model results, chat panel, language selection, and voice controls. Streamlit session state preserves chat context only for the active browser session; image handling is in-memory. Styling is loaded from the static CSS asset.
Paths: app.py, assets/style.css
Model Asset Loading and Caching
Two TensorFlow/Keras .h5 artifacts are application-local inference dependencies. The app loads them with inference-oriented settings and Streamlit resource caching, so model instances are reused rather than reloaded on each interaction. Missing or incompatible assets are a startup/runtime availability boundary.
Paths: app.py, custom_cnn_model.h5, vgg16_skin_cancer.h5
Image Inference Pipeline
Uploaded JPEG/PNG input crosses a validation boundary, then is converted to RGB, resized to each model’s configured input size, normalized, and expanded into a batch. The same image is independently evaluated by the custom CNN and VGG16 model. Output handling supports sigmoid-style binary results and multiclass probability vectors, mapping top scores to configured labels and displaying confidence/raw outputs.
Paths: app.py, custom_cnn_model.h5, vgg16_skin_cancer.h5
Conversational AI Integration
Skin-care questions and prior session messages are sent to Google Generative AI (Gemini) under a domain-specific prompt. API credentials come from environment configuration, with a UI fallback described for user-provided keys. Gemini model selection includes fallback behavior for quota/API failures; this is the primary external network dependency and the main nondeterministic service boundary.
Paths: app.py, .env
Voice and Multilingual Flow
The UI accepts English, Hindi, and Kannada interaction. Voice capture is transcribed to chat text via speech-recognition dependencies; generated assistant text can be synthesized into audio through gTTS. These capabilities depend on browser microphone permissions and online speech/TTS services, while text chat remains the fallback path.
Paths: app.py, requirements.txt
Runtime and Operational Shape
The system is a Streamlit-hosted Python application using TensorFlow/Keras, NumPy, Pillow, dotenv, Gemini SDK, speech recognition, and gTTS. There is no separate backend, database, queue, or persistent user-data store in the repository. Lightweight operational checks verify dependencies and model file availability.
Paths: requirements.txt, check_models.py, test_imports.py
Main entry points: app.py Image, chat and voice UI · custom_cnn_model.h5 Custom CNN model · vgg16_skin_cancer.h5 VGG16 skin cancer model · .env API credentials
Components 14
Streamlit interface
- Streamlit application · Single-process runtime and integration boundary.
app.py - Image, chat and voice UI
app.py - Browser session state · Retains chat context only for the active session.
app.py - Application styling
assets/style.css
Local image inference
- Uploaded lesion image · JPEG/PNG image supplied through the UI.
app.py - Validation and preprocessing · Converts RGB, resizes, normalizes, and batches per model.
app.py - Custom CNN model · Cached local inference model.
custom_cnn_model.h5 - VGG16 skin cancer model · Cached local inference model.
vgg16_skin_cancer.h5 - Classification results · Maps binary or multiclass scores to labels and confidence.
app.py
Conversational assistant
- Domain chat prompt · Combines question, prior messages, language, and skin-care guidance.
app.py - Google Gemini · Network service with model and quota fallback behavior.
- API credentials · Loads API key from environment with UI key fallback.
.env - Speech transcription · Requires microphone permission and online speech recognition.
app.py - Text-to-speech audio · Synthesizes assistant responses through gTTS.
app.py
Connections 19
- Streamlit application → Image, chat and voice UI: renders
- Streamlit application → Application styling: loads
- Image, chat and voice UI → Browser session state: reads and updates
- Image, chat and voice UI → Uploaded lesion image: accepts
- Uploaded lesion image → Validation and preprocessing: validates and transforms
- Validation and preprocessing → Custom CNN model: prepared batch
- Validation and preprocessing → VGG16 skin cancer model: prepared batch
- Custom CNN model → Classification results: scores
- VGG16 skin cancer model → Classification results: scores
- Classification results → Image, chat and voice UI: displays
- Image, chat and voice UI → Speech transcription: voice capture
- Speech transcription → Domain chat prompt: transcribed text
- Image, chat and voice UI → Domain chat prompt: typed question
- Browser session state → Domain chat prompt: prior messages
- API credentials → Google Gemini: authorizes
- Domain chat prompt → Google Gemini: prompt request
- Google Gemini → Browser session state: assistant response
- Google Gemini → Text-to-speech audio: response text
- Text-to-speech audio → Image, chat and voice UI: audio playback