Commit ·
e6453d3
0
Parent(s):
Add Gradio API ping endpoint
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .env.example +5 -0
- .gitignore +11 -0
- .hfignore +9 -0
- AEGIS_BIO_DIGITAL_LAB10_INTEGRATION.md +428 -0
- DEPLOY_API_FIX.md +128 -0
- DEPLOY_API_SERVER.md +117 -0
- DEPLOY_SECURE.md +124 -0
- Dockerfile +22 -0
- FINAL_SOLUTION.md +87 -0
- HUGGINGFACE_DEPLOYMENT_FIX.md +117 -0
- HYBRID_DEPLOYMENT_GUIDE.md +159 -0
- LICENSE +21 -0
- README.md +11 -0
- THIRD-PARTY-LICENSES +143 -0
- benchmark-openvino.bat +23 -0
- benchmark.bat +23 -0
- configs/lcm-lora-models.txt +4 -0
- configs/lcm-models.txt +6 -0
- configs/openvino-lcm-models.txt +10 -0
- configs/stable-diffusion-models.txt +7 -0
- controlnet_models/Readme.txt +3 -0
- deploy-to-huggingface.bat +61 -0
- deploy-to-huggingface.ps1 +106 -0
- install-mac.sh +36 -0
- install.bat +38 -0
- install.sh +44 -0
- lora_models/Readme.txt +3 -0
- models/gguf/clip/readme.txt +1 -0
- models/gguf/diffusion/readme.txt +1 -0
- models/gguf/t5xxl/readme.txt +1 -0
- models/gguf/vae/readme.txt +1 -0
- requirements.txt +23 -0
- sci-image/.gitignore +8 -0
- sci-image/AEGIS_BIO_DIGITAL_LAB10_INTEGRATION.md +428 -0
- sci-image/DEPLOY_API_FIX.md +128 -0
- sci-image/DEPLOY_API_SERVER.md +117 -0
- sci-image/Dockerfile +22 -0
- sci-image/ENDPOINT_SUMMARY.md +0 -0
- sci-image/HYBRID_DEPLOYMENT_GUIDE.md +159 -0
- sci-image/LICENSE +21 -0
- sci-image/README.md +11 -0
- sci-image/THIRD-PARTY-LICENSES +143 -0
- sci-image/benchmark-openvino.bat +23 -0
- sci-image/benchmark.bat +23 -0
- sci-image/configs/lcm-lora-models.txt +4 -0
- sci-image/configs/lcm-models.txt +6 -0
- sci-image/configs/openvino-lcm-models.txt +10 -0
- sci-image/configs/stable-diffusion-models.txt +7 -0
- sci-image/controlnet_models/Readme.txt +3 -0
- sci-image/install-mac.sh +36 -0
.env.example
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Token Configuration
|
| 2 |
+
# Copy this file to .env and add your actual token
|
| 3 |
+
# NEVER commit .env to git!
|
| 4 |
+
|
| 5 |
+
HF_TOKEN=hf_YOUR_TOKEN_HERE
|
.gitignore
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env
|
| 2 |
+
env_old
|
| 3 |
+
*.bak
|
| 4 |
+
*.pyc
|
| 5 |
+
__pycache__
|
| 6 |
+
results
|
| 7 |
+
# excluding user settings for the GUI frontend
|
| 8 |
+
configs/settings.yaml
|
| 9 |
+
# Environment variables with secrets
|
| 10 |
+
.env
|
| 11 |
+
.env.local
|
.hfignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Files to exclude from Hugging Face Space
|
| 2 |
+
# These files are for local deployment only
|
| 3 |
+
.env.example
|
| 4 |
+
DEPLOY_SECURE.md
|
| 5 |
+
HUGGINGFACE_DEPLOYMENT_FIX.md
|
| 6 |
+
deploy-to-huggingface.bat
|
| 7 |
+
deploy-to-huggingface.ps1
|
| 8 |
+
.env
|
| 9 |
+
.env.local
|
AEGIS_BIO_DIGITAL_LAB10_INTEGRATION.md
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AEGIS Bio-Digital Lab 10 - Visual System Integration
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
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:
|
| 5 |
+
- **Window 7**: Disease Analysis (viruses, bacteria, pathogens)
|
| 6 |
+
- **Window 9**: Drug Development (molecular structures, drug compounds)
|
| 7 |
+
|
| 8 |
+
## System Information
|
| 9 |
+
- **Service Name**: AEGIS Bio-Digital Lab 10 - Visual System
|
| 10 |
+
- **Base Technology**: FastSD CPU (Fast Stable Diffusion on CPU)
|
| 11 |
+
- **Primary Use Cases**:
|
| 12 |
+
- Pathogen visualization (viruses, bacteria)
|
| 13 |
+
- Molecular structure generation
|
| 14 |
+
- Scientific illustration
|
| 15 |
+
- **Integration Points**: Window 7 disease discovery, Window 9 drug development completion
|
| 16 |
+
|
| 17 |
+
## API Endpoints
|
| 18 |
+
|
| 19 |
+
### Health & Monitoring
|
| 20 |
+
|
| 21 |
+
#### 1. Ping Endpoint (UptimeRobot)
|
| 22 |
+
```
|
| 23 |
+
GET /api/ping
|
| 24 |
+
```
|
| 25 |
+
**Purpose**: Health check for UptimeRobot monitoring
|
| 26 |
+
**Response**:
|
| 27 |
+
```json
|
| 28 |
+
{
|
| 29 |
+
"status": "ok",
|
| 30 |
+
"service": "AEGIS Bio-Digital Lab 10 - Visual System",
|
| 31 |
+
"version": "1.0.0",
|
| 32 |
+
"device": "cpu"
|
| 33 |
+
}
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
#### 2. Detailed Health Check
|
| 37 |
+
```
|
| 38 |
+
GET /api/health
|
| 39 |
+
```
|
| 40 |
+
**Purpose**: Comprehensive system health status
|
| 41 |
+
**Response**:
|
| 42 |
+
```json
|
| 43 |
+
{
|
| 44 |
+
"status": "healthy",
|
| 45 |
+
"service": "AEGIS Bio-Digital Lab 10 - Visual System",
|
| 46 |
+
"version": "1.0.0",
|
| 47 |
+
"device": "cpu",
|
| 48 |
+
"device_name": "Intel Core i7",
|
| 49 |
+
"platform": "Linux"
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
#### 3. System Information
|
| 54 |
+
```
|
| 55 |
+
GET /api/info
|
| 56 |
+
```
|
| 57 |
+
**Purpose**: Get detailed system information
|
| 58 |
+
|
| 59 |
+
### Window 7: Disease Analysis Endpoints
|
| 60 |
+
|
| 61 |
+
#### 4. Generate Pathogen Visualization
|
| 62 |
+
```
|
| 63 |
+
POST /api/window7/generate-pathogen
|
| 64 |
+
```
|
| 65 |
+
**Purpose**: Generate virus and bacteria visualizations for disease discovery
|
| 66 |
+
**Use Case**: When a disease is discovered in Window 7, generate visual representation of the pathogen
|
| 67 |
+
|
| 68 |
+
**Example Prompts**:
|
| 69 |
+
- "Microscopic view of [virus name] virus, scientific illustration, high detail"
|
| 70 |
+
- "3D structure of [bacteria name] bacteria, medical visualization"
|
| 71 |
+
- "Electron microscope image of [pathogen], scientific accuracy"
|
| 72 |
+
- "Viral structure of COVID-19, detailed scientific diagram"
|
| 73 |
+
- "Bacterial cell structure of E. coli, cross-section view"
|
| 74 |
+
|
| 75 |
+
**Request Body**:
|
| 76 |
+
```json
|
| 77 |
+
{
|
| 78 |
+
"prompt": "Microscopic view of Ebola virus, scientific illustration, high detail, medical accuracy",
|
| 79 |
+
"negative_prompt": "blurry, low quality, artistic, cartoon",
|
| 80 |
+
"num_inference_steps": 12,
|
| 81 |
+
"guidance_scale": 2.0,
|
| 82 |
+
"width": 512,
|
| 83 |
+
"height": 512,
|
| 84 |
+
"seed": -1,
|
| 85 |
+
"diffusion_task": "text_to_image"
|
| 86 |
+
}
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
#### 5. Generate Disease Visualization
|
| 90 |
+
```
|
| 91 |
+
POST /api/window7/generate-disease-visualization
|
| 92 |
+
```
|
| 93 |
+
**Purpose**: Generate disease progression and infection visualizations
|
| 94 |
+
**Use Case**: Visualize disease symptoms, affected areas, and progression
|
| 95 |
+
|
| 96 |
+
**Example Prompts**:
|
| 97 |
+
- "Medical illustration of [disease] infection in human body"
|
| 98 |
+
- "Disease progression diagram of [condition], scientific style"
|
| 99 |
+
- "Affected organs in [disease], medical visualization"
|
| 100 |
+
- "Cellular damage from [pathogen] infection, microscopic view"
|
| 101 |
+
|
| 102 |
+
### Window 9: Drug Development Endpoints
|
| 103 |
+
|
| 104 |
+
#### 6. Generate Molecule Visualization
|
| 105 |
+
```
|
| 106 |
+
POST /api/window9/generate-molecule
|
| 107 |
+
```
|
| 108 |
+
**Purpose**: Generate molecular structure visualizations
|
| 109 |
+
**Use Case**: After SMILES processing, generate visual representations of molecular structures
|
| 110 |
+
|
| 111 |
+
**Example Prompts**:
|
| 112 |
+
- "3D molecular structure of aspirin, scientific visualization"
|
| 113 |
+
- "Chemical structure diagram of [SMILES notation], high detail"
|
| 114 |
+
- "Molecular bonds and atoms of [drug name], scientific illustration"
|
| 115 |
+
- "Protein-ligand complex, molecular docking visualization"
|
| 116 |
+
|
| 117 |
+
#### 7. Generate Drug Visualization
|
| 118 |
+
```
|
| 119 |
+
POST /api/window9/generate-drug-visualization
|
| 120 |
+
```
|
| 121 |
+
**Purpose**: Generate drug compound visualizations
|
| 122 |
+
**Use Case**: Visualize drug candidates and their properties
|
| 123 |
+
|
| 124 |
+
**Example Prompts**:
|
| 125 |
+
- "Drug compound [name] in 3D, pharmaceutical visualization"
|
| 126 |
+
- "Protein-ligand binding visualization for [drug name]"
|
| 127 |
+
- "Drug molecule interaction diagram, scientific style"
|
| 128 |
+
|
| 129 |
+
### General Scientific Visualization
|
| 130 |
+
|
| 131 |
+
#### 8. Generate Scientific Visualization
|
| 132 |
+
```
|
| 133 |
+
POST /api/aegis/generate-scientific
|
| 134 |
+
```
|
| 135 |
+
**Purpose**: General scientific visualization for all AEGIS windows
|
| 136 |
+
**Use Case**: Cross-window scientific imagery generation
|
| 137 |
+
|
| 138 |
+
#### 9. General Image Generation
|
| 139 |
+
```
|
| 140 |
+
POST /api/generate
|
| 141 |
+
```
|
| 142 |
+
**Purpose**: Standard image generation endpoint
|
| 143 |
+
|
| 144 |
+
### Configuration Endpoints
|
| 145 |
+
|
| 146 |
+
#### 10. Get Configuration
|
| 147 |
+
```
|
| 148 |
+
GET /api/config
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
#### 11. Get Available Models
|
| 152 |
+
```
|
| 153 |
+
GET /api/models
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## Integration Workflows
|
| 157 |
+
|
| 158 |
+
### Window 7: Disease Discovery Flow
|
| 159 |
+
|
| 160 |
+
```
|
| 161 |
+
1. Window 7 discovers new disease/pathogen
|
| 162 |
+
↓
|
| 163 |
+
2. Extract pathogen name and characteristics
|
| 164 |
+
↓
|
| 165 |
+
3. Call /api/window7/generate-pathogen with descriptive prompt
|
| 166 |
+
↓
|
| 167 |
+
4. Receive base64-encoded pathogen visualization
|
| 168 |
+
↓
|
| 169 |
+
5. Display in Window 7 UI alongside disease data
|
| 170 |
+
↓
|
| 171 |
+
6. Store in disease_analysis_v2 table
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
### Window 9: Drug Development Flow
|
| 175 |
+
|
| 176 |
+
```
|
| 177 |
+
1. Window 9 completes drug development analysis
|
| 178 |
+
↓
|
| 179 |
+
2. SMILES notation generated for drug compound
|
| 180 |
+
↓
|
| 181 |
+
3. Call /api/window9/generate-molecule with molecular prompt
|
| 182 |
+
↓
|
| 183 |
+
4. Receive base64-encoded molecular structure
|
| 184 |
+
↓
|
| 185 |
+
5. Display in Window 9 UI
|
| 186 |
+
↓
|
| 187 |
+
6. Store in drug_development table
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
## Example Integration Code
|
| 191 |
+
|
| 192 |
+
### Window 7: Pathogen Visualization
|
| 193 |
+
|
| 194 |
+
```javascript
|
| 195 |
+
// After disease discovery in Window 7
|
| 196 |
+
async function generatePathogenVisualization(diseaseData) {
|
| 197 |
+
const response = await fetch('https://sci-image-api.com/api/window7/generate-pathogen', {
|
| 198 |
+
method: 'POST',
|
| 199 |
+
headers: {
|
| 200 |
+
'Content-Type': 'application/json',
|
| 201 |
+
},
|
| 202 |
+
body: JSON.stringify({
|
| 203 |
+
prompt: `Microscopic view of ${diseaseData.pathogen_name} ${diseaseData.pathogen_type}, scientific illustration, high detail, medical accuracy`,
|
| 204 |
+
negative_prompt: 'blurry, low quality, artistic, cartoon, unrealistic',
|
| 205 |
+
num_inference_steps: 12,
|
| 206 |
+
guidance_scale: 2.0,
|
| 207 |
+
width: 512,
|
| 208 |
+
height: 512,
|
| 209 |
+
seed: -1,
|
| 210 |
+
diffusion_task: 'text_to_image'
|
| 211 |
+
})
|
| 212 |
+
});
|
| 213 |
+
|
| 214 |
+
const result = await response.json();
|
| 215 |
+
|
| 216 |
+
// Store in database
|
| 217 |
+
await fetch('/api/window7/disease-analysis', {
|
| 218 |
+
method: 'PATCH',
|
| 219 |
+
body: JSON.stringify({
|
| 220 |
+
id: diseaseData.id,
|
| 221 |
+
pathogen_image: result.images[0],
|
| 222 |
+
image_generation_latency: result.latency
|
| 223 |
+
})
|
| 224 |
+
});
|
| 225 |
+
|
| 226 |
+
return result.images[0]; // Base64 image
|
| 227 |
+
}
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
### Window 9: Molecular Visualization
|
| 231 |
+
|
| 232 |
+
```javascript
|
| 233 |
+
// After drug development completion in Window 9
|
| 234 |
+
async function generateMolecularVisualization(drugData) {
|
| 235 |
+
const response = await fetch('https://sci-image-api.com/api/window9/generate-molecule', {
|
| 236 |
+
method: 'POST',
|
| 237 |
+
headers: {
|
| 238 |
+
'Content-Type': 'application/json',
|
| 239 |
+
},
|
| 240 |
+
body: JSON.stringify({
|
| 241 |
+
prompt: `3D molecular structure of ${drugData.compound_name}, SMILES: ${drugData.smiles}, scientific visualization, high detail`,
|
| 242 |
+
negative_prompt: 'blurry, low quality, distorted, artistic',
|
| 243 |
+
num_inference_steps: 10,
|
| 244 |
+
guidance_scale: 1.8,
|
| 245 |
+
width: 512,
|
| 246 |
+
height: 512,
|
| 247 |
+
seed: -1,
|
| 248 |
+
diffusion_task: 'text_to_image'
|
| 249 |
+
})
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
const result = await response.json();
|
| 253 |
+
return result.images[0]; // Base64 image
|
| 254 |
+
}
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
## Response Format
|
| 258 |
+
|
| 259 |
+
All generation endpoints return:
|
| 260 |
+
```json
|
| 261 |
+
{
|
| 262 |
+
"latency": 2.5,
|
| 263 |
+
"images": ["base64_encoded_image_1", "base64_encoded_image_2"],
|
| 264 |
+
"error": null
|
| 265 |
+
}
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
## Configuration Parameters
|
| 269 |
+
|
| 270 |
+
### LCMDiffusionSetting Parameters
|
| 271 |
+
|
| 272 |
+
| Parameter | Type | Default | Description |
|
| 273 |
+
|-----------|------|---------|-------------|
|
| 274 |
+
| `prompt` | string | required | Text description of desired image |
|
| 275 |
+
| `negative_prompt` | string | "" | What to avoid in generation |
|
| 276 |
+
| `num_inference_steps` | int | 4 | Number of denoising steps (4-50) |
|
| 277 |
+
| `guidance_scale` | float | 1.0 | How closely to follow prompt (1.0-2.0) |
|
| 278 |
+
| `width` | int | 512 | Image width in pixels |
|
| 279 |
+
| `height` | int | 512 | Image height in pixels |
|
| 280 |
+
| `seed` | int | -1 | Random seed (-1 for random) |
|
| 281 |
+
| `diffusion_task` | string | "text_to_image" | "text_to_image" or "image_to_image" |
|
| 282 |
+
| `init_image` | string | null | Base64 image for img2img |
|
| 283 |
+
| `strength` | float | 0.8 | Img2img transformation strength |
|
| 284 |
+
|
| 285 |
+
## Best Practices
|
| 286 |
+
|
| 287 |
+
### For Pathogen Visualizations (Window 7)
|
| 288 |
+
1. **Prompt Structure**: "[Pathogen type] view of [pathogen name], scientific illustration, high detail, medical accuracy"
|
| 289 |
+
2. **Negative Prompts**: Always include "blurry, low quality, artistic, cartoon, unrealistic"
|
| 290 |
+
3. **Steps**: Use 10-15 steps for medical accuracy
|
| 291 |
+
4. **Guidance**: Set to 1.8-2.0 for scientific precision
|
| 292 |
+
5. **Keywords**: Include "microscopic", "electron microscope", "scientific", "medical"
|
| 293 |
+
|
| 294 |
+
**Example Prompts for Common Pathogens**:
|
| 295 |
+
- Viruses: "Electron microscope view of [virus name] virion, detailed capsid structure, scientific accuracy"
|
| 296 |
+
- Bacteria: "Microscopic view of [bacteria name] bacterial cell, flagella visible, scientific illustration"
|
| 297 |
+
- Fungi: "Microscopic structure of [fungus name], spores and hyphae, medical visualization"
|
| 298 |
+
- Parasites: "Detailed view of [parasite name], life cycle stage, scientific diagram"
|
| 299 |
+
|
| 300 |
+
### For Molecular Visualizations (Window 9)
|
| 301 |
+
1. **Include SMILES**: Reference SMILES notation in prompt when available
|
| 302 |
+
2. **Specify Style**: "3D molecular structure", "ball-and-stick model", "space-filling model"
|
| 303 |
+
3. **Scientific Terms**: Use "bonds", "atoms", "molecular geometry"
|
| 304 |
+
4. **Steps**: 8-12 for molecular accuracy
|
| 305 |
+
5. **Guidance**: 1.5-2.0 for precise structures
|
| 306 |
+
|
| 307 |
+
### Performance Optimization
|
| 308 |
+
1. Use lower `num_inference_steps` (4-6) for faster generation during development
|
| 309 |
+
2. Increase steps (10-15) for production/final visualizations
|
| 310 |
+
3. Cache frequently generated pathogen/molecule images
|
| 311 |
+
4. Batch multiple requests when generating variations
|
| 312 |
+
|
| 313 |
+
## Prompt Templates
|
| 314 |
+
|
| 315 |
+
### Window 7 Templates
|
| 316 |
+
|
| 317 |
+
#### Virus Visualization
|
| 318 |
+
```
|
| 319 |
+
"Electron microscope view of {virus_name} virus, detailed viral structure, capsid proteins visible, scientific illustration, high detail, medical accuracy"
|
| 320 |
+
```
|
| 321 |
+
|
| 322 |
+
#### Bacteria Visualization
|
| 323 |
+
```
|
| 324 |
+
"Microscopic view of {bacteria_name} bacteria, cell wall structure, flagella, scientific illustration, gram stain appearance, medical accuracy"
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
#### Disease Progression
|
| 328 |
+
```
|
| 329 |
+
"Medical illustration of {disease_name} infection progression in human {organ/tissue}, cellular level, scientific diagram, pathological changes"
|
| 330 |
+
```
|
| 331 |
+
|
| 332 |
+
### Window 9 Templates
|
| 333 |
+
|
| 334 |
+
#### Molecular Structure
|
| 335 |
+
```
|
| 336 |
+
"3D molecular structure of {compound_name}, SMILES: {smiles_notation}, ball-and-stick model, chemical bonds visible, scientific visualization, high detail"
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
#### Drug-Protein Interaction
|
| 340 |
+
```
|
| 341 |
+
"Protein-ligand binding visualization, {drug_name} docking with {protein_name}, molecular interaction diagram, scientific style, binding site highlighted"
|
| 342 |
+
```
|
| 343 |
+
|
| 344 |
+
## Monitoring
|
| 345 |
+
|
| 346 |
+
### UptimeRobot Configuration
|
| 347 |
+
- **Monitor Type**: HTTP(s)
|
| 348 |
+
- **URL**: `https://your-sci-image-api.com/api/ping`
|
| 349 |
+
- **Interval**: 5 minutes
|
| 350 |
+
- **Expected Response**: `200 OK` with `"status": "ok"`
|
| 351 |
+
|
| 352 |
+
### Health Check Schedule
|
| 353 |
+
- Ping endpoint: Every 5 minutes
|
| 354 |
+
- Health endpoint: Every 15 minutes
|
| 355 |
+
- Full system check: Every hour
|
| 356 |
+
|
| 357 |
+
## Error Handling
|
| 358 |
+
|
| 359 |
+
### Common Errors
|
| 360 |
+
|
| 361 |
+
| Error | Cause | Solution |
|
| 362 |
+
|-------|-------|----------|
|
| 363 |
+
| `latency > 30s` | Complex prompt or high steps | Reduce steps or simplify prompt |
|
| 364 |
+
| `images: []` | Generation failed | Check prompt validity |
|
| 365 |
+
| `error: "Out of memory"` | Image too large | Reduce dimensions |
|
| 366 |
+
| `error: "Model not loaded"` | Model initialization failed | Restart service |
|
| 367 |
+
|
| 368 |
+
## Database Integration
|
| 369 |
+
|
| 370 |
+
### Window 7: Storing Pathogen Images
|
| 371 |
+
|
| 372 |
+
```sql
|
| 373 |
+
-- Add pathogen_image column to disease_analysis_v2
|
| 374 |
+
ALTER TABLE disease_analysis_v2
|
| 375 |
+
ADD COLUMN pathogen_image TEXT,
|
| 376 |
+
ADD COLUMN pathogen_image_prompt TEXT,
|
| 377 |
+
ADD COLUMN image_generation_latency REAL;
|
| 378 |
+
```
|
| 379 |
+
|
| 380 |
+
### Window 9: Storing Molecular Images
|
| 381 |
+
|
| 382 |
+
```sql
|
| 383 |
+
-- Add molecular_image column to drug_development
|
| 384 |
+
ALTER TABLE drug_development
|
| 385 |
+
ADD COLUMN molecular_structure_image TEXT,
|
| 386 |
+
ADD COLUMN molecular_image_prompt TEXT,
|
| 387 |
+
ADD COLUMN image_generation_latency REAL;
|
| 388 |
+
```
|
| 389 |
+
|
| 390 |
+
## Deployment
|
| 391 |
+
|
| 392 |
+
### Environment Variables
|
| 393 |
+
```bash
|
| 394 |
+
DEVICE=cpu
|
| 395 |
+
APP_VERSION=1.0.0
|
| 396 |
+
PORT=8000
|
| 397 |
+
```
|
| 398 |
+
|
| 399 |
+
### Docker Deployment
|
| 400 |
+
```bash
|
| 401 |
+
docker build -t aegis-visual-system .
|
| 402 |
+
docker run -p 8000:8000 aegis-visual-system
|
| 403 |
+
```
|
| 404 |
+
|
| 405 |
+
### Hugging Face Space
|
| 406 |
+
- SDK: Docker
|
| 407 |
+
- App Port: 7860
|
| 408 |
+
- Python Version: 3.12 (see `.python-version`)
|
| 409 |
+
|
| 410 |
+
## Future Enhancements
|
| 411 |
+
|
| 412 |
+
1. **GPU Acceleration**: Add CUDA support for faster generation
|
| 413 |
+
2. **Model Fine-tuning**: Train on medical/scientific imagery datasets
|
| 414 |
+
3. **3D Rendering**: Generate rotatable 3D pathogen/molecule models
|
| 415 |
+
4. **Animation**: Create pathogen lifecycle and molecular interaction animations
|
| 416 |
+
5. **Style Transfer**: Apply scientific paper/textbook style
|
| 417 |
+
6. **Batch Processing**: Generate multiple variations simultaneously
|
| 418 |
+
7. **Real-time Generation**: WebSocket support for live visualization
|
| 419 |
+
|
| 420 |
+
## Version History
|
| 421 |
+
|
| 422 |
+
- **v1.0.0** (2026-05-31): Initial AEGIS Bio-Digital Lab 10 integration
|
| 423 |
+
- Added ping endpoint for UptimeRobot
|
| 424 |
+
- Added Window 7 pathogen visualization endpoints
|
| 425 |
+
- Added Window 9 molecular visualization endpoints
|
| 426 |
+
- Added AEGIS scientific visualization endpoint
|
| 427 |
+
- Added comprehensive health checks
|
| 428 |
+
- Integrated with disease discovery and drug development workflows
|
DEPLOY_API_FIX.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HuggingFace Space API Fix - Deployment Guide
|
| 2 |
+
|
| 3 |
+
## Problem Identified
|
| 4 |
+
The original `hf_demo.py` had no API endpoint configured. The `predict` function was only connected to the UI button, making it impossible to call via the Gradio API.
|
| 5 |
+
|
| 6 |
+
## Solution Implemented
|
| 7 |
+
Updated `sci-image/src/frontend/webui/hf_demo.py` with:
|
| 8 |
+
|
| 9 |
+
1. **API-enabled predict function** with proper parameters:
|
| 10 |
+
- `prompt`: Text description
|
| 11 |
+
- `width`: Image width (default: 512)
|
| 12 |
+
- `height`: Image height (default: 512)
|
| 13 |
+
- `num_images`: Number of images (default: 1)
|
| 14 |
+
- `steps`: Inference steps (default: 4)
|
| 15 |
+
- `guidance_scale`: Guidance scale (default: 1.0)
|
| 16 |
+
- `seed`: Random seed, -1 for random (default: -1)
|
| 17 |
+
|
| 18 |
+
2. **Separate UI and API functions**:
|
| 19 |
+
- `ui_predict()`: Handles UI button clicks
|
| 20 |
+
- `predict()`: Handles API calls with full parameters
|
| 21 |
+
|
| 22 |
+
3. **gr.Interface for API**:
|
| 23 |
+
- Created explicit API interface with `api_name="predict"`
|
| 24 |
+
- This enables `/api/predict` endpoint
|
| 25 |
+
|
| 26 |
+
## Deployment Steps
|
| 27 |
+
|
| 28 |
+
### 1. Push to HuggingFace Space
|
| 29 |
+
```bash
|
| 30 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 31 |
+
|
| 32 |
+
# Add and commit changes
|
| 33 |
+
git add src/frontend/webui/hf_demo.py
|
| 34 |
+
git commit -m "Add API endpoint for external calls"
|
| 35 |
+
|
| 36 |
+
# Push to HuggingFace Space
|
| 37 |
+
git push origin main
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### 2. Wait for Space to Rebuild
|
| 41 |
+
- Go to: https://huggingface.co/spaces/gsstec/sci-image
|
| 42 |
+
- Wait for the Space to rebuild (usually 2-5 minutes)
|
| 43 |
+
- Check the logs for any errors
|
| 44 |
+
|
| 45 |
+
### 3. Test the API Endpoint
|
| 46 |
+
|
| 47 |
+
#### Test via Gradio API:
|
| 48 |
+
```bash
|
| 49 |
+
# Step 1: Call predict
|
| 50 |
+
curl -X POST https://gsstec-sci-image.hf.space/gradio_api/call/predict \
|
| 51 |
+
-H "Content-Type: application/json" \
|
| 52 |
+
-d '{
|
| 53 |
+
"data": [
|
| 54 |
+
"a virus under microscope, scientific visualization",
|
| 55 |
+
512,
|
| 56 |
+
512,
|
| 57 |
+
1,
|
| 58 |
+
4,
|
| 59 |
+
1.0,
|
| 60 |
+
-1
|
| 61 |
+
]
|
| 62 |
+
}'
|
| 63 |
+
|
| 64 |
+
# Response: {"event_id": "some-id"}
|
| 65 |
+
|
| 66 |
+
# Step 2: Poll for results
|
| 67 |
+
curl https://gsstec-sci-image.hf.space/gradio_api/call/predict/{event_id}
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### 4. Test from Frontend
|
| 71 |
+
Navigate to: `http://localhost:8080/window/9/test`
|
| 72 |
+
|
| 73 |
+
The test page will now:
|
| 74 |
+
1. Call the Space API with proper parameters
|
| 75 |
+
2. Poll for results
|
| 76 |
+
3. Display the generated image
|
| 77 |
+
4. Show detailed logs of the entire process
|
| 78 |
+
|
| 79 |
+
## API Parameters Mapping
|
| 80 |
+
|
| 81 |
+
Our frontend sends:
|
| 82 |
+
```javascript
|
| 83 |
+
{
|
| 84 |
+
data: [
|
| 85 |
+
prompt, // "a virus under microscope..."
|
| 86 |
+
512, // width
|
| 87 |
+
512, // height
|
| 88 |
+
1, // num_images
|
| 89 |
+
4, // num_inference_steps
|
| 90 |
+
1.0, // guidance_scale
|
| 91 |
+
-1 // seed (random)
|
| 92 |
+
]
|
| 93 |
+
}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
The Space receives these in order as function parameters.
|
| 97 |
+
|
| 98 |
+
## Expected Response Format
|
| 99 |
+
|
| 100 |
+
The Space will return via SSE stream:
|
| 101 |
+
```
|
| 102 |
+
data: [{"url": "https://gsstec-sci-image.hf.space/file=/tmp/gradio/xxx.webp", "path": "/tmp/gradio/xxx.webp"}]
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
Our frontend extracts `data[0].url` and displays the image.
|
| 106 |
+
|
| 107 |
+
## Troubleshooting
|
| 108 |
+
|
| 109 |
+
### If API still returns null:
|
| 110 |
+
1. Check Space logs for errors
|
| 111 |
+
2. Verify the Space rebuilt successfully
|
| 112 |
+
3. Test the UI directly on the Space to ensure generation works
|
| 113 |
+
4. Check if the API endpoint is accessible: `https://gsstec-sci-image.hf.space/api/predict`
|
| 114 |
+
|
| 115 |
+
### If images don't display:
|
| 116 |
+
1. The temporary URLs expire quickly
|
| 117 |
+
2. Consider downloading the image immediately in the Durable Object
|
| 118 |
+
3. Or convert to base64 in the Space before returning
|
| 119 |
+
|
| 120 |
+
## Next Steps After Deployment
|
| 121 |
+
|
| 122 |
+
1. **Test the API**: Use the test page to verify it works
|
| 123 |
+
2. **Update Window 9**: Once confirmed working, update the main Window 9 page
|
| 124 |
+
3. **Add image caching**: Implement immediate download in Durable Object to avoid URL expiration
|
| 125 |
+
4. **Add error handling**: Better error messages for failed generations
|
| 126 |
+
|
| 127 |
+
## Files Modified
|
| 128 |
+
- `sci-image/src/frontend/webui/hf_demo.py` - Added API interface and proper parameter handling
|
DEPLOY_API_SERVER.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deploy API Server to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
## Problem
|
| 4 |
+
The current Hugging Face Space deployment is running in `--hfdemo` mode, which provides a Gradio UI but does NOT expose the API endpoints like `/api/ping`, `/api/health`, etc.
|
| 5 |
+
|
| 6 |
+
## Solution
|
| 7 |
+
The Dockerfile has been updated to:
|
| 8 |
+
1. Run in `--api` mode instead of `--hfdemo` mode
|
| 9 |
+
2. Use port 7860 (required by Hugging Face Spaces) instead of the default port 8000
|
| 10 |
+
|
| 11 |
+
## Deployment Steps
|
| 12 |
+
|
| 13 |
+
### 1. Commit and Push Changes
|
| 14 |
+
```bash
|
| 15 |
+
cd sci-image
|
| 16 |
+
git add Dockerfile
|
| 17 |
+
git commit -m "Switch to API server mode for Hugging Face Space"
|
| 18 |
+
git push
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
### 2. Push to Hugging Face Space
|
| 22 |
+
If you have the Hugging Face Space connected as a remote:
|
| 23 |
+
```bash
|
| 24 |
+
git push hf main
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
Or manually upload the updated Dockerfile to your Hugging Face Space at:
|
| 28 |
+
https://huggingface.co/spaces/gsstec/sci-image/tree/main
|
| 29 |
+
|
| 30 |
+
### 3. Wait for Rebuild
|
| 31 |
+
The Hugging Face Space will automatically rebuild with the new Dockerfile. This may take 5-10 minutes.
|
| 32 |
+
|
| 33 |
+
### 4. Verify API Endpoints
|
| 34 |
+
Once deployed, test the endpoints:
|
| 35 |
+
|
| 36 |
+
**Ping Endpoint:**
|
| 37 |
+
```bash
|
| 38 |
+
curl https://gsstec-sci-image.hf.space/api/ping
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
Expected response:
|
| 42 |
+
```json
|
| 43 |
+
{
|
| 44 |
+
"status": "ok",
|
| 45 |
+
"service": "AEGIS Bio-Digital Lab 10 - Visual System",
|
| 46 |
+
"version": "1.0.0",
|
| 47 |
+
"device": "cpu"
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
**Health Endpoint:**
|
| 52 |
+
```bash
|
| 53 |
+
curl https://gsstec-sci-image.hf.space/api/health
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
**System Info:**
|
| 57 |
+
```bash
|
| 58 |
+
curl https://gsstec-sci-image.hf.space/api/info
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Available API Endpoints After Deployment
|
| 62 |
+
|
| 63 |
+
### Health & Monitoring
|
| 64 |
+
- `GET /api/` - Welcome message
|
| 65 |
+
- `GET /api/ping` - Health check for UptimeRobot
|
| 66 |
+
- `GET /api/health` - Detailed health status
|
| 67 |
+
- `GET /api/info` - System information
|
| 68 |
+
- `GET /api/config` - Current configuration
|
| 69 |
+
- `GET /api/models` - Available models
|
| 70 |
+
|
| 71 |
+
### Image Generation
|
| 72 |
+
- `POST /api/generate` - General image generation
|
| 73 |
+
- `POST /api/window7/generate-pathogen` - Pathogen visualization
|
| 74 |
+
- `POST /api/window7/generate-disease-visualization` - Disease visualization
|
| 75 |
+
- `POST /api/window9/generate-molecule` - Molecular structure
|
| 76 |
+
- `POST /api/window9/generate-drug-visualization` - Drug visualization
|
| 77 |
+
- `POST /api/aegis/generate-scientific` - Scientific visualization
|
| 78 |
+
|
| 79 |
+
### API Documentation
|
| 80 |
+
- `/api/docs` - Swagger UI documentation
|
| 81 |
+
- `/api/redoc` - ReDoc documentation
|
| 82 |
+
- `/api/openapi.json` - OpenAPI specification
|
| 83 |
+
|
| 84 |
+
## UptimeRobot Configuration
|
| 85 |
+
|
| 86 |
+
After deployment, configure UptimeRobot:
|
| 87 |
+
- **Monitor Type**: HTTP(s)
|
| 88 |
+
- **URL**: `https://gsstec-sci-image.hf.space/api/ping`
|
| 89 |
+
- **Interval**: 5 minutes
|
| 90 |
+
- **Expected Response**: `200 OK` with `"status": "ok"`
|
| 91 |
+
|
| 92 |
+
## Testing Locally
|
| 93 |
+
|
| 94 |
+
To test the API server locally before deploying:
|
| 95 |
+
```bash
|
| 96 |
+
cd sci-image
|
| 97 |
+
python src/app.py --api
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
Then test:
|
| 101 |
+
```bash
|
| 102 |
+
curl http://localhost:8000/api/ping
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
## Reverting to UI Mode
|
| 106 |
+
|
| 107 |
+
If you need to revert to the Gradio UI:
|
| 108 |
+
```dockerfile
|
| 109 |
+
CMD ["python", "src/app.py","--hfdemo"]
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
## Notes
|
| 113 |
+
|
| 114 |
+
- The API server runs on port 7860 (as configured in Dockerfile EXPOSE)
|
| 115 |
+
- CORS is enabled for all origins
|
| 116 |
+
- The server uses FastAPI with automatic OpenAPI documentation
|
| 117 |
+
- All endpoints are prefixed with `/api/`
|
DEPLOY_SECURE.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Secure Hugging Face Deployment Guide
|
| 2 |
+
|
| 3 |
+
## Problem Solved
|
| 4 |
+
Hugging Face rejects pushes containing hardcoded tokens in files. This guide shows how to deploy securely using environment variables.
|
| 5 |
+
|
| 6 |
+
## Quick Setup
|
| 7 |
+
|
| 8 |
+
### Step 1: Set Your Token as Environment Variable
|
| 9 |
+
|
| 10 |
+
**PowerShell (Recommended):**
|
| 11 |
+
```powershell
|
| 12 |
+
# Set for current session (replace with your actual token)
|
| 13 |
+
$env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE"
|
| 14 |
+
|
| 15 |
+
# Or set permanently (run as Administrator)
|
| 16 |
+
[System.Environment]::SetEnvironmentVariable('HF_TOKEN', 'hf_YOUR_ACTUAL_TOKEN_HERE', 'User')
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
**Command Prompt:**
|
| 20 |
+
```cmd
|
| 21 |
+
set HF_TOKEN=hf_YOUR_ACTUAL_TOKEN_HERE
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
### Step 2: Run Deployment Script
|
| 25 |
+
|
| 26 |
+
**Option A: Use the Batch Script**
|
| 27 |
+
```powershell
|
| 28 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 29 |
+
.\deploy-to-huggingface.bat
|
| 30 |
+
```
|
| 31 |
+
The script will use the `HF_TOKEN` environment variable or prompt you for it.
|
| 32 |
+
|
| 33 |
+
**Option B: Use the PowerShell Script**
|
| 34 |
+
```powershell
|
| 35 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 36 |
+
.\deploy-to-huggingface.ps1
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## Manual Deployment (If Scripts Fail)
|
| 40 |
+
|
| 41 |
+
```powershell
|
| 42 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 43 |
+
|
| 44 |
+
# 1. Set token (use your actual token)
|
| 45 |
+
$env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE"
|
| 46 |
+
|
| 47 |
+
# 2. Remove old remote if exists
|
| 48 |
+
git remote remove hf 2>$null
|
| 49 |
+
|
| 50 |
+
# 3. Add remote with token from environment
|
| 51 |
+
git remote add hf "https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image"
|
| 52 |
+
|
| 53 |
+
# 4. Add and commit changes
|
| 54 |
+
git add -A
|
| 55 |
+
git commit -m "Update deployment"
|
| 56 |
+
|
| 57 |
+
# 5. Pull and merge remote changes
|
| 58 |
+
git pull hf main --allow-unrelated-histories --no-rebase -X theirs
|
| 59 |
+
|
| 60 |
+
# 6. Push to Hugging Face
|
| 61 |
+
git push hf main
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## Alternative: Use .env File (Local Only)
|
| 65 |
+
|
| 66 |
+
1. Create a `.env` file in the sci-image directory:
|
| 67 |
+
```bash
|
| 68 |
+
HF_TOKEN=hf_YOUR_ACTUAL_TOKEN_HERE
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
2. The `.env` file is already in `.gitignore` so it won't be committed
|
| 72 |
+
|
| 73 |
+
3. Load it in PowerShell before deploying:
|
| 74 |
+
```powershell
|
| 75 |
+
Get-Content .env | ForEach-Object {
|
| 76 |
+
if ($_ -match '^([^=]+)=(.*)$') {
|
| 77 |
+
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
## Why This Approach?
|
| 83 |
+
|
| 84 |
+
✅ **Secure**: Token is never committed to git
|
| 85 |
+
✅ **Flexible**: Works with both batch and PowerShell scripts
|
| 86 |
+
✅ **Reusable**: Set once, use multiple times
|
| 87 |
+
✅ **HF Compliant**: Passes Hugging Face's security checks
|
| 88 |
+
|
| 89 |
+
## Troubleshooting
|
| 90 |
+
|
| 91 |
+
### Error: "You are not authorized to push"
|
| 92 |
+
- Make sure `HF_TOKEN` environment variable is set correctly
|
| 93 |
+
- Verify your token has write access to the space
|
| 94 |
+
- Check token hasn't expired
|
| 95 |
+
|
| 96 |
+
### Error: "Updates were rejected"
|
| 97 |
+
- The scripts now handle this automatically by pulling first
|
| 98 |
+
- If manual intervention needed, run: `git pull hf main --allow-unrelated-histories`
|
| 99 |
+
|
| 100 |
+
### Error: "Offending files contain tokens"
|
| 101 |
+
- This means a token was hardcoded in a file
|
| 102 |
+
- Remove the hardcoded token and use environment variable instead
|
| 103 |
+
- Commit the cleaned files before pushing
|
| 104 |
+
|
| 105 |
+
## Space Information
|
| 106 |
+
|
| 107 |
+
- **Space URL**: https://huggingface.co/spaces/gsstec/sci-image
|
| 108 |
+
- **Repository**: gsstec/sci-image
|
| 109 |
+
- **Branch**: main
|
| 110 |
+
|
| 111 |
+
## Files Modified
|
| 112 |
+
|
| 113 |
+
- `deploy-to-huggingface.bat` - Uses environment variable for token
|
| 114 |
+
- `deploy-to-huggingface.ps1` - Uses environment variable for token
|
| 115 |
+
- `.gitignore` - Added `.env` to prevent committing secrets
|
| 116 |
+
- `.env.example` - Template for local token storage
|
| 117 |
+
|
| 118 |
+
## Next Steps
|
| 119 |
+
|
| 120 |
+
1. Set your `HF_TOKEN` environment variable with your actual token
|
| 121 |
+
2. Run `.\deploy-to-huggingface.bat` or `.\deploy-to-huggingface.ps1`
|
| 122 |
+
3. Your changes will be deployed securely to Hugging Face
|
| 123 |
+
|
| 124 |
+
**Important**: Never commit files containing actual tokens. Always use environment variables or .env files (which are gitignored).
|
Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ghcr.io/astral-sh/uv:python3.11-trixie-slim
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get install -y \
|
| 4 |
+
git curl build-essential libgl1 libglib2.0-0 \
|
| 5 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
ENV DEVICE=cpu
|
| 8 |
+
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
COPY . .
|
| 11 |
+
|
| 12 |
+
RUN uv pip install --system --no-cache-dir \
|
| 13 |
+
torch==2.8.0 torchvision==0.23.0 \
|
| 14 |
+
--index-url https://download.pytorch.org/whl/cpu
|
| 15 |
+
|
| 16 |
+
RUN uv pip install --system --no-cache-dir -r requirements.txt
|
| 17 |
+
|
| 18 |
+
EXPOSE 7860
|
| 19 |
+
|
| 20 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 21 |
+
|
| 22 |
+
CMD ["python", "src/app.py","--api","--port","7860"]
|
FINAL_SOLUTION.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Final Solution: Ping Endpoint for Hugging Face Space
|
| 2 |
+
|
| 3 |
+
## Current Situation
|
| 4 |
+
|
| 5 |
+
The Hugging Face Space at `https://gsstec-sci-image.hf.space` is configured to run in `--hfdemo` mode, which provides a Gradio UI for interactive image generation.
|
| 6 |
+
|
| 7 |
+
## The Ping Endpoint Challenge
|
| 8 |
+
|
| 9 |
+
**Problem**: You need a `/api/ping` endpoint for UptimeRobot monitoring, but the application architecture doesn't support running both Gradio UI and FastAPI endpoints simultaneously.
|
| 10 |
+
|
| 11 |
+
## Solution Options
|
| 12 |
+
|
| 13 |
+
### Option 1: Use Gradio's Built-in API (RECOMMENDED)
|
| 14 |
+
|
| 15 |
+
Gradio automatically provides API endpoints for all functions. Use Gradio's health check:
|
| 16 |
+
|
| 17 |
+
**Endpoint**: `https://gsstec-sci-image.hf.space/gradio_api/call/predict`
|
| 18 |
+
|
| 19 |
+
**UptimeRobot Configuration**:
|
| 20 |
+
- Monitor Type: HTTP(s)
|
| 21 |
+
- URL: `https://gsstec-sci-image.hf.space/`
|
| 22 |
+
- Method: GET
|
| 23 |
+
- Expected Response: 200 OK (Gradio UI loads)
|
| 24 |
+
|
| 25 |
+
### Option 2: Deploy Two Separate Spaces
|
| 26 |
+
|
| 27 |
+
1. **UI Space** (Current): `https://gsstec-sci-image.hf.space`
|
| 28 |
+
- Mode: `--hfdemo`
|
| 29 |
+
- Purpose: Interactive UI for users
|
| 30 |
+
|
| 31 |
+
2. **API Space** (New): `https://gsstec-sci-image-api.hf.space`
|
| 32 |
+
- Mode: `--api`
|
| 33 |
+
- Purpose: REST API endpoints + monitoring
|
| 34 |
+
- Ping: `https://gsstec-sci-image-api.hf.space/api/ping`
|
| 35 |
+
|
| 36 |
+
### Option 3: Switch to API-Only Mode
|
| 37 |
+
|
| 38 |
+
Change Dockerfile to use `--api` mode:
|
| 39 |
+
```dockerfile
|
| 40 |
+
CMD ["python", "src/app.py","--api","--port","7860"]
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
**Trade-off**: Loses interactive UI, gains full REST API
|
| 44 |
+
|
| 45 |
+
## Recommended Approach
|
| 46 |
+
|
| 47 |
+
**Keep the current `--hfdemo` setup** and use one of these monitoring strategies:
|
| 48 |
+
|
| 49 |
+
1. **Monitor the root URL**: `https://gsstec-sci-image.hf.space/`
|
| 50 |
+
- UptimeRobot checks if the Gradio UI loads
|
| 51 |
+
- Simple and effective
|
| 52 |
+
|
| 53 |
+
2. **Use Gradio's API endpoint**: `https://gsstec-sci-image.hf.space/gradio_api/call/predict`
|
| 54 |
+
- Monitors the actual generation functionality
|
| 55 |
+
- More comprehensive health check
|
| 56 |
+
|
| 57 |
+
3. **Deploy a separate API-only Space** for monitoring and programmatic access
|
| 58 |
+
- Best of both worlds
|
| 59 |
+
- Requires maintaining two deployments
|
| 60 |
+
|
| 61 |
+
## Current Files Status
|
| 62 |
+
|
| 63 |
+
- [`Dockerfile`](sci-image/Dockerfile:22) - Set to `--hfdemo` (Gradio UI)
|
| 64 |
+
- [`hf_demo.py`](sci-image/src/frontend/webui/hf_demo.py:225) - Standard Gradio launch
|
| 65 |
+
- [`web.py`](sci-image/src/backend/api/web.py:47) - FastAPI with HEAD support (not active in hfdemo mode)
|
| 66 |
+
|
| 67 |
+
## Why Hybrid Mode Doesn't Work
|
| 68 |
+
|
| 69 |
+
The application uses two different web frameworks:
|
| 70 |
+
- **Gradio**: For the interactive UI (port 7860)
|
| 71 |
+
- **FastAPI**: For REST API endpoints (port 7860)
|
| 72 |
+
|
| 73 |
+
Both try to bind to the same port, and the architecture doesn't support running them together without significant refactoring.
|
| 74 |
+
|
| 75 |
+
## Next Steps
|
| 76 |
+
|
| 77 |
+
1. **For immediate monitoring**: Configure UptimeRobot to monitor `https://gsstec-sci-image.hf.space/` (root URL)
|
| 78 |
+
|
| 79 |
+
2. **For API access**: Deploy a second Space in `--api` mode for programmatic access and dedicated ping endpoint
|
| 80 |
+
|
| 81 |
+
3. **For long-term solution**: Refactor the application to use FastAPI as the primary server with Gradio mounted as a sub-application (requires significant code changes)
|
| 82 |
+
|
| 83 |
+
## Summary
|
| 84 |
+
|
| 85 |
+
**Ping Endpoint**: Not available in current `--hfdemo` mode
|
| 86 |
+
**Alternative**: Monitor root URL `https://gsstec-sci-image.hf.space/`
|
| 87 |
+
**Best Solution**: Deploy separate API-only Space for monitoring
|
HUGGINGFACE_DEPLOYMENT_FIX.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Deployment Fix Guide
|
| 2 |
+
|
| 3 |
+
## Problem
|
| 4 |
+
The push to Hugging Face was rejected because the remote repository contains changes that aren't in your local repository.
|
| 5 |
+
|
| 6 |
+
## Quick Solution
|
| 7 |
+
|
| 8 |
+
### Option 1: Use the PowerShell Script (Recommended)
|
| 9 |
+
Run the new PowerShell script that handles everything automatically:
|
| 10 |
+
```powershell
|
| 11 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 12 |
+
|
| 13 |
+
# Set your token first
|
| 14 |
+
$env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE"
|
| 15 |
+
|
| 16 |
+
# Run the script
|
| 17 |
+
.\deploy-to-huggingface.ps1
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
This script will:
|
| 21 |
+
- Add and commit your changes
|
| 22 |
+
- Set up the HF remote with authentication
|
| 23 |
+
- Pull and merge remote changes
|
| 24 |
+
- Push to Hugging Face with proper error handling
|
| 25 |
+
|
| 26 |
+
### Option 2: Manual Steps
|
| 27 |
+
If you prefer to do it manually:
|
| 28 |
+
|
| 29 |
+
```powershell
|
| 30 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 31 |
+
|
| 32 |
+
# 1. Set your token (replace with actual token)
|
| 33 |
+
$env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE"
|
| 34 |
+
|
| 35 |
+
# 2. Add and commit your changes
|
| 36 |
+
git add -A
|
| 37 |
+
git commit -m "Update sci-image deployment"
|
| 38 |
+
|
| 39 |
+
# 3. Set up HF remote with token
|
| 40 |
+
git remote add hf https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image
|
| 41 |
+
|
| 42 |
+
# 4. Pull remote changes (merge strategy)
|
| 43 |
+
git pull hf main --allow-unrelated-histories --no-rebase -X theirs
|
| 44 |
+
|
| 45 |
+
# 5. Push to Hugging Face
|
| 46 |
+
git push hf main
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### Option 3: Force Push (Use with Caution)
|
| 50 |
+
If you're certain your local version is correct and want to overwrite the remote:
|
| 51 |
+
|
| 52 |
+
```powershell
|
| 53 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 54 |
+
|
| 55 |
+
# Set your token
|
| 56 |
+
$env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE"
|
| 57 |
+
|
| 58 |
+
# Add remote if not exists
|
| 59 |
+
git remote add hf https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image
|
| 60 |
+
|
| 61 |
+
# Force push
|
| 62 |
+
git push hf main --force
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
⚠️ **Warning**: Force push will overwrite any changes on the remote repository.
|
| 66 |
+
|
| 67 |
+
## What Caused This Issue?
|
| 68 |
+
|
| 69 |
+
The error occurred because:
|
| 70 |
+
1. The Hugging Face Space repository has commits that aren't in your local repository
|
| 71 |
+
2. Git prevents pushing to avoid losing those remote changes
|
| 72 |
+
3. You need to pull and merge those changes before pushing
|
| 73 |
+
|
| 74 |
+
## Files Modified
|
| 75 |
+
|
| 76 |
+
The deployment scripts have been updated:
|
| 77 |
+
- `deploy-to-huggingface.bat` - Updated with pull/rebase logic
|
| 78 |
+
- `deploy-to-huggingface.ps1` - New PowerShell script with comprehensive error handling
|
| 79 |
+
|
| 80 |
+
## Next Steps
|
| 81 |
+
|
| 82 |
+
1. Set your HF_TOKEN environment variable with your actual token
|
| 83 |
+
2. Run the PowerShell script: `.\deploy-to-huggingface.ps1`
|
| 84 |
+
3. The script will handle the merge automatically
|
| 85 |
+
4. Your changes will be pushed to: https://huggingface.co/spaces/gsstec/sci-image
|
| 86 |
+
|
| 87 |
+
## Troubleshooting
|
| 88 |
+
|
| 89 |
+
### If you get merge conflicts:
|
| 90 |
+
```powershell
|
| 91 |
+
# Accept your local changes
|
| 92 |
+
git checkout --ours .
|
| 93 |
+
git add -A
|
| 94 |
+
git rebase --continue
|
| 95 |
+
|
| 96 |
+
# Or accept remote changes
|
| 97 |
+
git checkout --theirs .
|
| 98 |
+
git add -A
|
| 99 |
+
git rebase --continue
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### If the remote URL is wrong:
|
| 103 |
+
```powershell
|
| 104 |
+
$env:HF_TOKEN = "hf_YOUR_ACTUAL_TOKEN_HERE"
|
| 105 |
+
git remote set-url hf https://$env:HF_TOKEN@huggingface.co/spaces/gsstec/sci-image
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
### To check current remotes:
|
| 109 |
+
```powershell
|
| 110 |
+
git remote -v
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
## Space URL
|
| 114 |
+
Your Hugging Face Space: https://huggingface.co/spaces/gsstec/sci-image
|
| 115 |
+
|
| 116 |
+
## Important Security Note
|
| 117 |
+
Never commit files with actual tokens. Always use environment variables or .env files (which are in .gitignore).
|
HYBRID_DEPLOYMENT_GUIDE.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hybrid Deployment: Gradio UI + FastAPI Endpoints
|
| 2 |
+
|
| 3 |
+
## Solution Overview
|
| 4 |
+
|
| 5 |
+
The Hugging Face Space now runs in **hybrid mode**, providing BOTH:
|
| 6 |
+
1. **Gradio UI** - Interactive web interface for users
|
| 7 |
+
2. **FastAPI Endpoints** - Programmatic API access for integrations and monitoring
|
| 8 |
+
|
| 9 |
+
## Changes Made
|
| 10 |
+
|
| 11 |
+
### 1. Modified `hf_demo.py`
|
| 12 |
+
Added FastAPI app mounting to the Gradio demo:
|
| 13 |
+
|
| 14 |
+
```python
|
| 15 |
+
def start_demo():
|
| 16 |
+
# Mount FastAPI app for API endpoints
|
| 17 |
+
from backend.api.web import app as fastapi_app
|
| 18 |
+
|
| 19 |
+
# Launch demo with API enabled and FastAPI mounted
|
| 20 |
+
demo.queue()
|
| 21 |
+
demo.launch(
|
| 22 |
+
share=False,
|
| 23 |
+
app_kwargs={"app": fastapi_app} # Mount FastAPI app
|
| 24 |
+
)
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### 2. Reverted `Dockerfile`
|
| 28 |
+
Changed back to `--hfdemo` mode (which now includes API endpoints):
|
| 29 |
+
|
| 30 |
+
```dockerfile
|
| 31 |
+
CMD ["python", "src/app.py","--hfdemo"]
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## How It Works
|
| 35 |
+
|
| 36 |
+
Gradio's `app_kwargs` parameter allows mounting a FastAPI application alongside the Gradio interface. This means:
|
| 37 |
+
|
| 38 |
+
- **Root URL** (`/`) → Gradio UI (interactive interface)
|
| 39 |
+
- **API Routes** (`/api/*`) → FastAPI endpoints (programmatic access)
|
| 40 |
+
|
| 41 |
+
## Available Endpoints
|
| 42 |
+
|
| 43 |
+
### User Interface
|
| 44 |
+
- **URL**: `https://gsstec-sci-image.hf.space/`
|
| 45 |
+
- **Type**: Gradio interactive UI
|
| 46 |
+
- **Purpose**: User-friendly image generation interface
|
| 47 |
+
|
| 48 |
+
### API Endpoints
|
| 49 |
+
All FastAPI endpoints are accessible at `/api/*`:
|
| 50 |
+
|
| 51 |
+
1. **GET /api/ping** - Health check for UptimeRobot
|
| 52 |
+
2. **GET /api/health** - Detailed health status
|
| 53 |
+
3. **GET /api/info** - System information
|
| 54 |
+
4. **GET /api/config** - Current configuration
|
| 55 |
+
5. **GET /api/models** - Available models
|
| 56 |
+
6. **POST /api/generate** - General image generation
|
| 57 |
+
7. **POST /api/window7/generate-pathogen** - Pathogen visualization
|
| 58 |
+
8. **POST /api/window9/generate-molecule** - Molecular visualization
|
| 59 |
+
9. **GET /api/docs** - Interactive API documentation (Swagger UI)
|
| 60 |
+
10. **GET /api/redoc** - ReDoc documentation
|
| 61 |
+
|
| 62 |
+
## UptimeRobot Configuration
|
| 63 |
+
|
| 64 |
+
**Monitor Type**: HTTP(s)
|
| 65 |
+
**URL**: `https://gsstec-sci-image.hf.space/api/ping`
|
| 66 |
+
**Method**: GET
|
| 67 |
+
**Interval**: 5 minutes
|
| 68 |
+
**Expected Response**: `200 OK` with `{"status": "ok"}`
|
| 69 |
+
|
| 70 |
+
## Testing
|
| 71 |
+
|
| 72 |
+
### Test the UI
|
| 73 |
+
Visit: `https://gsstec-sci-image.hf.space/`
|
| 74 |
+
|
| 75 |
+
### Test the API
|
| 76 |
+
```bash
|
| 77 |
+
# Ping endpoint
|
| 78 |
+
curl https://gsstec-sci-image.hf.space/api/ping
|
| 79 |
+
|
| 80 |
+
# Health endpoint
|
| 81 |
+
curl https://gsstec-sci-image.hf.space/api/health
|
| 82 |
+
|
| 83 |
+
# API documentation
|
| 84 |
+
# Open in browser: https://gsstec-sci-image.hf.space/api/docs
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
### Run Test Script
|
| 88 |
+
```powershell
|
| 89 |
+
cd sci-image
|
| 90 |
+
powershell -NoProfile -ExecutionPolicy Bypass -File "test-hf-space-endpoint.ps1"
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## Deployment Steps
|
| 94 |
+
|
| 95 |
+
1. **Commit Changes**:
|
| 96 |
+
```bash
|
| 97 |
+
cd sci-image
|
| 98 |
+
git add src/frontend/webui/hf_demo.py Dockerfile
|
| 99 |
+
git commit -m "Add hybrid mode: Gradio UI + FastAPI endpoints"
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
2. **Push to Hugging Face Space**:
|
| 103 |
+
```bash
|
| 104 |
+
git push hf main
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
3. **Wait for Rebuild** (5-10 minutes)
|
| 108 |
+
|
| 109 |
+
4. **Verify**:
|
| 110 |
+
- UI: Visit `https://gsstec-sci-image.hf.space/`
|
| 111 |
+
- API: `curl https://gsstec-sci-image.hf.space/api/ping`
|
| 112 |
+
|
| 113 |
+
## Benefits
|
| 114 |
+
|
| 115 |
+
✓ **User-Friendly**: Gradio UI for interactive use
|
| 116 |
+
✓ **Programmatic Access**: FastAPI endpoints for integrations
|
| 117 |
+
✓ **Monitoring**: `/api/ping` endpoint for UptimeRobot
|
| 118 |
+
✓ **Documentation**: Auto-generated API docs at `/api/docs`
|
| 119 |
+
✓ **Single Deployment**: One Space serves both purposes
|
| 120 |
+
|
| 121 |
+
## Integration Examples
|
| 122 |
+
|
| 123 |
+
### AEGIS Bio-Digital Lab 10 Integration
|
| 124 |
+
|
| 125 |
+
```javascript
|
| 126 |
+
// Window 7: Generate pathogen visualization
|
| 127 |
+
const response = await fetch('https://gsstec-sci-image.hf.space/api/window7/generate-pathogen', {
|
| 128 |
+
method: 'POST',
|
| 129 |
+
headers: { 'Content-Type': 'application/json' },
|
| 130 |
+
body: JSON.stringify({
|
| 131 |
+
prompt: "Microscopic view of Ebola virus, scientific illustration",
|
| 132 |
+
num_inference_steps: 12,
|
| 133 |
+
guidance_scale: 2.0,
|
| 134 |
+
width: 512,
|
| 135 |
+
height: 512
|
| 136 |
+
})
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
const result = await response.json();
|
| 140 |
+
console.log('Generated image:', result.images[0]); // Base64 image
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
## Troubleshooting
|
| 144 |
+
|
| 145 |
+
### Issue: API endpoints return 404
|
| 146 |
+
**Solution**: Ensure the Space has rebuilt after pushing the changes to `hf_demo.py`
|
| 147 |
+
|
| 148 |
+
### Issue: UI not loading
|
| 149 |
+
**Solution**: Check that Gradio is properly launching. View Space logs for errors.
|
| 150 |
+
|
| 151 |
+
### Issue: Both UI and API slow
|
| 152 |
+
**Solution**: This is expected on CPU-only instances. Consider upgrading to GPU Space for faster generation.
|
| 153 |
+
|
| 154 |
+
## Version History
|
| 155 |
+
|
| 156 |
+
- **v1.2.0** (2026-06-05): Hybrid mode implementation
|
| 157 |
+
- Added FastAPI mounting to Gradio demo
|
| 158 |
+
- Provides both UI and API endpoints
|
| 159 |
+
- Reverted to `--hfdemo` mode with enhanced functionality
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 Rupesh Sreeraman
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Fastsdcpu
|
| 3 |
+
emoji: 📉
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
Check out the configuration reference at <https://huggingface.co/docs/hub/spaces-config-reference>
|
THIRD-PARTY-LICENSES
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
stablediffusion.cpp - MIT
|
| 2 |
+
|
| 3 |
+
OpenVINO stablediffusion engine - Apache 2
|
| 4 |
+
|
| 5 |
+
SD Turbo - STABILITY AI NON-COMMERCIAL RESEARCH COMMUNITY LICENSE AGREEMENT
|
| 6 |
+
|
| 7 |
+
MIT License
|
| 8 |
+
|
| 9 |
+
Copyright (c) 2023 leejet
|
| 10 |
+
|
| 11 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 12 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 13 |
+
in the Software without restriction, including without limitation the rights
|
| 14 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 15 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 16 |
+
furnished to do so, subject to the following conditions:
|
| 17 |
+
|
| 18 |
+
The above copyright notice and this permission notice shall be included in all
|
| 19 |
+
copies or substantial portions of the Software.
|
| 20 |
+
|
| 21 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 22 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 23 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 24 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 25 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 26 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 27 |
+
SOFTWARE.
|
| 28 |
+
|
| 29 |
+
ERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 30 |
+
|
| 31 |
+
Definitions.
|
| 32 |
+
|
| 33 |
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
| 34 |
+
|
| 35 |
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
| 36 |
+
|
| 37 |
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
| 38 |
+
|
| 39 |
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
| 40 |
+
|
| 41 |
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
| 42 |
+
|
| 43 |
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
| 44 |
+
|
| 45 |
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
| 46 |
+
|
| 47 |
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
| 50 |
+
|
| 51 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
| 52 |
+
|
| 53 |
+
Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
| 54 |
+
|
| 55 |
+
Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
| 56 |
+
|
| 57 |
+
Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
| 58 |
+
|
| 59 |
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
| 60 |
+
|
| 61 |
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
| 62 |
+
|
| 63 |
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
| 64 |
+
|
| 65 |
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
| 66 |
+
|
| 67 |
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
| 68 |
+
|
| 69 |
+
Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
| 70 |
+
|
| 71 |
+
Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
| 72 |
+
|
| 73 |
+
Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
| 74 |
+
|
| 75 |
+
Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
| 76 |
+
|
| 77 |
+
Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
| 78 |
+
|
| 79 |
+
END OF TERMS AND CONDITIONS
|
| 80 |
+
|
| 81 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 82 |
+
|
| 83 |
+
To apply the Apache License to your work, attach the following
|
| 84 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 85 |
+
replaced with your own identifying information. (Don't include
|
| 86 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 87 |
+
comment syntax for the file format. We also recommend that a
|
| 88 |
+
file or class name and description of purpose be included on the
|
| 89 |
+
same "printed page" as the copyright notice for easier
|
| 90 |
+
identification within third-party archives.
|
| 91 |
+
Copyright [yyyy] [name of copyright owner]
|
| 92 |
+
|
| 93 |
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
| 94 |
+
|
| 95 |
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
| 96 |
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
| 97 |
+
|
| 98 |
+
STABILITY AI NON-COMMERCIAL RESEARCH COMMUNITY LICENSE AGREEMENT
|
| 99 |
+
Dated: November 28, 2023
|
| 100 |
+
|
| 101 |
+
By using or distributing any portion or element of the Models, Software, Software Products or Derivative Works, you agree to be bound by this Agreement.
|
| 102 |
+
|
| 103 |
+
"Agreement" means this Stable Non-Commercial Research Community License Agreement.
|
| 104 |
+
|
| 105 |
+
“AUP” means the Stability AI Acceptable Use Policy available at <https://stability.ai/use-policy>, as may be updated from time to time.
|
| 106 |
+
|
| 107 |
+
"Derivative Work(s)” means (a) any derivative work of the Software Products as recognized by U.S. copyright laws and (b) any modifications to a Model, and any other model created which is based on or derived from the Model or the Model’s output. For clarity, Derivative Works do not include the output of any Model.
|
| 108 |
+
|
| 109 |
+
“Documentation” means any specifications, manuals, documentation, and other written information provided by Stability AI related to the Software.
|
| 110 |
+
|
| 111 |
+
"Licensee" or "you" means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity's behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.
|
| 112 |
+
|
| 113 |
+
“Model(s)" means, collectively, Stability AI’s proprietary models and algorithms, including machine-learning models, trained model weights and other elements of the foregoing, made available under this Agreement.
|
| 114 |
+
|
| 115 |
+
“Non-Commercial Uses” means exercising any of the rights granted herein for the purpose of research or non-commercial purposes. Non-Commercial Uses does not include any production use of the Software Products or any Derivative Works.
|
| 116 |
+
|
| 117 |
+
"Stability AI" or "we" means Stability AI Ltd. and its affiliates.
|
| 118 |
+
|
| 119 |
+
"Software" means Stability AI’s proprietary software made available under this Agreement.
|
| 120 |
+
|
| 121 |
+
“Software Products” means the Models, Software and Documentation, individually or in any combination.
|
| 122 |
+
|
| 123 |
+
1. License Rights and Redistribution.
|
| 124 |
+
|
| 125 |
+
a. Subject to your compliance with this Agreement, the AUP (which is hereby incorporated herein by reference), and the Documentation, Stability AI grants you a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable, royalty free and limited license under Stability AI’s intellectual property or other rights owned or controlled by Stability AI embodied in the Software Products to use, reproduce, distribute, and create Derivative Works of, the Software Products, in each case for Non-Commercial Uses only.
|
| 126 |
+
|
| 127 |
+
b. You may not use the Software Products or Derivative Works to enable third parties to use the Software Products or Derivative Works as part of your hosted service or via your APIs, whether you are adding substantial additional functionality thereto or not. Merely distributing the Software Products or Derivative Works for download online without offering any related service (ex. by distributing the Models on HuggingFace) is not a violation of this subsection. If you wish to use the Software Products or any Derivative Works for commercial or production use or you wish to make the Software Products or any Derivative Works available to third parties via your hosted service or your APIs, contact Stability AI at <https://stability.ai/contact>.
|
| 128 |
+
|
| 129 |
+
c. If you distribute or make the Software Products, or any Derivative Works thereof, available to a third party, the Software Products, Derivative Works, or any portion thereof, respectively, will remain subject to this Agreement and you must (i) provide a copy of this Agreement to such third party, and (ii) retain the following attribution notice within a "Notice" text file distributed as a part of such copies: "This Stability AI Model is licensed under the Stability AI Non-Commercial Research Community License, Copyright (c) Stability AI Ltd. All Rights Reserved.” If you create a Derivative Work of a Software Product, you may add your own attribution notices to the Notice file included with the Software Product, provided that you clearly indicate which attributions apply to the Software Product and you must state in the NOTICE file that you changed the Software Product and how it was modified.
|
| 130 |
+
|
| 131 |
+
2. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE SOFTWARE PRODUCTS AND ANY OUTPUT AND RESULTS THERE FROM ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE SOFTWARE PRODUCTS, DERIVATIVE WORKS OR ANY OUTPUT OR RESULTS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE SOFTWARE PRODUCTS, DERIVATIVE WORKS AND ANY OUTPUT AND RESULTS.
|
| 132 |
+
|
| 133 |
+
3. Limitation of Liability. IN NO EVENT WILL STABILITY AI OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF STABILITY AI OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
| 134 |
+
|
| 135 |
+
4. Intellectual Property.
|
| 136 |
+
|
| 137 |
+
a. No trademark licenses are granted under this Agreement, and in connection with the Software Products or Derivative Works, neither Stability AI nor Licensee may use any name or mark owned by or associated with the other or any of its affiliates, except as required for reasonable and customary use in describing and redistributing the Software Products or Derivative Works.
|
| 138 |
+
|
| 139 |
+
b. Subject to Stability AI’s ownership of the Software Products and Derivative Works made by or for Stability AI, with respect to any Derivative Works that are made by you, as between you and Stability AI, you are and will be the owner of such Derivative Works
|
| 140 |
+
|
| 141 |
+
c. If you institute litigation or other proceedings against Stability AI (including a cross-claim or counterclaim in a lawsuit) alleging that the Software Products, Derivative Works or associated outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Stability AI from and against any claim by any third party arising out of or related to your use or distribution of the Software Products or Derivative Works in violation of this Agreement.
|
| 142 |
+
|
| 143 |
+
5. Term and Termination. The term of this Agreement will commence upon your acceptance of this Agreement or access to the Software Products and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Stability AI may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of any Software Products or Derivative Works. Sections 2-4 shall survive the termination of this Agreement.
|
benchmark-openvino.bat
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
setlocal
|
| 3 |
+
|
| 4 |
+
set "PYTHON_COMMAND=python"
|
| 5 |
+
|
| 6 |
+
call python --version > nul 2>&1
|
| 7 |
+
if %errorlevel% equ 0 (
|
| 8 |
+
echo Python command check :OK
|
| 9 |
+
) else (
|
| 10 |
+
echo "Error: Python command not found, please install Python (Recommended : Python 3.10 or Python 3.11) and try again"
|
| 11 |
+
pause
|
| 12 |
+
exit /b 1
|
| 13 |
+
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
:check_python_version
|
| 17 |
+
for /f "tokens=2" %%I in ('%PYTHON_COMMAND% --version 2^>^&1') do (
|
| 18 |
+
set "python_version=%%I"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
echo Python version: %python_version%
|
| 22 |
+
|
| 23 |
+
call "%~dp0env\Scripts\activate.bat" && %PYTHON_COMMAND% src/app.py -b --use_openvino --openvino_lcm_model_id "rupeshs/sd-turbo-openvino"
|
benchmark.bat
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
setlocal
|
| 3 |
+
|
| 4 |
+
set "PYTHON_COMMAND=python"
|
| 5 |
+
|
| 6 |
+
call python --version > nul 2>&1
|
| 7 |
+
if %errorlevel% equ 0 (
|
| 8 |
+
echo Python command check :OK
|
| 9 |
+
) else (
|
| 10 |
+
echo "Error: Python command not found, please install Python (Recommended : Python 3.10 or Python 3.11) and try again"
|
| 11 |
+
pause
|
| 12 |
+
exit /b 1
|
| 13 |
+
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
:check_python_version
|
| 17 |
+
for /f "tokens=2" %%I in ('%PYTHON_COMMAND% --version 2^>^&1') do (
|
| 18 |
+
set "python_version=%%I"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
echo Python version: %python_version%
|
| 22 |
+
|
| 23 |
+
call "%~dp0env\Scripts\activate.bat" && %PYTHON_COMMAND% src/app.py -b
|
configs/lcm-lora-models.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
latent-consistency/lcm-lora-sdv1-5
|
| 2 |
+
latent-consistency/lcm-lora-sdxl
|
| 3 |
+
latent-consistency/lcm-lora-ssd-1b
|
| 4 |
+
rupeshs/hypersd-sd1-5-1-step-lora
|
configs/lcm-models.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
stabilityai/sd-turbo
|
| 2 |
+
rupeshs/sdxs-512-0.9-orig-vae
|
| 3 |
+
rupeshs/hyper-sd-sdxl-1-step
|
| 4 |
+
rupeshs/SDXL-Lightning-2steps
|
| 5 |
+
stabilityai/sdxl-turbo
|
| 6 |
+
SimianLuo/LCM_Dreamshaper_v7
|
configs/openvino-lcm-models.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
rupeshs/sd-turbo-openvino
|
| 2 |
+
rupeshs/sdxs-512-0.9-openvino
|
| 3 |
+
rupeshs/hyper-sd-sdxl-1-step-openvino-int8
|
| 4 |
+
rupeshs/SDXL-Lightning-2steps-openvino-int8
|
| 5 |
+
rupeshs/sdxl-turbo-openvino-int8
|
| 6 |
+
rupeshs/LCM-dreamshaper-v7-openvino
|
| 7 |
+
Disty0/LCM_SoteMix
|
| 8 |
+
rupeshs/sd15-lcm-square-openvino-int8
|
| 9 |
+
OpenVINO/FLUX.1-schnell-int4-ov
|
| 10 |
+
rupeshs/sana-sprint-0.6b-openvino-int4
|
configs/stable-diffusion-models.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Lykon/dreamshaper-8
|
| 2 |
+
Fictiverse/Stable_Diffusion_PaperCut_Model
|
| 3 |
+
stabilityai/stable-diffusion-xl-base-1.0
|
| 4 |
+
runwayml/stable-diffusion-v1-5
|
| 5 |
+
segmind/SSD-1B
|
| 6 |
+
stablediffusionapi/anything-v5
|
| 7 |
+
prompthero/openjourney-v4
|
controlnet_models/Readme.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Place your ControlNet models in this folder.
|
| 2 |
+
You can download controlnet model (.safetensors) from https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/tree/main
|
| 3 |
+
E.g: https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/blob/main/control_v11p_sd15_canny_fp16.safetensors
|
deploy-to-huggingface.bat
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
echo ========================================
|
| 3 |
+
echo Deploying to Hugging Face Space
|
| 4 |
+
echo ========================================
|
| 5 |
+
echo.
|
| 6 |
+
|
| 7 |
+
cd /d "%~dp0"
|
| 8 |
+
|
| 9 |
+
echo Checking git status...
|
| 10 |
+
git status
|
| 11 |
+
echo.
|
| 12 |
+
|
| 13 |
+
echo Adding all changes...
|
| 14 |
+
git add -A
|
| 15 |
+
echo.
|
| 16 |
+
|
| 17 |
+
echo Committing changes...
|
| 18 |
+
git commit -m "Update sci-image deployment" || echo No changes to commit
|
| 19 |
+
echo.
|
| 20 |
+
|
| 21 |
+
echo Setting up Hugging Face remote with authentication...
|
| 22 |
+
git remote remove hf >nul 2>&1
|
| 23 |
+
echo Adding HF remote with token...
|
| 24 |
+
echo Please set HF_TOKEN environment variable or the script will prompt for it
|
| 25 |
+
if not defined HF_TOKEN (
|
| 26 |
+
set /p HF_TOKEN="Enter your Hugging Face token: "
|
| 27 |
+
)
|
| 28 |
+
git remote add hf https://%HF_TOKEN%@huggingface.co/spaces/gsstec/sci-image
|
| 29 |
+
echo.
|
| 30 |
+
|
| 31 |
+
echo Pulling latest changes from Hugging Face...
|
| 32 |
+
git pull hf main --rebase --allow-unrelated-histories
|
| 33 |
+
echo.
|
| 34 |
+
|
| 35 |
+
echo Pushing to Hugging Face...
|
| 36 |
+
echo Space URL: https://huggingface.co/spaces/gsstec/sci-image
|
| 37 |
+
echo.
|
| 38 |
+
|
| 39 |
+
git push hf main
|
| 40 |
+
echo.
|
| 41 |
+
|
| 42 |
+
if errorlevel 1 (
|
| 43 |
+
echo.
|
| 44 |
+
echo ========================================
|
| 45 |
+
echo Push failed! Trying with authentication...
|
| 46 |
+
echo ========================================
|
| 47 |
+
echo.
|
| 48 |
+
echo Please run manually with your token:
|
| 49 |
+
echo git push https://YOUR_HF_TOKEN@huggingface.co/spaces/gsstec/sci-image main
|
| 50 |
+
echo.
|
| 51 |
+
) else (
|
| 52 |
+
echo.
|
| 53 |
+
echo ========================================
|
| 54 |
+
echo Deployment successful!
|
| 55 |
+
echo ========================================
|
| 56 |
+
echo.
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
pause
|
| 60 |
+
|
| 61 |
+
@REM Made with Bob
|
deploy-to-huggingface.ps1
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Deployment Script
|
| 2 |
+
# This script handles the complete deployment process with proper error handling
|
| 3 |
+
|
| 4 |
+
Write-Host "========================================" -ForegroundColor Cyan
|
| 5 |
+
Write-Host "Deploying to Hugging Face Space" -ForegroundColor Cyan
|
| 6 |
+
Write-Host "========================================" -ForegroundColor Cyan
|
| 7 |
+
Write-Host ""
|
| 8 |
+
|
| 9 |
+
# Change to script directory
|
| 10 |
+
Set-Location $PSScriptRoot
|
| 11 |
+
|
| 12 |
+
# Configuration
|
| 13 |
+
$HF_SPACE_URL = "https://huggingface.co/spaces/gsstec/sci-image"
|
| 14 |
+
|
| 15 |
+
# Get token from environment variable or prompt user
|
| 16 |
+
if (-not $env:HF_TOKEN) {
|
| 17 |
+
Write-Host "HF_TOKEN environment variable not set" -ForegroundColor Yellow
|
| 18 |
+
$HF_TOKEN = Read-Host "Enter your Hugging Face token"
|
| 19 |
+
} else {
|
| 20 |
+
$HF_TOKEN = $env:HF_TOKEN
|
| 21 |
+
Write-Host "Using HF_TOKEN from environment variable" -ForegroundColor Green
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
$HF_REMOTE_URL = "https://${HF_TOKEN}@huggingface.co/spaces/gsstec/sci-image"
|
| 25 |
+
|
| 26 |
+
Write-Host "Checking git status..." -ForegroundColor Yellow
|
| 27 |
+
git status
|
| 28 |
+
Write-Host ""
|
| 29 |
+
|
| 30 |
+
Write-Host "Adding all changes..." -ForegroundColor Yellow
|
| 31 |
+
git add -A
|
| 32 |
+
Write-Host ""
|
| 33 |
+
|
| 34 |
+
Write-Host "Committing changes..." -ForegroundColor Yellow
|
| 35 |
+
$commitResult = git commit -m "Update sci-image deployment" 2>&1
|
| 36 |
+
if ($LASTEXITCODE -ne 0) {
|
| 37 |
+
Write-Host "No changes to commit or commit failed" -ForegroundColor Gray
|
| 38 |
+
}
|
| 39 |
+
Write-Host ""
|
| 40 |
+
|
| 41 |
+
Write-Host "Setting up Hugging Face remote..." -ForegroundColor Yellow
|
| 42 |
+
$remoteExists = git remote get-url hf 2>&1
|
| 43 |
+
if ($LASTEXITCODE -ne 0) {
|
| 44 |
+
Write-Host "Adding HF remote..." -ForegroundColor Green
|
| 45 |
+
git remote add hf $HF_REMOTE_URL
|
| 46 |
+
} else {
|
| 47 |
+
Write-Host "Updating HF remote URL..." -ForegroundColor Green
|
| 48 |
+
git remote set-url hf $HF_REMOTE_URL
|
| 49 |
+
}
|
| 50 |
+
Write-Host ""
|
| 51 |
+
|
| 52 |
+
Write-Host "Fetching latest changes from Hugging Face..." -ForegroundColor Yellow
|
| 53 |
+
git fetch hf main
|
| 54 |
+
Write-Host ""
|
| 55 |
+
|
| 56 |
+
Write-Host "Pulling and rebasing with remote changes..." -ForegroundColor Yellow
|
| 57 |
+
$pullResult = git pull hf main --rebase --allow-unrelated-histories 2>&1
|
| 58 |
+
if ($LASTEXITCODE -ne 0) {
|
| 59 |
+
Write-Host "Pull failed or conflicts detected. Attempting to resolve..." -ForegroundColor Red
|
| 60 |
+
Write-Host ""
|
| 61 |
+
Write-Host "Trying alternative merge strategy..." -ForegroundColor Yellow
|
| 62 |
+
git rebase --abort 2>&1 | Out-Null
|
| 63 |
+
git pull hf main --no-rebase --allow-unrelated-histories -X theirs
|
| 64 |
+
}
|
| 65 |
+
Write-Host ""
|
| 66 |
+
|
| 67 |
+
Write-Host "Pushing to Hugging Face..." -ForegroundColor Yellow
|
| 68 |
+
Write-Host "Space URL: $HF_SPACE_URL" -ForegroundColor Cyan
|
| 69 |
+
Write-Host ""
|
| 70 |
+
|
| 71 |
+
$pushResult = git push hf main --force-with-lease 2>&1
|
| 72 |
+
if ($LASTEXITCODE -eq 0) {
|
| 73 |
+
Write-Host ""
|
| 74 |
+
Write-Host "========================================" -ForegroundColor Green
|
| 75 |
+
Write-Host "Deployment successful!" -ForegroundColor Green
|
| 76 |
+
Write-Host "========================================" -ForegroundColor Green
|
| 77 |
+
Write-Host ""
|
| 78 |
+
Write-Host "Your space is available at:" -ForegroundColor Cyan
|
| 79 |
+
Write-Host $HF_SPACE_URL -ForegroundColor White
|
| 80 |
+
} else {
|
| 81 |
+
Write-Host ""
|
| 82 |
+
Write-Host "========================================" -ForegroundColor Red
|
| 83 |
+
Write-Host "Push failed! Trying force push..." -ForegroundColor Red
|
| 84 |
+
Write-Host "========================================" -ForegroundColor Red
|
| 85 |
+
Write-Host ""
|
| 86 |
+
|
| 87 |
+
$forcePushResult = git push hf main --force 2>&1
|
| 88 |
+
if ($LASTEXITCODE -eq 0) {
|
| 89 |
+
Write-Host ""
|
| 90 |
+
Write-Host "Force push successful!" -ForegroundColor Green
|
| 91 |
+
Write-Host "Your space is available at:" -ForegroundColor Cyan
|
| 92 |
+
Write-Host $HF_SPACE_URL -ForegroundColor White
|
| 93 |
+
} else {
|
| 94 |
+
Write-Host ""
|
| 95 |
+
Write-Host "All push attempts failed. Manual intervention required." -ForegroundColor Red
|
| 96 |
+
Write-Host ""
|
| 97 |
+
Write-Host "Try running manually:" -ForegroundColor Yellow
|
| 98 |
+
Write-Host "git push $HF_REMOTE_URL main --force" -ForegroundColor White
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
Write-Host ""
|
| 103 |
+
Write-Host "Press any key to continue..."
|
| 104 |
+
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
| 105 |
+
|
| 106 |
+
# Made with Bob
|
install-mac.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
echo Starting FastSD CPU env installation...
|
| 3 |
+
set -e
|
| 4 |
+
PYTHON_COMMAND="python3"
|
| 5 |
+
|
| 6 |
+
if ! command -v python3 &>/dev/null; then
|
| 7 |
+
if ! command -v python &>/dev/null; then
|
| 8 |
+
echo "Error: Python not found, please install python 3.8 or higher and try again"
|
| 9 |
+
exit 1
|
| 10 |
+
fi
|
| 11 |
+
fi
|
| 12 |
+
|
| 13 |
+
if command -v python &>/dev/null; then
|
| 14 |
+
PYTHON_COMMAND="python"
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
echo "Found $PYTHON_COMMAND command"
|
| 18 |
+
|
| 19 |
+
python_version=$($PYTHON_COMMAND --version 2>&1 | awk '{print $2}')
|
| 20 |
+
echo "Python version : $python_version"
|
| 21 |
+
|
| 22 |
+
if ! command -v uv &>/dev/null; then
|
| 23 |
+
echo "Error: uv command not found,please install https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1 and try again."
|
| 24 |
+
exit 1
|
| 25 |
+
fi
|
| 26 |
+
|
| 27 |
+
BASEDIR=$(pwd)
|
| 28 |
+
|
| 29 |
+
uv venv --python 3.11.6 "$BASEDIR/env"
|
| 30 |
+
# shellcheck disable=SC1091
|
| 31 |
+
source "$BASEDIR/env/bin/activate"
|
| 32 |
+
uv pip install torch==2.8.0
|
| 33 |
+
uv pip install -r "$BASEDIR/requirements.txt"
|
| 34 |
+
chmod +x "start.sh"
|
| 35 |
+
chmod +x "start-webui.sh"
|
| 36 |
+
read -n1 -r -p "FastSD CPU installation completed,press any key to continue..." key
|
install.bat
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
@echo off
|
| 3 |
+
setlocal
|
| 4 |
+
echo Starting FastSD CPU env installation...
|
| 5 |
+
|
| 6 |
+
set "PYTHON_COMMAND=python"
|
| 7 |
+
|
| 8 |
+
call python --version > nul 2>&1
|
| 9 |
+
if %errorlevel% equ 0 (
|
| 10 |
+
echo Python command check :OK
|
| 11 |
+
) else (
|
| 12 |
+
echo "Error: Python command not found,please install Python(Recommended : Python 3.10 or Python 3.11) and try again."
|
| 13 |
+
pause
|
| 14 |
+
exit /b 1
|
| 15 |
+
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
call uv --version > nul 2>&1
|
| 19 |
+
if %errorlevel% equ 0 (
|
| 20 |
+
echo uv command check :OK
|
| 21 |
+
) else (
|
| 22 |
+
echo "Error: uv command not found,please install https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2 and try again."
|
| 23 |
+
pause
|
| 24 |
+
exit /b 1
|
| 25 |
+
|
| 26 |
+
)
|
| 27 |
+
:check_python_version
|
| 28 |
+
for /f "tokens=2" %%I in ('%PYTHON_COMMAND% --version 2^>^&1') do (
|
| 29 |
+
set "python_version=%%I"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
echo Python version: %python_version%
|
| 33 |
+
|
| 34 |
+
uv venv --python 3.11.6 "%~dp0env"
|
| 35 |
+
call "%~dp0env\Scripts\activate.bat" && uv pip install torch==2.8.0 --index-url https://download.pytorch.org/whl/cpu
|
| 36 |
+
call "%~dp0env\Scripts\activate.bat" && uv pip install -r "%~dp0requirements.txt"
|
| 37 |
+
echo FastSD CPU env installation completed.
|
| 38 |
+
pause
|
install.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
echo Starting FastSD CPU env installation...
|
| 3 |
+
set -e
|
| 4 |
+
PYTHON_COMMAND="python3"
|
| 5 |
+
|
| 6 |
+
if ! command -v python3 &>/dev/null; then
|
| 7 |
+
if ! command -v python &>/dev/null; then
|
| 8 |
+
echo "Error: Python not found, please install python 3.8 or higher and try again"
|
| 9 |
+
exit 1
|
| 10 |
+
fi
|
| 11 |
+
fi
|
| 12 |
+
|
| 13 |
+
if command -v python &>/dev/null; then
|
| 14 |
+
PYTHON_COMMAND="python"
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
echo "Found $PYTHON_COMMAND command"
|
| 18 |
+
|
| 19 |
+
python_version=$($PYTHON_COMMAND --version 2>&1 | awk '{print $2}')
|
| 20 |
+
echo "Python version : $python_version"
|
| 21 |
+
|
| 22 |
+
if ! command -v uv &>/dev/null; then
|
| 23 |
+
echo "Error: uv command not found,please install https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1 and try again."
|
| 24 |
+
exit 1
|
| 25 |
+
fi
|
| 26 |
+
|
| 27 |
+
BASEDIR=$(pwd)
|
| 28 |
+
|
| 29 |
+
uv venv --python 3.11.6 "$BASEDIR/env"
|
| 30 |
+
# shellcheck disable=SC1091
|
| 31 |
+
source "$BASEDIR/env/bin/activate"
|
| 32 |
+
uv pip install torch==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cpu
|
| 33 |
+
if [[ "$1" == "--disable-gui" ]]; then
|
| 34 |
+
#! For termux , we don't need Qt based GUI
|
| 35 |
+
packages="$(grep -v "^ *#\|^PyQt5" requirements.txt | grep .)"
|
| 36 |
+
# shellcheck disable=SC2086
|
| 37 |
+
uv pip install $packages
|
| 38 |
+
else
|
| 39 |
+
uv pip install -r "$BASEDIR/requirements.txt"
|
| 40 |
+
fi
|
| 41 |
+
|
| 42 |
+
chmod +x "start.sh"
|
| 43 |
+
chmod +x "start-webui.sh"
|
| 44 |
+
read -n1 -r -p "FastSD CPU installation completed,press any key to continue..." key
|
lora_models/Readme.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Place your lora models in this folder.
|
| 2 |
+
You can download lora model (.safetensors/Safetensor) from Civitai (https://civitai.com/) or Hugging Face(https://huggingface.co/)
|
| 3 |
+
E.g: https://civitai.com/models/207984/cutecartoonredmond-15v-cute-cartoon-lora-for-liberteredmond-sd-15?modelVersionId=234192
|
models/gguf/clip/readme.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Place CLIP model files here"
|
models/gguf/diffusion/readme.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Place your diffusion gguf model files here
|
models/gguf/t5xxl/readme.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Place T5-XXL model files here
|
models/gguf/vae/readme.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Place VAE model files here
|
requirements.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accelerate==1.6.0
|
| 2 |
+
diffusers==0.33.0
|
| 3 |
+
transformers==4.48.0
|
| 4 |
+
PyQt5
|
| 5 |
+
Pillow==9.4.0
|
| 6 |
+
openvino==2025.1.0
|
| 7 |
+
optimum-intel==1.23.0
|
| 8 |
+
onnx==1.16.0
|
| 9 |
+
numpy==1.26.4
|
| 10 |
+
onnxruntime==1.17.3
|
| 11 |
+
pydantic
|
| 12 |
+
typing-extensions==4.10.0
|
| 13 |
+
pyyaml==6.0.1
|
| 14 |
+
gradio==5.6.0
|
| 15 |
+
peft==0.6.1
|
| 16 |
+
opencv-python==4.8.1.78
|
| 17 |
+
omegaconf==2.3.0
|
| 18 |
+
controlnet-aux==0.0.7
|
| 19 |
+
mediapipe==0.10.18
|
| 20 |
+
tomesd==0.1.3
|
| 21 |
+
mcp==1.6.0
|
| 22 |
+
fastapi-mcp==0.3.0
|
| 23 |
+
hf_xet
|
sci-image/.gitignore
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
env
|
| 2 |
+
env_old
|
| 3 |
+
*.bak
|
| 4 |
+
*.pyc
|
| 5 |
+
__pycache__
|
| 6 |
+
results
|
| 7 |
+
# excluding user settings for the GUI frontend
|
| 8 |
+
configs/settings.yaml
|
sci-image/AEGIS_BIO_DIGITAL_LAB10_INTEGRATION.md
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AEGIS Bio-Digital Lab 10 - Visual System Integration
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
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:
|
| 5 |
+
- **Window 7**: Disease Analysis (viruses, bacteria, pathogens)
|
| 6 |
+
- **Window 9**: Drug Development (molecular structures, drug compounds)
|
| 7 |
+
|
| 8 |
+
## System Information
|
| 9 |
+
- **Service Name**: AEGIS Bio-Digital Lab 10 - Visual System
|
| 10 |
+
- **Base Technology**: FastSD CPU (Fast Stable Diffusion on CPU)
|
| 11 |
+
- **Primary Use Cases**:
|
| 12 |
+
- Pathogen visualization (viruses, bacteria)
|
| 13 |
+
- Molecular structure generation
|
| 14 |
+
- Scientific illustration
|
| 15 |
+
- **Integration Points**: Window 7 disease discovery, Window 9 drug development completion
|
| 16 |
+
|
| 17 |
+
## API Endpoints
|
| 18 |
+
|
| 19 |
+
### Health & Monitoring
|
| 20 |
+
|
| 21 |
+
#### 1. Ping Endpoint (UptimeRobot)
|
| 22 |
+
```
|
| 23 |
+
GET /api/ping
|
| 24 |
+
```
|
| 25 |
+
**Purpose**: Health check for UptimeRobot monitoring
|
| 26 |
+
**Response**:
|
| 27 |
+
```json
|
| 28 |
+
{
|
| 29 |
+
"status": "ok",
|
| 30 |
+
"service": "AEGIS Bio-Digital Lab 10 - Visual System",
|
| 31 |
+
"version": "1.0.0",
|
| 32 |
+
"device": "cpu"
|
| 33 |
+
}
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
#### 2. Detailed Health Check
|
| 37 |
+
```
|
| 38 |
+
GET /api/health
|
| 39 |
+
```
|
| 40 |
+
**Purpose**: Comprehensive system health status
|
| 41 |
+
**Response**:
|
| 42 |
+
```json
|
| 43 |
+
{
|
| 44 |
+
"status": "healthy",
|
| 45 |
+
"service": "AEGIS Bio-Digital Lab 10 - Visual System",
|
| 46 |
+
"version": "1.0.0",
|
| 47 |
+
"device": "cpu",
|
| 48 |
+
"device_name": "Intel Core i7",
|
| 49 |
+
"platform": "Linux"
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
#### 3. System Information
|
| 54 |
+
```
|
| 55 |
+
GET /api/info
|
| 56 |
+
```
|
| 57 |
+
**Purpose**: Get detailed system information
|
| 58 |
+
|
| 59 |
+
### Window 7: Disease Analysis Endpoints
|
| 60 |
+
|
| 61 |
+
#### 4. Generate Pathogen Visualization
|
| 62 |
+
```
|
| 63 |
+
POST /api/window7/generate-pathogen
|
| 64 |
+
```
|
| 65 |
+
**Purpose**: Generate virus and bacteria visualizations for disease discovery
|
| 66 |
+
**Use Case**: When a disease is discovered in Window 7, generate visual representation of the pathogen
|
| 67 |
+
|
| 68 |
+
**Example Prompts**:
|
| 69 |
+
- "Microscopic view of [virus name] virus, scientific illustration, high detail"
|
| 70 |
+
- "3D structure of [bacteria name] bacteria, medical visualization"
|
| 71 |
+
- "Electron microscope image of [pathogen], scientific accuracy"
|
| 72 |
+
- "Viral structure of COVID-19, detailed scientific diagram"
|
| 73 |
+
- "Bacterial cell structure of E. coli, cross-section view"
|
| 74 |
+
|
| 75 |
+
**Request Body**:
|
| 76 |
+
```json
|
| 77 |
+
{
|
| 78 |
+
"prompt": "Microscopic view of Ebola virus, scientific illustration, high detail, medical accuracy",
|
| 79 |
+
"negative_prompt": "blurry, low quality, artistic, cartoon",
|
| 80 |
+
"num_inference_steps": 12,
|
| 81 |
+
"guidance_scale": 2.0,
|
| 82 |
+
"width": 512,
|
| 83 |
+
"height": 512,
|
| 84 |
+
"seed": -1,
|
| 85 |
+
"diffusion_task": "text_to_image"
|
| 86 |
+
}
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
#### 5. Generate Disease Visualization
|
| 90 |
+
```
|
| 91 |
+
POST /api/window7/generate-disease-visualization
|
| 92 |
+
```
|
| 93 |
+
**Purpose**: Generate disease progression and infection visualizations
|
| 94 |
+
**Use Case**: Visualize disease symptoms, affected areas, and progression
|
| 95 |
+
|
| 96 |
+
**Example Prompts**:
|
| 97 |
+
- "Medical illustration of [disease] infection in human body"
|
| 98 |
+
- "Disease progression diagram of [condition], scientific style"
|
| 99 |
+
- "Affected organs in [disease], medical visualization"
|
| 100 |
+
- "Cellular damage from [pathogen] infection, microscopic view"
|
| 101 |
+
|
| 102 |
+
### Window 9: Drug Development Endpoints
|
| 103 |
+
|
| 104 |
+
#### 6. Generate Molecule Visualization
|
| 105 |
+
```
|
| 106 |
+
POST /api/window9/generate-molecule
|
| 107 |
+
```
|
| 108 |
+
**Purpose**: Generate molecular structure visualizations
|
| 109 |
+
**Use Case**: After SMILES processing, generate visual representations of molecular structures
|
| 110 |
+
|
| 111 |
+
**Example Prompts**:
|
| 112 |
+
- "3D molecular structure of aspirin, scientific visualization"
|
| 113 |
+
- "Chemical structure diagram of [SMILES notation], high detail"
|
| 114 |
+
- "Molecular bonds and atoms of [drug name], scientific illustration"
|
| 115 |
+
- "Protein-ligand complex, molecular docking visualization"
|
| 116 |
+
|
| 117 |
+
#### 7. Generate Drug Visualization
|
| 118 |
+
```
|
| 119 |
+
POST /api/window9/generate-drug-visualization
|
| 120 |
+
```
|
| 121 |
+
**Purpose**: Generate drug compound visualizations
|
| 122 |
+
**Use Case**: Visualize drug candidates and their properties
|
| 123 |
+
|
| 124 |
+
**Example Prompts**:
|
| 125 |
+
- "Drug compound [name] in 3D, pharmaceutical visualization"
|
| 126 |
+
- "Protein-ligand binding visualization for [drug name]"
|
| 127 |
+
- "Drug molecule interaction diagram, scientific style"
|
| 128 |
+
|
| 129 |
+
### General Scientific Visualization
|
| 130 |
+
|
| 131 |
+
#### 8. Generate Scientific Visualization
|
| 132 |
+
```
|
| 133 |
+
POST /api/aegis/generate-scientific
|
| 134 |
+
```
|
| 135 |
+
**Purpose**: General scientific visualization for all AEGIS windows
|
| 136 |
+
**Use Case**: Cross-window scientific imagery generation
|
| 137 |
+
|
| 138 |
+
#### 9. General Image Generation
|
| 139 |
+
```
|
| 140 |
+
POST /api/generate
|
| 141 |
+
```
|
| 142 |
+
**Purpose**: Standard image generation endpoint
|
| 143 |
+
|
| 144 |
+
### Configuration Endpoints
|
| 145 |
+
|
| 146 |
+
#### 10. Get Configuration
|
| 147 |
+
```
|
| 148 |
+
GET /api/config
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
#### 11. Get Available Models
|
| 152 |
+
```
|
| 153 |
+
GET /api/models
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## Integration Workflows
|
| 157 |
+
|
| 158 |
+
### Window 7: Disease Discovery Flow
|
| 159 |
+
|
| 160 |
+
```
|
| 161 |
+
1. Window 7 discovers new disease/pathogen
|
| 162 |
+
↓
|
| 163 |
+
2. Extract pathogen name and characteristics
|
| 164 |
+
↓
|
| 165 |
+
3. Call /api/window7/generate-pathogen with descriptive prompt
|
| 166 |
+
↓
|
| 167 |
+
4. Receive base64-encoded pathogen visualization
|
| 168 |
+
↓
|
| 169 |
+
5. Display in Window 7 UI alongside disease data
|
| 170 |
+
↓
|
| 171 |
+
6. Store in disease_analysis_v2 table
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
### Window 9: Drug Development Flow
|
| 175 |
+
|
| 176 |
+
```
|
| 177 |
+
1. Window 9 completes drug development analysis
|
| 178 |
+
↓
|
| 179 |
+
2. SMILES notation generated for drug compound
|
| 180 |
+
↓
|
| 181 |
+
3. Call /api/window9/generate-molecule with molecular prompt
|
| 182 |
+
↓
|
| 183 |
+
4. Receive base64-encoded molecular structure
|
| 184 |
+
↓
|
| 185 |
+
5. Display in Window 9 UI
|
| 186 |
+
↓
|
| 187 |
+
6. Store in drug_development table
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
## Example Integration Code
|
| 191 |
+
|
| 192 |
+
### Window 7: Pathogen Visualization
|
| 193 |
+
|
| 194 |
+
```javascript
|
| 195 |
+
// After disease discovery in Window 7
|
| 196 |
+
async function generatePathogenVisualization(diseaseData) {
|
| 197 |
+
const response = await fetch('https://sci-image-api.com/api/window7/generate-pathogen', {
|
| 198 |
+
method: 'POST',
|
| 199 |
+
headers: {
|
| 200 |
+
'Content-Type': 'application/json',
|
| 201 |
+
},
|
| 202 |
+
body: JSON.stringify({
|
| 203 |
+
prompt: `Microscopic view of ${diseaseData.pathogen_name} ${diseaseData.pathogen_type}, scientific illustration, high detail, medical accuracy`,
|
| 204 |
+
negative_prompt: 'blurry, low quality, artistic, cartoon, unrealistic',
|
| 205 |
+
num_inference_steps: 12,
|
| 206 |
+
guidance_scale: 2.0,
|
| 207 |
+
width: 512,
|
| 208 |
+
height: 512,
|
| 209 |
+
seed: -1,
|
| 210 |
+
diffusion_task: 'text_to_image'
|
| 211 |
+
})
|
| 212 |
+
});
|
| 213 |
+
|
| 214 |
+
const result = await response.json();
|
| 215 |
+
|
| 216 |
+
// Store in database
|
| 217 |
+
await fetch('/api/window7/disease-analysis', {
|
| 218 |
+
method: 'PATCH',
|
| 219 |
+
body: JSON.stringify({
|
| 220 |
+
id: diseaseData.id,
|
| 221 |
+
pathogen_image: result.images[0],
|
| 222 |
+
image_generation_latency: result.latency
|
| 223 |
+
})
|
| 224 |
+
});
|
| 225 |
+
|
| 226 |
+
return result.images[0]; // Base64 image
|
| 227 |
+
}
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
### Window 9: Molecular Visualization
|
| 231 |
+
|
| 232 |
+
```javascript
|
| 233 |
+
// After drug development completion in Window 9
|
| 234 |
+
async function generateMolecularVisualization(drugData) {
|
| 235 |
+
const response = await fetch('https://sci-image-api.com/api/window9/generate-molecule', {
|
| 236 |
+
method: 'POST',
|
| 237 |
+
headers: {
|
| 238 |
+
'Content-Type': 'application/json',
|
| 239 |
+
},
|
| 240 |
+
body: JSON.stringify({
|
| 241 |
+
prompt: `3D molecular structure of ${drugData.compound_name}, SMILES: ${drugData.smiles}, scientific visualization, high detail`,
|
| 242 |
+
negative_prompt: 'blurry, low quality, distorted, artistic',
|
| 243 |
+
num_inference_steps: 10,
|
| 244 |
+
guidance_scale: 1.8,
|
| 245 |
+
width: 512,
|
| 246 |
+
height: 512,
|
| 247 |
+
seed: -1,
|
| 248 |
+
diffusion_task: 'text_to_image'
|
| 249 |
+
})
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
const result = await response.json();
|
| 253 |
+
return result.images[0]; // Base64 image
|
| 254 |
+
}
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
## Response Format
|
| 258 |
+
|
| 259 |
+
All generation endpoints return:
|
| 260 |
+
```json
|
| 261 |
+
{
|
| 262 |
+
"latency": 2.5,
|
| 263 |
+
"images": ["base64_encoded_image_1", "base64_encoded_image_2"],
|
| 264 |
+
"error": null
|
| 265 |
+
}
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
## Configuration Parameters
|
| 269 |
+
|
| 270 |
+
### LCMDiffusionSetting Parameters
|
| 271 |
+
|
| 272 |
+
| Parameter | Type | Default | Description |
|
| 273 |
+
|-----------|------|---------|-------------|
|
| 274 |
+
| `prompt` | string | required | Text description of desired image |
|
| 275 |
+
| `negative_prompt` | string | "" | What to avoid in generation |
|
| 276 |
+
| `num_inference_steps` | int | 4 | Number of denoising steps (4-50) |
|
| 277 |
+
| `guidance_scale` | float | 1.0 | How closely to follow prompt (1.0-2.0) |
|
| 278 |
+
| `width` | int | 512 | Image width in pixels |
|
| 279 |
+
| `height` | int | 512 | Image height in pixels |
|
| 280 |
+
| `seed` | int | -1 | Random seed (-1 for random) |
|
| 281 |
+
| `diffusion_task` | string | "text_to_image" | "text_to_image" or "image_to_image" |
|
| 282 |
+
| `init_image` | string | null | Base64 image for img2img |
|
| 283 |
+
| `strength` | float | 0.8 | Img2img transformation strength |
|
| 284 |
+
|
| 285 |
+
## Best Practices
|
| 286 |
+
|
| 287 |
+
### For Pathogen Visualizations (Window 7)
|
| 288 |
+
1. **Prompt Structure**: "[Pathogen type] view of [pathogen name], scientific illustration, high detail, medical accuracy"
|
| 289 |
+
2. **Negative Prompts**: Always include "blurry, low quality, artistic, cartoon, unrealistic"
|
| 290 |
+
3. **Steps**: Use 10-15 steps for medical accuracy
|
| 291 |
+
4. **Guidance**: Set to 1.8-2.0 for scientific precision
|
| 292 |
+
5. **Keywords**: Include "microscopic", "electron microscope", "scientific", "medical"
|
| 293 |
+
|
| 294 |
+
**Example Prompts for Common Pathogens**:
|
| 295 |
+
- Viruses: "Electron microscope view of [virus name] virion, detailed capsid structure, scientific accuracy"
|
| 296 |
+
- Bacteria: "Microscopic view of [bacteria name] bacterial cell, flagella visible, scientific illustration"
|
| 297 |
+
- Fungi: "Microscopic structure of [fungus name], spores and hyphae, medical visualization"
|
| 298 |
+
- Parasites: "Detailed view of [parasite name], life cycle stage, scientific diagram"
|
| 299 |
+
|
| 300 |
+
### For Molecular Visualizations (Window 9)
|
| 301 |
+
1. **Include SMILES**: Reference SMILES notation in prompt when available
|
| 302 |
+
2. **Specify Style**: "3D molecular structure", "ball-and-stick model", "space-filling model"
|
| 303 |
+
3. **Scientific Terms**: Use "bonds", "atoms", "molecular geometry"
|
| 304 |
+
4. **Steps**: 8-12 for molecular accuracy
|
| 305 |
+
5. **Guidance**: 1.5-2.0 for precise structures
|
| 306 |
+
|
| 307 |
+
### Performance Optimization
|
| 308 |
+
1. Use lower `num_inference_steps` (4-6) for faster generation during development
|
| 309 |
+
2. Increase steps (10-15) for production/final visualizations
|
| 310 |
+
3. Cache frequently generated pathogen/molecule images
|
| 311 |
+
4. Batch multiple requests when generating variations
|
| 312 |
+
|
| 313 |
+
## Prompt Templates
|
| 314 |
+
|
| 315 |
+
### Window 7 Templates
|
| 316 |
+
|
| 317 |
+
#### Virus Visualization
|
| 318 |
+
```
|
| 319 |
+
"Electron microscope view of {virus_name} virus, detailed viral structure, capsid proteins visible, scientific illustration, high detail, medical accuracy"
|
| 320 |
+
```
|
| 321 |
+
|
| 322 |
+
#### Bacteria Visualization
|
| 323 |
+
```
|
| 324 |
+
"Microscopic view of {bacteria_name} bacteria, cell wall structure, flagella, scientific illustration, gram stain appearance, medical accuracy"
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
#### Disease Progression
|
| 328 |
+
```
|
| 329 |
+
"Medical illustration of {disease_name} infection progression in human {organ/tissue}, cellular level, scientific diagram, pathological changes"
|
| 330 |
+
```
|
| 331 |
+
|
| 332 |
+
### Window 9 Templates
|
| 333 |
+
|
| 334 |
+
#### Molecular Structure
|
| 335 |
+
```
|
| 336 |
+
"3D molecular structure of {compound_name}, SMILES: {smiles_notation}, ball-and-stick model, chemical bonds visible, scientific visualization, high detail"
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
#### Drug-Protein Interaction
|
| 340 |
+
```
|
| 341 |
+
"Protein-ligand binding visualization, {drug_name} docking with {protein_name}, molecular interaction diagram, scientific style, binding site highlighted"
|
| 342 |
+
```
|
| 343 |
+
|
| 344 |
+
## Monitoring
|
| 345 |
+
|
| 346 |
+
### UptimeRobot Configuration
|
| 347 |
+
- **Monitor Type**: HTTP(s)
|
| 348 |
+
- **URL**: `https://your-sci-image-api.com/api/ping`
|
| 349 |
+
- **Interval**: 5 minutes
|
| 350 |
+
- **Expected Response**: `200 OK` with `"status": "ok"`
|
| 351 |
+
|
| 352 |
+
### Health Check Schedule
|
| 353 |
+
- Ping endpoint: Every 5 minutes
|
| 354 |
+
- Health endpoint: Every 15 minutes
|
| 355 |
+
- Full system check: Every hour
|
| 356 |
+
|
| 357 |
+
## Error Handling
|
| 358 |
+
|
| 359 |
+
### Common Errors
|
| 360 |
+
|
| 361 |
+
| Error | Cause | Solution |
|
| 362 |
+
|-------|-------|----------|
|
| 363 |
+
| `latency > 30s` | Complex prompt or high steps | Reduce steps or simplify prompt |
|
| 364 |
+
| `images: []` | Generation failed | Check prompt validity |
|
| 365 |
+
| `error: "Out of memory"` | Image too large | Reduce dimensions |
|
| 366 |
+
| `error: "Model not loaded"` | Model initialization failed | Restart service |
|
| 367 |
+
|
| 368 |
+
## Database Integration
|
| 369 |
+
|
| 370 |
+
### Window 7: Storing Pathogen Images
|
| 371 |
+
|
| 372 |
+
```sql
|
| 373 |
+
-- Add pathogen_image column to disease_analysis_v2
|
| 374 |
+
ALTER TABLE disease_analysis_v2
|
| 375 |
+
ADD COLUMN pathogen_image TEXT,
|
| 376 |
+
ADD COLUMN pathogen_image_prompt TEXT,
|
| 377 |
+
ADD COLUMN image_generation_latency REAL;
|
| 378 |
+
```
|
| 379 |
+
|
| 380 |
+
### Window 9: Storing Molecular Images
|
| 381 |
+
|
| 382 |
+
```sql
|
| 383 |
+
-- Add molecular_image column to drug_development
|
| 384 |
+
ALTER TABLE drug_development
|
| 385 |
+
ADD COLUMN molecular_structure_image TEXT,
|
| 386 |
+
ADD COLUMN molecular_image_prompt TEXT,
|
| 387 |
+
ADD COLUMN image_generation_latency REAL;
|
| 388 |
+
```
|
| 389 |
+
|
| 390 |
+
## Deployment
|
| 391 |
+
|
| 392 |
+
### Environment Variables
|
| 393 |
+
```bash
|
| 394 |
+
DEVICE=cpu
|
| 395 |
+
APP_VERSION=1.0.0
|
| 396 |
+
PORT=8000
|
| 397 |
+
```
|
| 398 |
+
|
| 399 |
+
### Docker Deployment
|
| 400 |
+
```bash
|
| 401 |
+
docker build -t aegis-visual-system .
|
| 402 |
+
docker run -p 8000:8000 aegis-visual-system
|
| 403 |
+
```
|
| 404 |
+
|
| 405 |
+
### Hugging Face Space
|
| 406 |
+
- SDK: Docker
|
| 407 |
+
- App Port: 7860
|
| 408 |
+
- Python Version: 3.12 (see `.python-version`)
|
| 409 |
+
|
| 410 |
+
## Future Enhancements
|
| 411 |
+
|
| 412 |
+
1. **GPU Acceleration**: Add CUDA support for faster generation
|
| 413 |
+
2. **Model Fine-tuning**: Train on medical/scientific imagery datasets
|
| 414 |
+
3. **3D Rendering**: Generate rotatable 3D pathogen/molecule models
|
| 415 |
+
4. **Animation**: Create pathogen lifecycle and molecular interaction animations
|
| 416 |
+
5. **Style Transfer**: Apply scientific paper/textbook style
|
| 417 |
+
6. **Batch Processing**: Generate multiple variations simultaneously
|
| 418 |
+
7. **Real-time Generation**: WebSocket support for live visualization
|
| 419 |
+
|
| 420 |
+
## Version History
|
| 421 |
+
|
| 422 |
+
- **v1.0.0** (2026-05-31): Initial AEGIS Bio-Digital Lab 10 integration
|
| 423 |
+
- Added ping endpoint for UptimeRobot
|
| 424 |
+
- Added Window 7 pathogen visualization endpoints
|
| 425 |
+
- Added Window 9 molecular visualization endpoints
|
| 426 |
+
- Added AEGIS scientific visualization endpoint
|
| 427 |
+
- Added comprehensive health checks
|
| 428 |
+
- Integrated with disease discovery and drug development workflows
|
sci-image/DEPLOY_API_FIX.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HuggingFace Space API Fix - Deployment Guide
|
| 2 |
+
|
| 3 |
+
## Problem Identified
|
| 4 |
+
The original `hf_demo.py` had no API endpoint configured. The `predict` function was only connected to the UI button, making it impossible to call via the Gradio API.
|
| 5 |
+
|
| 6 |
+
## Solution Implemented
|
| 7 |
+
Updated `sci-image/src/frontend/webui/hf_demo.py` with:
|
| 8 |
+
|
| 9 |
+
1. **API-enabled predict function** with proper parameters:
|
| 10 |
+
- `prompt`: Text description
|
| 11 |
+
- `width`: Image width (default: 512)
|
| 12 |
+
- `height`: Image height (default: 512)
|
| 13 |
+
- `num_images`: Number of images (default: 1)
|
| 14 |
+
- `steps`: Inference steps (default: 4)
|
| 15 |
+
- `guidance_scale`: Guidance scale (default: 1.0)
|
| 16 |
+
- `seed`: Random seed, -1 for random (default: -1)
|
| 17 |
+
|
| 18 |
+
2. **Separate UI and API functions**:
|
| 19 |
+
- `ui_predict()`: Handles UI button clicks
|
| 20 |
+
- `predict()`: Handles API calls with full parameters
|
| 21 |
+
|
| 22 |
+
3. **gr.Interface for API**:
|
| 23 |
+
- Created explicit API interface with `api_name="predict"`
|
| 24 |
+
- This enables `/api/predict` endpoint
|
| 25 |
+
|
| 26 |
+
## Deployment Steps
|
| 27 |
+
|
| 28 |
+
### 1. Push to HuggingFace Space
|
| 29 |
+
```bash
|
| 30 |
+
cd C:\Users\Dell\Desktop\TimeTravel-main\sci-image
|
| 31 |
+
|
| 32 |
+
# Add and commit changes
|
| 33 |
+
git add src/frontend/webui/hf_demo.py
|
| 34 |
+
git commit -m "Add API endpoint for external calls"
|
| 35 |
+
|
| 36 |
+
# Push to HuggingFace Space
|
| 37 |
+
git push origin main
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
### 2. Wait for Space to Rebuild
|
| 41 |
+
- Go to: https://huggingface.co/spaces/gsstec/sci-image
|
| 42 |
+
- Wait for the Space to rebuild (usually 2-5 minutes)
|
| 43 |
+
- Check the logs for any errors
|
| 44 |
+
|
| 45 |
+
### 3. Test the API Endpoint
|
| 46 |
+
|
| 47 |
+
#### Test via Gradio API:
|
| 48 |
+
```bash
|
| 49 |
+
# Step 1: Call predict
|
| 50 |
+
curl -X POST https://gsstec-sci-image.hf.space/gradio_api/call/predict \
|
| 51 |
+
-H "Content-Type: application/json" \
|
| 52 |
+
-d '{
|
| 53 |
+
"data": [
|
| 54 |
+
"a virus under microscope, scientific visualization",
|
| 55 |
+
512,
|
| 56 |
+
512,
|
| 57 |
+
1,
|
| 58 |
+
4,
|
| 59 |
+
1.0,
|
| 60 |
+
-1
|
| 61 |
+
]
|
| 62 |
+
}'
|
| 63 |
+
|
| 64 |
+
# Response: {"event_id": "some-id"}
|
| 65 |
+
|
| 66 |
+
# Step 2: Poll for results
|
| 67 |
+
curl https://gsstec-sci-image.hf.space/gradio_api/call/predict/{event_id}
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### 4. Test from Frontend
|
| 71 |
+
Navigate to: `http://localhost:8080/window/9/test`
|
| 72 |
+
|
| 73 |
+
The test page will now:
|
| 74 |
+
1. Call the Space API with proper parameters
|
| 75 |
+
2. Poll for results
|
| 76 |
+
3. Display the generated image
|
| 77 |
+
4. Show detailed logs of the entire process
|
| 78 |
+
|
| 79 |
+
## API Parameters Mapping
|
| 80 |
+
|
| 81 |
+
Our frontend sends:
|
| 82 |
+
```javascript
|
| 83 |
+
{
|
| 84 |
+
data: [
|
| 85 |
+
prompt, // "a virus under microscope..."
|
| 86 |
+
512, // width
|
| 87 |
+
512, // height
|
| 88 |
+
1, // num_images
|
| 89 |
+
4, // num_inference_steps
|
| 90 |
+
1.0, // guidance_scale
|
| 91 |
+
-1 // seed (random)
|
| 92 |
+
]
|
| 93 |
+
}
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
The Space receives these in order as function parameters.
|
| 97 |
+
|
| 98 |
+
## Expected Response Format
|
| 99 |
+
|
| 100 |
+
The Space will return via SSE stream:
|
| 101 |
+
```
|
| 102 |
+
data: [{"url": "https://gsstec-sci-image.hf.space/file=/tmp/gradio/xxx.webp", "path": "/tmp/gradio/xxx.webp"}]
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
Our frontend extracts `data[0].url` and displays the image.
|
| 106 |
+
|
| 107 |
+
## Troubleshooting
|
| 108 |
+
|
| 109 |
+
### If API still returns null:
|
| 110 |
+
1. Check Space logs for errors
|
| 111 |
+
2. Verify the Space rebuilt successfully
|
| 112 |
+
3. Test the UI directly on the Space to ensure generation works
|
| 113 |
+
4. Check if the API endpoint is accessible: `https://gsstec-sci-image.hf.space/api/predict`
|
| 114 |
+
|
| 115 |
+
### If images don't display:
|
| 116 |
+
1. The temporary URLs expire quickly
|
| 117 |
+
2. Consider downloading the image immediately in the Durable Object
|
| 118 |
+
3. Or convert to base64 in the Space before returning
|
| 119 |
+
|
| 120 |
+
## Next Steps After Deployment
|
| 121 |
+
|
| 122 |
+
1. **Test the API**: Use the test page to verify it works
|
| 123 |
+
2. **Update Window 9**: Once confirmed working, update the main Window 9 page
|
| 124 |
+
3. **Add image caching**: Implement immediate download in Durable Object to avoid URL expiration
|
| 125 |
+
4. **Add error handling**: Better error messages for failed generations
|
| 126 |
+
|
| 127 |
+
## Files Modified
|
| 128 |
+
- `sci-image/src/frontend/webui/hf_demo.py` - Added API interface and proper parameter handling
|
sci-image/DEPLOY_API_SERVER.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deploy API Server to Hugging Face Space
|
| 2 |
+
|
| 3 |
+
## Problem
|
| 4 |
+
The current Hugging Face Space deployment is running in `--hfdemo` mode, which provides a Gradio UI but does NOT expose the API endpoints like `/api/ping`, `/api/health`, etc.
|
| 5 |
+
|
| 6 |
+
## Solution
|
| 7 |
+
The Dockerfile has been updated to:
|
| 8 |
+
1. Run in `--api` mode instead of `--hfdemo` mode
|
| 9 |
+
2. Use port 7860 (required by Hugging Face Spaces) instead of the default port 8000
|
| 10 |
+
|
| 11 |
+
## Deployment Steps
|
| 12 |
+
|
| 13 |
+
### 1. Commit and Push Changes
|
| 14 |
+
```bash
|
| 15 |
+
cd sci-image
|
| 16 |
+
git add Dockerfile
|
| 17 |
+
git commit -m "Switch to API server mode for Hugging Face Space"
|
| 18 |
+
git push
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
### 2. Push to Hugging Face Space
|
| 22 |
+
If you have the Hugging Face Space connected as a remote:
|
| 23 |
+
```bash
|
| 24 |
+
git push hf main
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
Or manually upload the updated Dockerfile to your Hugging Face Space at:
|
| 28 |
+
https://huggingface.co/spaces/gsstec/sci-image/tree/main
|
| 29 |
+
|
| 30 |
+
### 3. Wait for Rebuild
|
| 31 |
+
The Hugging Face Space will automatically rebuild with the new Dockerfile. This may take 5-10 minutes.
|
| 32 |
+
|
| 33 |
+
### 4. Verify API Endpoints
|
| 34 |
+
Once deployed, test the endpoints:
|
| 35 |
+
|
| 36 |
+
**Ping Endpoint:**
|
| 37 |
+
```bash
|
| 38 |
+
curl https://gsstec-sci-image.hf.space/api/ping
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
Expected response:
|
| 42 |
+
```json
|
| 43 |
+
{
|
| 44 |
+
"status": "ok",
|
| 45 |
+
"service": "AEGIS Bio-Digital Lab 10 - Visual System",
|
| 46 |
+
"version": "1.0.0",
|
| 47 |
+
"device": "cpu"
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
**Health Endpoint:**
|
| 52 |
+
```bash
|
| 53 |
+
curl https://gsstec-sci-image.hf.space/api/health
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
**System Info:**
|
| 57 |
+
```bash
|
| 58 |
+
curl https://gsstec-sci-image.hf.space/api/info
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Available API Endpoints After Deployment
|
| 62 |
+
|
| 63 |
+
### Health & Monitoring
|
| 64 |
+
- `GET /api/` - Welcome message
|
| 65 |
+
- `GET /api/ping` - Health check for UptimeRobot
|
| 66 |
+
- `GET /api/health` - Detailed health status
|
| 67 |
+
- `GET /api/info` - System information
|
| 68 |
+
- `GET /api/config` - Current configuration
|
| 69 |
+
- `GET /api/models` - Available models
|
| 70 |
+
|
| 71 |
+
### Image Generation
|
| 72 |
+
- `POST /api/generate` - General image generation
|
| 73 |
+
- `POST /api/window7/generate-pathogen` - Pathogen visualization
|
| 74 |
+
- `POST /api/window7/generate-disease-visualization` - Disease visualization
|
| 75 |
+
- `POST /api/window9/generate-molecule` - Molecular structure
|
| 76 |
+
- `POST /api/window9/generate-drug-visualization` - Drug visualization
|
| 77 |
+
- `POST /api/aegis/generate-scientific` - Scientific visualization
|
| 78 |
+
|
| 79 |
+
### API Documentation
|
| 80 |
+
- `/api/docs` - Swagger UI documentation
|
| 81 |
+
- `/api/redoc` - ReDoc documentation
|
| 82 |
+
- `/api/openapi.json` - OpenAPI specification
|
| 83 |
+
|
| 84 |
+
## UptimeRobot Configuration
|
| 85 |
+
|
| 86 |
+
After deployment, configure UptimeRobot:
|
| 87 |
+
- **Monitor Type**: HTTP(s)
|
| 88 |
+
- **URL**: `https://gsstec-sci-image.hf.space/api/ping`
|
| 89 |
+
- **Interval**: 5 minutes
|
| 90 |
+
- **Expected Response**: `200 OK` with `"status": "ok"`
|
| 91 |
+
|
| 92 |
+
## Testing Locally
|
| 93 |
+
|
| 94 |
+
To test the API server locally before deploying:
|
| 95 |
+
```bash
|
| 96 |
+
cd sci-image
|
| 97 |
+
python src/app.py --api
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
Then test:
|
| 101 |
+
```bash
|
| 102 |
+
curl http://localhost:8000/api/ping
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
## Reverting to UI Mode
|
| 106 |
+
|
| 107 |
+
If you need to revert to the Gradio UI:
|
| 108 |
+
```dockerfile
|
| 109 |
+
CMD ["python", "src/app.py","--hfdemo"]
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
## Notes
|
| 113 |
+
|
| 114 |
+
- The API server runs on port 7860 (as configured in Dockerfile EXPOSE)
|
| 115 |
+
- CORS is enabled for all origins
|
| 116 |
+
- The server uses FastAPI with automatic OpenAPI documentation
|
| 117 |
+
- All endpoints are prefixed with `/api/`
|
sci-image/Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ghcr.io/astral-sh/uv:python3.11-trixie-slim
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get install -y \
|
| 4 |
+
git curl build-essential libgl1 libglib2.0-0 \
|
| 5 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
ENV DEVICE=cpu
|
| 8 |
+
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
COPY . .
|
| 11 |
+
|
| 12 |
+
RUN uv pip install --system --no-cache-dir \
|
| 13 |
+
torch==2.8.0 torchvision==0.23.0 \
|
| 14 |
+
--index-url https://download.pytorch.org/whl/cpu
|
| 15 |
+
|
| 16 |
+
RUN uv pip install --system --no-cache-dir -r requirements.txt
|
| 17 |
+
|
| 18 |
+
EXPOSE 7860
|
| 19 |
+
|
| 20 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 21 |
+
|
| 22 |
+
CMD ["python", "src/app.py","--hfdemo"]
|
sci-image/ENDPOINT_SUMMARY.md
ADDED
|
File without changes
|
sci-image/HYBRID_DEPLOYMENT_GUIDE.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hybrid Deployment: Gradio UI + FastAPI Endpoints
|
| 2 |
+
|
| 3 |
+
## Solution Overview
|
| 4 |
+
|
| 5 |
+
The Hugging Face Space now runs in **hybrid mode**, providing BOTH:
|
| 6 |
+
1. **Gradio UI** - Interactive web interface for users
|
| 7 |
+
2. **FastAPI Endpoints** - Programmatic API access for integrations and monitoring
|
| 8 |
+
|
| 9 |
+
## Changes Made
|
| 10 |
+
|
| 11 |
+
### 1. Modified `hf_demo.py`
|
| 12 |
+
Added FastAPI app mounting to the Gradio demo:
|
| 13 |
+
|
| 14 |
+
```python
|
| 15 |
+
def start_demo():
|
| 16 |
+
# Mount FastAPI app for API endpoints
|
| 17 |
+
from backend.api.web import app as fastapi_app
|
| 18 |
+
|
| 19 |
+
# Launch demo with API enabled and FastAPI mounted
|
| 20 |
+
demo.queue()
|
| 21 |
+
demo.launch(
|
| 22 |
+
share=False,
|
| 23 |
+
app_kwargs={"app": fastapi_app} # Mount FastAPI app
|
| 24 |
+
)
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### 2. Reverted `Dockerfile`
|
| 28 |
+
Changed back to `--hfdemo` mode (which now includes API endpoints):
|
| 29 |
+
|
| 30 |
+
```dockerfile
|
| 31 |
+
CMD ["python", "src/app.py","--hfdemo"]
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## How It Works
|
| 35 |
+
|
| 36 |
+
Gradio's `app_kwargs` parameter allows mounting a FastAPI application alongside the Gradio interface. This means:
|
| 37 |
+
|
| 38 |
+
- **Root URL** (`/`) → Gradio UI (interactive interface)
|
| 39 |
+
- **API Routes** (`/api/*`) → FastAPI endpoints (programmatic access)
|
| 40 |
+
|
| 41 |
+
## Available Endpoints
|
| 42 |
+
|
| 43 |
+
### User Interface
|
| 44 |
+
- **URL**: `https://gsstec-sci-image.hf.space/`
|
| 45 |
+
- **Type**: Gradio interactive UI
|
| 46 |
+
- **Purpose**: User-friendly image generation interface
|
| 47 |
+
|
| 48 |
+
### API Endpoints
|
| 49 |
+
All FastAPI endpoints are accessible at `/api/*`:
|
| 50 |
+
|
| 51 |
+
1. **GET /api/ping** - Health check for UptimeRobot
|
| 52 |
+
2. **GET /api/health** - Detailed health status
|
| 53 |
+
3. **GET /api/info** - System information
|
| 54 |
+
4. **GET /api/config** - Current configuration
|
| 55 |
+
5. **GET /api/models** - Available models
|
| 56 |
+
6. **POST /api/generate** - General image generation
|
| 57 |
+
7. **POST /api/window7/generate-pathogen** - Pathogen visualization
|
| 58 |
+
8. **POST /api/window9/generate-molecule** - Molecular visualization
|
| 59 |
+
9. **GET /api/docs** - Interactive API documentation (Swagger UI)
|
| 60 |
+
10. **GET /api/redoc** - ReDoc documentation
|
| 61 |
+
|
| 62 |
+
## UptimeRobot Configuration
|
| 63 |
+
|
| 64 |
+
**Monitor Type**: HTTP(s)
|
| 65 |
+
**URL**: `https://gsstec-sci-image.hf.space/api/ping`
|
| 66 |
+
**Method**: GET
|
| 67 |
+
**Interval**: 5 minutes
|
| 68 |
+
**Expected Response**: `200 OK` with `{"status": "ok"}`
|
| 69 |
+
|
| 70 |
+
## Testing
|
| 71 |
+
|
| 72 |
+
### Test the UI
|
| 73 |
+
Visit: `https://gsstec-sci-image.hf.space/`
|
| 74 |
+
|
| 75 |
+
### Test the API
|
| 76 |
+
```bash
|
| 77 |
+
# Ping endpoint
|
| 78 |
+
curl https://gsstec-sci-image.hf.space/api/ping
|
| 79 |
+
|
| 80 |
+
# Health endpoint
|
| 81 |
+
curl https://gsstec-sci-image.hf.space/api/health
|
| 82 |
+
|
| 83 |
+
# API documentation
|
| 84 |
+
# Open in browser: https://gsstec-sci-image.hf.space/api/docs
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
### Run Test Script
|
| 88 |
+
```powershell
|
| 89 |
+
cd sci-image
|
| 90 |
+
powershell -NoProfile -ExecutionPolicy Bypass -File "test-hf-space-endpoint.ps1"
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## Deployment Steps
|
| 94 |
+
|
| 95 |
+
1. **Commit Changes**:
|
| 96 |
+
```bash
|
| 97 |
+
cd sci-image
|
| 98 |
+
git add src/frontend/webui/hf_demo.py Dockerfile
|
| 99 |
+
git commit -m "Add hybrid mode: Gradio UI + FastAPI endpoints"
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
2. **Push to Hugging Face Space**:
|
| 103 |
+
```bash
|
| 104 |
+
git push hf main
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
3. **Wait for Rebuild** (5-10 minutes)
|
| 108 |
+
|
| 109 |
+
4. **Verify**:
|
| 110 |
+
- UI: Visit `https://gsstec-sci-image.hf.space/`
|
| 111 |
+
- API: `curl https://gsstec-sci-image.hf.space/api/ping`
|
| 112 |
+
|
| 113 |
+
## Benefits
|
| 114 |
+
|
| 115 |
+
✓ **User-Friendly**: Gradio UI for interactive use
|
| 116 |
+
✓ **Programmatic Access**: FastAPI endpoints for integrations
|
| 117 |
+
✓ **Monitoring**: `/api/ping` endpoint for UptimeRobot
|
| 118 |
+
✓ **Documentation**: Auto-generated API docs at `/api/docs`
|
| 119 |
+
✓ **Single Deployment**: One Space serves both purposes
|
| 120 |
+
|
| 121 |
+
## Integration Examples
|
| 122 |
+
|
| 123 |
+
### AEGIS Bio-Digital Lab 10 Integration
|
| 124 |
+
|
| 125 |
+
```javascript
|
| 126 |
+
// Window 7: Generate pathogen visualization
|
| 127 |
+
const response = await fetch('https://gsstec-sci-image.hf.space/api/window7/generate-pathogen', {
|
| 128 |
+
method: 'POST',
|
| 129 |
+
headers: { 'Content-Type': 'application/json' },
|
| 130 |
+
body: JSON.stringify({
|
| 131 |
+
prompt: "Microscopic view of Ebola virus, scientific illustration",
|
| 132 |
+
num_inference_steps: 12,
|
| 133 |
+
guidance_scale: 2.0,
|
| 134 |
+
width: 512,
|
| 135 |
+
height: 512
|
| 136 |
+
})
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
const result = await response.json();
|
| 140 |
+
console.log('Generated image:', result.images[0]); // Base64 image
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
## Troubleshooting
|
| 144 |
+
|
| 145 |
+
### Issue: API endpoints return 404
|
| 146 |
+
**Solution**: Ensure the Space has rebuilt after pushing the changes to `hf_demo.py`
|
| 147 |
+
|
| 148 |
+
### Issue: UI not loading
|
| 149 |
+
**Solution**: Check that Gradio is properly launching. View Space logs for errors.
|
| 150 |
+
|
| 151 |
+
### Issue: Both UI and API slow
|
| 152 |
+
**Solution**: This is expected on CPU-only instances. Consider upgrading to GPU Space for faster generation.
|
| 153 |
+
|
| 154 |
+
## Version History
|
| 155 |
+
|
| 156 |
+
- **v1.2.0** (2026-06-05): Hybrid mode implementation
|
| 157 |
+
- Added FastAPI mounting to Gradio demo
|
| 158 |
+
- Provides both UI and API endpoints
|
| 159 |
+
- Reverted to `--hfdemo` mode with enhanced functionality
|
sci-image/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 Rupesh Sreeraman
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
sci-image/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Fastsdcpu
|
| 3 |
+
emoji: 📉
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
Check out the configuration reference at <https://huggingface.co/docs/hub/spaces-config-reference>
|
sci-image/THIRD-PARTY-LICENSES
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
stablediffusion.cpp - MIT
|
| 2 |
+
|
| 3 |
+
OpenVINO stablediffusion engine - Apache 2
|
| 4 |
+
|
| 5 |
+
SD Turbo - STABILITY AI NON-COMMERCIAL RESEARCH COMMUNITY LICENSE AGREEMENT
|
| 6 |
+
|
| 7 |
+
MIT License
|
| 8 |
+
|
| 9 |
+
Copyright (c) 2023 leejet
|
| 10 |
+
|
| 11 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 12 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 13 |
+
in the Software without restriction, including without limitation the rights
|
| 14 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 15 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 16 |
+
furnished to do so, subject to the following conditions:
|
| 17 |
+
|
| 18 |
+
The above copyright notice and this permission notice shall be included in all
|
| 19 |
+
copies or substantial portions of the Software.
|
| 20 |
+
|
| 21 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 22 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 23 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 24 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 25 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 26 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 27 |
+
SOFTWARE.
|
| 28 |
+
|
| 29 |
+
ERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 30 |
+
|
| 31 |
+
Definitions.
|
| 32 |
+
|
| 33 |
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
| 34 |
+
|
| 35 |
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
| 36 |
+
|
| 37 |
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
| 38 |
+
|
| 39 |
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
| 40 |
+
|
| 41 |
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
| 42 |
+
|
| 43 |
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
| 44 |
+
|
| 45 |
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
| 46 |
+
|
| 47 |
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
| 50 |
+
|
| 51 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
| 52 |
+
|
| 53 |
+
Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
| 54 |
+
|
| 55 |
+
Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
| 56 |
+
|
| 57 |
+
Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
| 58 |
+
|
| 59 |
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
| 60 |
+
|
| 61 |
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
| 62 |
+
|
| 63 |
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
| 64 |
+
|
| 65 |
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
| 66 |
+
|
| 67 |
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
| 68 |
+
|
| 69 |
+
Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
| 70 |
+
|
| 71 |
+
Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
| 72 |
+
|
| 73 |
+
Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
| 74 |
+
|
| 75 |
+
Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
| 76 |
+
|
| 77 |
+
Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
| 78 |
+
|
| 79 |
+
END OF TERMS AND CONDITIONS
|
| 80 |
+
|
| 81 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 82 |
+
|
| 83 |
+
To apply the Apache License to your work, attach the following
|
| 84 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 85 |
+
replaced with your own identifying information. (Don't include
|
| 86 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 87 |
+
comment syntax for the file format. We also recommend that a
|
| 88 |
+
file or class name and description of purpose be included on the
|
| 89 |
+
same "printed page" as the copyright notice for easier
|
| 90 |
+
identification within third-party archives.
|
| 91 |
+
Copyright [yyyy] [name of copyright owner]
|
| 92 |
+
|
| 93 |
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
| 94 |
+
|
| 95 |
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
| 96 |
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
| 97 |
+
|
| 98 |
+
STABILITY AI NON-COMMERCIAL RESEARCH COMMUNITY LICENSE AGREEMENT
|
| 99 |
+
Dated: November 28, 2023
|
| 100 |
+
|
| 101 |
+
By using or distributing any portion or element of the Models, Software, Software Products or Derivative Works, you agree to be bound by this Agreement.
|
| 102 |
+
|
| 103 |
+
"Agreement" means this Stable Non-Commercial Research Community License Agreement.
|
| 104 |
+
|
| 105 |
+
“AUP” means the Stability AI Acceptable Use Policy available at <https://stability.ai/use-policy>, as may be updated from time to time.
|
| 106 |
+
|
| 107 |
+
"Derivative Work(s)” means (a) any derivative work of the Software Products as recognized by U.S. copyright laws and (b) any modifications to a Model, and any other model created which is based on or derived from the Model or the Model’s output. For clarity, Derivative Works do not include the output of any Model.
|
| 108 |
+
|
| 109 |
+
“Documentation” means any specifications, manuals, documentation, and other written information provided by Stability AI related to the Software.
|
| 110 |
+
|
| 111 |
+
"Licensee" or "you" means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity's behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.
|
| 112 |
+
|
| 113 |
+
“Model(s)" means, collectively, Stability AI’s proprietary models and algorithms, including machine-learning models, trained model weights and other elements of the foregoing, made available under this Agreement.
|
| 114 |
+
|
| 115 |
+
“Non-Commercial Uses” means exercising any of the rights granted herein for the purpose of research or non-commercial purposes. Non-Commercial Uses does not include any production use of the Software Products or any Derivative Works.
|
| 116 |
+
|
| 117 |
+
"Stability AI" or "we" means Stability AI Ltd. and its affiliates.
|
| 118 |
+
|
| 119 |
+
"Software" means Stability AI’s proprietary software made available under this Agreement.
|
| 120 |
+
|
| 121 |
+
“Software Products” means the Models, Software and Documentation, individually or in any combination.
|
| 122 |
+
|
| 123 |
+
1. License Rights and Redistribution.
|
| 124 |
+
|
| 125 |
+
a. Subject to your compliance with this Agreement, the AUP (which is hereby incorporated herein by reference), and the Documentation, Stability AI grants you a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable, royalty free and limited license under Stability AI’s intellectual property or other rights owned or controlled by Stability AI embodied in the Software Products to use, reproduce, distribute, and create Derivative Works of, the Software Products, in each case for Non-Commercial Uses only.
|
| 126 |
+
|
| 127 |
+
b. You may not use the Software Products or Derivative Works to enable third parties to use the Software Products or Derivative Works as part of your hosted service or via your APIs, whether you are adding substantial additional functionality thereto or not. Merely distributing the Software Products or Derivative Works for download online without offering any related service (ex. by distributing the Models on HuggingFace) is not a violation of this subsection. If you wish to use the Software Products or any Derivative Works for commercial or production use or you wish to make the Software Products or any Derivative Works available to third parties via your hosted service or your APIs, contact Stability AI at <https://stability.ai/contact>.
|
| 128 |
+
|
| 129 |
+
c. If you distribute or make the Software Products, or any Derivative Works thereof, available to a third party, the Software Products, Derivative Works, or any portion thereof, respectively, will remain subject to this Agreement and you must (i) provide a copy of this Agreement to such third party, and (ii) retain the following attribution notice within a "Notice" text file distributed as a part of such copies: "This Stability AI Model is licensed under the Stability AI Non-Commercial Research Community License, Copyright (c) Stability AI Ltd. All Rights Reserved.” If you create a Derivative Work of a Software Product, you may add your own attribution notices to the Notice file included with the Software Product, provided that you clearly indicate which attributions apply to the Software Product and you must state in the NOTICE file that you changed the Software Product and how it was modified.
|
| 130 |
+
|
| 131 |
+
2. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE SOFTWARE PRODUCTS AND ANY OUTPUT AND RESULTS THERE FROM ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE SOFTWARE PRODUCTS, DERIVATIVE WORKS OR ANY OUTPUT OR RESULTS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE SOFTWARE PRODUCTS, DERIVATIVE WORKS AND ANY OUTPUT AND RESULTS.
|
| 132 |
+
|
| 133 |
+
3. Limitation of Liability. IN NO EVENT WILL STABILITY AI OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF STABILITY AI OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
| 134 |
+
|
| 135 |
+
4. Intellectual Property.
|
| 136 |
+
|
| 137 |
+
a. No trademark licenses are granted under this Agreement, and in connection with the Software Products or Derivative Works, neither Stability AI nor Licensee may use any name or mark owned by or associated with the other or any of its affiliates, except as required for reasonable and customary use in describing and redistributing the Software Products or Derivative Works.
|
| 138 |
+
|
| 139 |
+
b. Subject to Stability AI’s ownership of the Software Products and Derivative Works made by or for Stability AI, with respect to any Derivative Works that are made by you, as between you and Stability AI, you are and will be the owner of such Derivative Works
|
| 140 |
+
|
| 141 |
+
c. If you institute litigation or other proceedings against Stability AI (including a cross-claim or counterclaim in a lawsuit) alleging that the Software Products, Derivative Works or associated outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Stability AI from and against any claim by any third party arising out of or related to your use or distribution of the Software Products or Derivative Works in violation of this Agreement.
|
| 142 |
+
|
| 143 |
+
5. Term and Termination. The term of this Agreement will commence upon your acceptance of this Agreement or access to the Software Products and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Stability AI may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of any Software Products or Derivative Works. Sections 2-4 shall survive the termination of this Agreement.
|
sci-image/benchmark-openvino.bat
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
setlocal
|
| 3 |
+
|
| 4 |
+
set "PYTHON_COMMAND=python"
|
| 5 |
+
|
| 6 |
+
call python --version > nul 2>&1
|
| 7 |
+
if %errorlevel% equ 0 (
|
| 8 |
+
echo Python command check :OK
|
| 9 |
+
) else (
|
| 10 |
+
echo "Error: Python command not found, please install Python (Recommended : Python 3.10 or Python 3.11) and try again"
|
| 11 |
+
pause
|
| 12 |
+
exit /b 1
|
| 13 |
+
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
:check_python_version
|
| 17 |
+
for /f "tokens=2" %%I in ('%PYTHON_COMMAND% --version 2^>^&1') do (
|
| 18 |
+
set "python_version=%%I"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
echo Python version: %python_version%
|
| 22 |
+
|
| 23 |
+
call "%~dp0env\Scripts\activate.bat" && %PYTHON_COMMAND% src/app.py -b --use_openvino --openvino_lcm_model_id "rupeshs/sd-turbo-openvino"
|
sci-image/benchmark.bat
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
setlocal
|
| 3 |
+
|
| 4 |
+
set "PYTHON_COMMAND=python"
|
| 5 |
+
|
| 6 |
+
call python --version > nul 2>&1
|
| 7 |
+
if %errorlevel% equ 0 (
|
| 8 |
+
echo Python command check :OK
|
| 9 |
+
) else (
|
| 10 |
+
echo "Error: Python command not found, please install Python (Recommended : Python 3.10 or Python 3.11) and try again"
|
| 11 |
+
pause
|
| 12 |
+
exit /b 1
|
| 13 |
+
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
:check_python_version
|
| 17 |
+
for /f "tokens=2" %%I in ('%PYTHON_COMMAND% --version 2^>^&1') do (
|
| 18 |
+
set "python_version=%%I"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
echo Python version: %python_version%
|
| 22 |
+
|
| 23 |
+
call "%~dp0env\Scripts\activate.bat" && %PYTHON_COMMAND% src/app.py -b
|
sci-image/configs/lcm-lora-models.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
latent-consistency/lcm-lora-sdv1-5
|
| 2 |
+
latent-consistency/lcm-lora-sdxl
|
| 3 |
+
latent-consistency/lcm-lora-ssd-1b
|
| 4 |
+
rupeshs/hypersd-sd1-5-1-step-lora
|
sci-image/configs/lcm-models.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
stabilityai/sd-turbo
|
| 2 |
+
rupeshs/sdxs-512-0.9-orig-vae
|
| 3 |
+
rupeshs/hyper-sd-sdxl-1-step
|
| 4 |
+
rupeshs/SDXL-Lightning-2steps
|
| 5 |
+
stabilityai/sdxl-turbo
|
| 6 |
+
SimianLuo/LCM_Dreamshaper_v7
|
sci-image/configs/openvino-lcm-models.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
rupeshs/sd-turbo-openvino
|
| 2 |
+
rupeshs/sdxs-512-0.9-openvino
|
| 3 |
+
rupeshs/hyper-sd-sdxl-1-step-openvino-int8
|
| 4 |
+
rupeshs/SDXL-Lightning-2steps-openvino-int8
|
| 5 |
+
rupeshs/sdxl-turbo-openvino-int8
|
| 6 |
+
rupeshs/LCM-dreamshaper-v7-openvino
|
| 7 |
+
Disty0/LCM_SoteMix
|
| 8 |
+
rupeshs/sd15-lcm-square-openvino-int8
|
| 9 |
+
OpenVINO/FLUX.1-schnell-int4-ov
|
| 10 |
+
rupeshs/sana-sprint-0.6b-openvino-int4
|
sci-image/configs/stable-diffusion-models.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Lykon/dreamshaper-8
|
| 2 |
+
Fictiverse/Stable_Diffusion_PaperCut_Model
|
| 3 |
+
stabilityai/stable-diffusion-xl-base-1.0
|
| 4 |
+
runwayml/stable-diffusion-v1-5
|
| 5 |
+
segmind/SSD-1B
|
| 6 |
+
stablediffusionapi/anything-v5
|
| 7 |
+
prompthero/openjourney-v4
|
sci-image/controlnet_models/Readme.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Place your ControlNet models in this folder.
|
| 2 |
+
You can download controlnet model (.safetensors) from https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/tree/main
|
| 3 |
+
E.g: https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/blob/main/control_v11p_sd15_canny_fp16.safetensors
|
sci-image/install-mac.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
echo Starting FastSD CPU env installation...
|
| 3 |
+
set -e
|
| 4 |
+
PYTHON_COMMAND="python3"
|
| 5 |
+
|
| 6 |
+
if ! command -v python3 &>/dev/null; then
|
| 7 |
+
if ! command -v python &>/dev/null; then
|
| 8 |
+
echo "Error: Python not found, please install python 3.8 or higher and try again"
|
| 9 |
+
exit 1
|
| 10 |
+
fi
|
| 11 |
+
fi
|
| 12 |
+
|
| 13 |
+
if command -v python &>/dev/null; then
|
| 14 |
+
PYTHON_COMMAND="python"
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
echo "Found $PYTHON_COMMAND command"
|
| 18 |
+
|
| 19 |
+
python_version=$($PYTHON_COMMAND --version 2>&1 | awk '{print $2}')
|
| 20 |
+
echo "Python version : $python_version"
|
| 21 |
+
|
| 22 |
+
if ! command -v uv &>/dev/null; then
|
| 23 |
+
echo "Error: uv command not found,please install https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1 and try again."
|
| 24 |
+
exit 1
|
| 25 |
+
fi
|
| 26 |
+
|
| 27 |
+
BASEDIR=$(pwd)
|
| 28 |
+
|
| 29 |
+
uv venv --python 3.11.6 "$BASEDIR/env"
|
| 30 |
+
# shellcheck disable=SC1091
|
| 31 |
+
source "$BASEDIR/env/bin/activate"
|
| 32 |
+
uv pip install torch==2.8.0
|
| 33 |
+
uv pip install -r "$BASEDIR/requirements.txt"
|
| 34 |
+
chmod +x "start.sh"
|
| 35 |
+
chmod +x "start-webui.sh"
|
| 36 |
+
read -n1 -r -p "FastSD CPU installation completed,press any key to continue..." key
|