Skip to content

Naresh-x86/PreciseDose

Repository files navigation

PreciseDose

A multi-threaded desktop application utilizing customtkinter for its graphical interface and integrating advanced machine learning components for predictive modeling and natural language processing. The application is designed to ingest continuous audio streams, parse medical context, and evaluate dosage protocols using pre-trained neural networks.


Machine Learning Integration

The software stack integrates two distinct machine learning paradigms operating in parallel:

graph TD
    A[Main UI Thread: customtkinter] -->|Spawn Thread| B(AudioToTextRecorder: RealtimeSTT)
    B -->|Transcribed Text| C{ollama.ChatResponse}
    C -->|llama3.2 Local LLM| D[Extract Medical Variables]
    D -->|Input Tensors| E(precisedose_nn_model.onnx)
    E -->|Forward Pass via weights.h5| F[Predict Dosage Floats]
Loading
  1. Audio-to-Text Pipeline (RealtimeSTT)
    The application instantiates an AudioToTextRecorder instance. This class establishes a continuous listening thread on the default system microphone, utilizing Voice Activity Detection (VAD) to segment audio streams. Once a voice segment is recorded, it transcribes the waveform into text strings utilizing embedded acoustic models (e.g., Whisper), bypassing the need for cloud API reliance and ensuring zero-latency offline transcription.

  2. Large Language Model Execution (ollama)
    The transcribed string is pushed to an event loop where the ollama.ChatResponse module interfaces with a localized LLM daemon. By specifying the llama3.2 model architecture in the chat function parameters, the system prompts the LLM to structure the arbitrary text input into actionable medical variables or conversational feedback.

  3. Predictive Neural Network (precise_nn_model)
    Located in the precise_nn_model directory, the system loads a pre-compiled ONNX format graph (precisedose_nn_model.onnx). Patient physiological variables parsed by the LLM are transformed into normalized input tensors. The ONNX runtime executes a forward pass through the dense layers of the model, utilizing specific weight matrices (weights.h5) to generate float output arrays representing targeted medication dosages.

UI Engine and Concurrency

  • The graphical frontend runs on the main Tkinter thread. It utilizes a layered Canvas structure where background static images are algorithmically tinted using Pillow's RGBTransform().mix_with() function, effectively multiplying the source pixels with a primary_color hex value defined in the settings.json.
  • A tkVideoPlayer instance is bound to the canvas for rendering animated states. A recursive after() method loop handles seeking and playback.

Tip

To prevent the computationally expensive STT and LLM inferences from blocking the UI thread's event loop, these operations are strictly encapsulated in asyncio coroutines.


Setup & Run Instructions

  1. Clone & Install Dependencies Initialize your environment and install the required packages:

    pip install customtkinter tkvideoplayer Pillow ollama RealtimeSTT colorama termcolor
  2. LLM Initialization Ensure the Ollama daemon is running locally with the required model pulled:

    ollama pull llama3.2
  3. Launch the Application Run the launcher to initiate the splash screen sequence, or directly execute main.py:

    python launcher.py

Note

No Artificial Intelligence or automated code generation tools were utilized in the programming of this project. The entire codebase, including logic, UI design, and model integration workflows, was written manually by hand.

About

A multi-threaded desktop application utilizing customtkinter for its graphical interface and integrating machine learning components for predictive modeling and NLP. Designed to ingest continuous audio streams, parse medical context, and evaluate dosage protocols using pre-trained NNs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages