sci-image / AEGIS_BIO_DIGITAL_LAB10_INTEGRATION.md
Gaston895's picture
Add Gradio API ping endpoint
e6453d3
|
Raw History Blame Contribute Delete
13.2 kB

AEGIS Bio-Digital Lab 10 - Visual System Integration

Overview

The sci-image system serves as the Visual Generation Engine for AEGIS Bio-Digital Lab 10, providing AI-powered image generation capabilities for scientific visualization across all windows, with primary focus on:

  • Window 7: Disease Analysis (viruses, bacteria, pathogens)
  • Window 9: Drug Development (molecular structures, drug compounds)

System Information

  • Service Name: AEGIS Bio-Digital Lab 10 - Visual System
  • Base Technology: FastSD CPU (Fast Stable Diffusion on CPU)
  • Primary Use Cases:
    • Pathogen visualization (viruses, bacteria)
    • Molecular structure generation
    • Scientific illustration
  • Integration Points: Window 7 disease discovery, Window 9 drug development completion

API Endpoints

Health & Monitoring

1. Ping Endpoint (UptimeRobot)

GET /api/ping

Purpose: Health check for UptimeRobot monitoring
Response:

{
  "status": "ok",
  "service": "AEGIS Bio-Digital Lab 10 - Visual System",
  "version": "1.0.0",
  "device": "cpu"
}

2. Detailed Health Check

GET /api/health

Purpose: Comprehensive system health status
Response:

{
  "status": "healthy",
  "service": "AEGIS Bio-Digital Lab 10 - Visual System",
  "version": "1.0.0",
  "device": "cpu",
  "device_name": "Intel Core i7",
  "platform": "Linux"
}

3. System Information

GET /api/info

Purpose: Get detailed system information

Window 7: Disease Analysis Endpoints

4. Generate Pathogen Visualization

POST /api/window7/generate-pathogen

Purpose: Generate virus and bacteria visualizations for disease discovery
Use Case: When a disease is discovered in Window 7, generate visual representation of the pathogen

Example Prompts:

  • "Microscopic view of [virus name] virus, scientific illustration, high detail"
  • "3D structure of [bacteria name] bacteria, medical visualization"
  • "Electron microscope image of [pathogen], scientific accuracy"
  • "Viral structure of COVID-19, detailed scientific diagram"
  • "Bacterial cell structure of E. coli, cross-section view"

Request Body:

{
  "prompt": "Microscopic view of Ebola virus, scientific illustration, high detail, medical accuracy",
  "negative_prompt": "blurry, low quality, artistic, cartoon",
  "num_inference_steps": 12,
  "guidance_scale": 2.0,
  "width": 512,
  "height": 512,
  "seed": -1,
  "diffusion_task": "text_to_image"
}

5. Generate Disease Visualization

POST /api/window7/generate-disease-visualization

Purpose: Generate disease progression and infection visualizations
Use Case: Visualize disease symptoms, affected areas, and progression

Example Prompts:

  • "Medical illustration of [disease] infection in human body"
  • "Disease progression diagram of [condition], scientific style"
  • "Affected organs in [disease], medical visualization"
  • "Cellular damage from [pathogen] infection, microscopic view"

Window 9: Drug Development Endpoints

6. Generate Molecule Visualization

POST /api/window9/generate-molecule

Purpose: Generate molecular structure visualizations
Use Case: After SMILES processing, generate visual representations of molecular structures

Example Prompts:

  • "3D molecular structure of aspirin, scientific visualization"
  • "Chemical structure diagram of [SMILES notation], high detail"
  • "Molecular bonds and atoms of [drug name], scientific illustration"
  • "Protein-ligand complex, molecular docking visualization"

7. Generate Drug Visualization

POST /api/window9/generate-drug-visualization

Purpose: Generate drug compound visualizations
Use Case: Visualize drug candidates and their properties

Example Prompts:

  • "Drug compound [name] in 3D, pharmaceutical visualization"
  • "Protein-ligand binding visualization for [drug name]"
  • "Drug molecule interaction diagram, scientific style"

General Scientific Visualization

8. Generate Scientific Visualization

POST /api/aegis/generate-scientific

Purpose: General scientific visualization for all AEGIS windows
Use Case: Cross-window scientific imagery generation

9. General Image Generation

POST /api/generate

Purpose: Standard image generation endpoint

Configuration Endpoints

10. Get Configuration

GET /api/config

11. Get Available Models

GET /api/models

Integration Workflows

Window 7: Disease Discovery Flow

1. Window 7 discovers new disease/pathogen
   ↓
2. Extract pathogen name and characteristics
   ↓
3. Call /api/window7/generate-pathogen with descriptive prompt
   ↓
4. Receive base64-encoded pathogen visualization
   ↓
5. Display in Window 7 UI alongside disease data
   ↓
6. Store in disease_analysis_v2 table

Window 9: Drug Development Flow

1. Window 9 completes drug development analysis
   ↓
2. SMILES notation generated for drug compound
   ↓
3. Call /api/window9/generate-molecule with molecular prompt
   ↓
4. Receive base64-encoded molecular structure
   ↓
5. Display in Window 9 UI
   ↓
6. Store in drug_development table

Example Integration Code

Window 7: Pathogen Visualization

// After disease discovery in Window 7
async function generatePathogenVisualization(diseaseData) {
  const response = await fetch('https://sci-image-api.com/api/window7/generate-pathogen', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      prompt: `Microscopic view of ${diseaseData.pathogen_name} ${diseaseData.pathogen_type}, scientific illustration, high detail, medical accuracy`,
      negative_prompt: 'blurry, low quality, artistic, cartoon, unrealistic',
      num_inference_steps: 12,
      guidance_scale: 2.0,
      width: 512,
      height: 512,
      seed: -1,
      diffusion_task: 'text_to_image'
    })
  });
  
  const result = await response.json();
  
  // Store in database
  await fetch('/api/window7/disease-analysis', {
    method: 'PATCH',
    body: JSON.stringify({
      id: diseaseData.id,
      pathogen_image: result.images[0],
      image_generation_latency: result.latency
    })
  });
  
  return result.images[0]; // Base64 image
}

Window 9: Molecular Visualization

// After drug development completion in Window 9
async function generateMolecularVisualization(drugData) {
  const response = await fetch('https://sci-image-api.com/api/window9/generate-molecule', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      prompt: `3D molecular structure of ${drugData.compound_name}, SMILES: ${drugData.smiles}, scientific visualization, high detail`,
      negative_prompt: 'blurry, low quality, distorted, artistic',
      num_inference_steps: 10,
      guidance_scale: 1.8,
      width: 512,
      height: 512,
      seed: -1,
      diffusion_task: 'text_to_image'
    })
  });
  
  const result = await response.json();
  return result.images[0]; // Base64 image
}

Response Format

All generation endpoints return:

{
  "latency": 2.5,
  "images": ["base64_encoded_image_1", "base64_encoded_image_2"],
  "error": null
}

Configuration Parameters

LCMDiffusionSetting Parameters

Parameter Type Default Description
prompt string required Text description of desired image
negative_prompt string "" What to avoid in generation
num_inference_steps int 4 Number of denoising steps (4-50)
guidance_scale float 1.0 How closely to follow prompt (1.0-2.0)
width int 512 Image width in pixels
height int 512 Image height in pixels
seed int -1 Random seed (-1 for random)
diffusion_task string "text_to_image" "text_to_image" or "image_to_image"
init_image string null Base64 image for img2img
strength float 0.8 Img2img transformation strength

Best Practices

For Pathogen Visualizations (Window 7)

  1. Prompt Structure: "[Pathogen type] view of [pathogen name], scientific illustration, high detail, medical accuracy"
  2. Negative Prompts: Always include "blurry, low quality, artistic, cartoon, unrealistic"
  3. Steps: Use 10-15 steps for medical accuracy
  4. Guidance: Set to 1.8-2.0 for scientific precision
  5. Keywords: Include "microscopic", "electron microscope", "scientific", "medical"

Example Prompts for Common Pathogens:

  • Viruses: "Electron microscope view of [virus name] virion, detailed capsid structure, scientific accuracy"
  • Bacteria: "Microscopic view of [bacteria name] bacterial cell, flagella visible, scientific illustration"
  • Fungi: "Microscopic structure of [fungus name], spores and hyphae, medical visualization"
  • Parasites: "Detailed view of [parasite name], life cycle stage, scientific diagram"

For Molecular Visualizations (Window 9)

  1. Include SMILES: Reference SMILES notation in prompt when available
  2. Specify Style: "3D molecular structure", "ball-and-stick model", "space-filling model"
  3. Scientific Terms: Use "bonds", "atoms", "molecular geometry"
  4. Steps: 8-12 for molecular accuracy
  5. Guidance: 1.5-2.0 for precise structures

Performance Optimization

  1. Use lower num_inference_steps (4-6) for faster generation during development
  2. Increase steps (10-15) for production/final visualizations
  3. Cache frequently generated pathogen/molecule images
  4. Batch multiple requests when generating variations

Prompt Templates

Window 7 Templates

Virus Visualization

"Electron microscope view of {virus_name} virus, detailed viral structure, capsid proteins visible, scientific illustration, high detail, medical accuracy"

Bacteria Visualization

"Microscopic view of {bacteria_name} bacteria, cell wall structure, flagella, scientific illustration, gram stain appearance, medical accuracy"

Disease Progression

"Medical illustration of {disease_name} infection progression in human {organ/tissue}, cellular level, scientific diagram, pathological changes"

Window 9 Templates

Molecular Structure

"3D molecular structure of {compound_name}, SMILES: {smiles_notation}, ball-and-stick model, chemical bonds visible, scientific visualization, high detail"

Drug-Protein Interaction

"Protein-ligand binding visualization, {drug_name} docking with {protein_name}, molecular interaction diagram, scientific style, binding site highlighted"

Monitoring

UptimeRobot Configuration

  • Monitor Type: HTTP(s)
  • URL: https://your-sci-image-api.com/api/ping
  • Interval: 5 minutes
  • Expected Response: 200 OK with "status": "ok"

Health Check Schedule

  • Ping endpoint: Every 5 minutes
  • Health endpoint: Every 15 minutes
  • Full system check: Every hour

Error Handling

Common Errors

Error Cause Solution
latency > 30s Complex prompt or high steps Reduce steps or simplify prompt
images: [] Generation failed Check prompt validity
error: "Out of memory" Image too large Reduce dimensions
error: "Model not loaded" Model initialization failed Restart service

Database Integration

Window 7: Storing Pathogen Images

-- Add pathogen_image column to disease_analysis_v2
ALTER TABLE disease_analysis_v2 
ADD COLUMN pathogen_image TEXT,
ADD COLUMN pathogen_image_prompt TEXT,
ADD COLUMN image_generation_latency REAL;

Window 9: Storing Molecular Images

-- Add molecular_image column to drug_development
ALTER TABLE drug_development
ADD COLUMN molecular_structure_image TEXT,
ADD COLUMN molecular_image_prompt TEXT,
ADD COLUMN image_generation_latency REAL;

Deployment

Environment Variables

DEVICE=cpu
APP_VERSION=1.0.0
PORT=8000

Docker Deployment

docker build -t aegis-visual-system .
docker run -p 8000:8000 aegis-visual-system

Hugging Face Space

  • SDK: Docker
  • App Port: 7860
  • Python Version: 3.12 (see .python-version)

Future Enhancements

  1. GPU Acceleration: Add CUDA support for faster generation
  2. Model Fine-tuning: Train on medical/scientific imagery datasets
  3. 3D Rendering: Generate rotatable 3D pathogen/molecule models
  4. Animation: Create pathogen lifecycle and molecular interaction animations
  5. Style Transfer: Apply scientific paper/textbook style
  6. Batch Processing: Generate multiple variations simultaneously
  7. Real-time Generation: WebSocket support for live visualization

Version History

  • v1.0.0 (2026-05-31): Initial AEGIS Bio-Digital Lab 10 integration
    • Added ping endpoint for UptimeRobot
    • Added Window 7 pathogen visualization endpoints
    • Added Window 9 molecular visualization endpoints
    • Added AEGIS scientific visualization endpoint
    • Added comprehensive health checks
    • Integrated with disease discovery and drug development workflows