Spaces:
Sleeping
Sleeping
Commit
·
35862c8
1
Parent(s):
6735641
initial commit
Browse files- .editorconfig +12 -0
- .pre-commit-config.yaml +14 -0
- .ruff.toml +24 -0
- README.md +226 -2
- app/__init__.py +1 -0
- app/core/__init__.py +1 -0
- app/generator.py +1 -0
- app/img2img.py +1 -0
- app/models/__init__.py +1 -0
- app/models/metadata.py +1 -0
- app/pipeline.py +1 -0
- app/presets/__init__.py +1 -0
- app/presets/styles.py +1 -0
- app/ui.py +1 -0
- app/upscaler/__init__.py +1 -0
- app/upscaler/realesrgan.py +1 -0
- app/utils/__init__.py +1 -0
- app/utils/history.py +1 -0
- app/utils/logger.py +1 -0
- app/utils/seed.py +1 -0
- assets/__init__.py +1 -0
- assets/lora/__init__.py +1 -0
- init_structure.py +94 -0
- main.py +1 -0
- requirements.txt +40 -0
.editorconfig
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
root = true
|
| 2 |
+
|
| 3 |
+
[*]
|
| 4 |
+
indent_style = space
|
| 5 |
+
indent_size = 4
|
| 6 |
+
charset = utf-8
|
| 7 |
+
end_of_line = lf
|
| 8 |
+
insert_final_newline = true
|
| 9 |
+
trim_trailing_whitespace = true
|
| 10 |
+
|
| 11 |
+
[*.md]
|
| 12 |
+
trim_trailing_whitespace = false
|
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
repos:
|
| 2 |
+
- repo: https://github.com/psf/black
|
| 3 |
+
rev: 24.4.2
|
| 4 |
+
hooks:
|
| 5 |
+
- id: black
|
| 6 |
+
language_version: python3
|
| 7 |
+
args: ["--line-length=100"]
|
| 8 |
+
|
| 9 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 10 |
+
rev: v0.5.0
|
| 11 |
+
hooks:
|
| 12 |
+
- id: ruff
|
| 13 |
+
args: ["--fix"]
|
| 14 |
+
- id: ruff-format
|
.ruff.toml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ruff Configuration
|
| 2 |
+
|
| 3 |
+
[lint]
|
| 4 |
+
select = [
|
| 5 |
+
"E", # pycodestyle errors
|
| 6 |
+
"F", # pyflakes
|
| 7 |
+
"B", # bugbear
|
| 8 |
+
"D", # pydocstyle
|
| 9 |
+
"I", # isort
|
| 10 |
+
]
|
| 11 |
+
ignore = [
|
| 12 |
+
# Ignore missing docstring for __init__.py only
|
| 13 |
+
"D104",
|
| 14 |
+
"B008",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
[lint.pydocstyle]
|
| 18 |
+
convention = "google"
|
| 19 |
+
|
| 20 |
+
[format]
|
| 21 |
+
quote-style = "double"
|
| 22 |
+
indent-style = "space"
|
| 23 |
+
skip-magic-trailing-comma = false
|
| 24 |
+
line-ending = "lf"
|
README.md
CHANGED
|
@@ -1,2 +1,226 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🎨 Stable Diffusion Image Generator
|
| 2 |
+
|
| 3 |
+
AI system built using **Stable Diffusion (HuggingFace Diffusers)** and a modern **Gradio UI**.
|
| 4 |
+
This project generates high-quality images from text prompts and includes advanced capabilities such as:
|
| 5 |
+
|
| 6 |
+
* Style presets
|
| 7 |
+
* Image-to-Image generation
|
| 8 |
+
* Super-resolution upscaling (RealESRGAN)
|
| 9 |
+
* Prompt history & metadata tracking
|
| 10 |
+
* Seed reproducibility
|
| 11 |
+
* LoRA extension support
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Feature Details
|
| 16 |
+
|
| 17 |
+
## 1️⃣ **Text-to-Image Generation**
|
| 18 |
+
|
| 19 |
+
* Supports prompts & negative prompts
|
| 20 |
+
* Adjustable steps, CFG scale, resolution
|
| 21 |
+
* Seed for reproducibility
|
| 22 |
+
* Preset selection panel
|
| 23 |
+
|
| 24 |
+
## 2️⃣ **Image-to-Image (Img2Img)**
|
| 25 |
+
|
| 26 |
+
Transform uploaded images using prompts, e.g.:
|
| 27 |
+
|
| 28 |
+
* “Make this photo look cyberpunk”
|
| 29 |
+
* “Convert this portrait into anime style”
|
| 30 |
+
* “Turn into oil painting style”
|
| 31 |
+
|
| 32 |
+
## 3️⃣ **Super-Resolution Upscaling**
|
| 33 |
+
|
| 34 |
+
Improve output quality significantly:
|
| 35 |
+
|
| 36 |
+
* 1.5×
|
| 37 |
+
* 2×
|
| 38 |
+
* 4×
|
| 39 |
+
Powered by **RealESRGAN**.
|
| 40 |
+
|
| 41 |
+
## 4️⃣ **Style Presets**
|
| 42 |
+
|
| 43 |
+
One-click artistic styles:
|
| 44 |
+
|
| 45 |
+
* Anime
|
| 46 |
+
* Realistic photography
|
| 47 |
+
* Pixar / 3D
|
| 48 |
+
* Oil painting
|
| 49 |
+
* Cyberpunk neon
|
| 50 |
+
|
| 51 |
+
## 5️⃣ **Prompt History & Metadata Tracking**
|
| 52 |
+
|
| 53 |
+
Every generation stores:
|
| 54 |
+
|
| 55 |
+
* Prompt
|
| 56 |
+
* Negative prompt
|
| 57 |
+
* Configuration
|
| 58 |
+
* Seed
|
| 59 |
+
* Generated image
|
| 60 |
+
|
| 61 |
+
## 6️⃣ **LoRA Support**
|
| 62 |
+
|
| 63 |
+
Load and use custom LoRA fine-tuned models:
|
| 64 |
+
|
| 65 |
+
* Styles
|
| 66 |
+
* Artists
|
| 67 |
+
* Characters
|
| 68 |
+
* Themes
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
# 🧩 Project Architecture
|
| 73 |
+
|
| 74 |
+
```
|
| 75 |
+
stable-diffusion-image-generator/
|
| 76 |
+
│
|
| 77 |
+
├── app/
|
| 78 |
+
│ ├── core/
|
| 79 |
+
│ │ └── __init__.py
|
| 80 |
+
│ │
|
| 81 |
+
│ ├── pipeline.py
|
| 82 |
+
│ │ # Loads & initializes Stable Diffusion (FP16, GPU, model configs)
|
| 83 |
+
│ │
|
| 84 |
+
│ ├── generator.py
|
| 85 |
+
│ │ # Text-to-image inference logic
|
| 86 |
+
│ │
|
| 87 |
+
│ ├── img2img.py
|
| 88 |
+
│ │ # Image-to-image transformation logic
|
| 89 |
+
│ │
|
| 90 |
+
│ ├── ui.py
|
| 91 |
+
│ │ # Complete Gradio interface with multiple tabs:
|
| 92 |
+
│ │ # Text2Img, Img2Img, Upscaling, History, About
|
| 93 |
+
│ │
|
| 94 |
+
│ ├── presets/
|
| 95 |
+
│ │ ├── styles.py
|
| 96 |
+
│ │ # Predefined artistic style presets (anime, cyberpunk, etc.)
|
| 97 |
+
│ │
|
| 98 |
+
│ ├── upscaler/
|
| 99 |
+
│ │ ├── realesrgan.py
|
| 100 |
+
│ │ # Super-resolution (1.5x, 2x, 4x)
|
| 101 |
+
│ │
|
| 102 |
+
│ ├── utils/
|
| 103 |
+
│ │ ├── history.py # Prompt history & metadata saving
|
| 104 |
+
│ │ ├── seed.py # Seed utilities for reproducibility
|
| 105 |
+
│ │ ├── logger.py # Central logging
|
| 106 |
+
│ │
|
| 107 |
+
│ ├── models/
|
| 108 |
+
│ │ ├── metadata.py # Data model for storing history entries
|
| 109 |
+
│
|
| 110 |
+
├── assets/
|
| 111 |
+
│ ├── samples/ # Example generated images
|
| 112 |
+
│ ├── lora/ # Custom LoRA models (optional)
|
| 113 |
+
│
|
| 114 |
+
├── main.py # Entry point (launches Gradio app)
|
| 115 |
+
├── requirements.txt # All dependencies (pinned)
|
| 116 |
+
├── LICENSE
|
| 117 |
+
└── README.md
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
# ⚙️ Installation & Setup
|
| 123 |
+
|
| 124 |
+
### Step 1 — Clone the Repo
|
| 125 |
+
|
| 126 |
+
```
|
| 127 |
+
git clone https://github.com/sanskarmodi8/stable-diffusion-image-generator
|
| 128 |
+
cd stable-diffusion-image-generator
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### Step 2 — Create virtual environment
|
| 132 |
+
|
| 133 |
+
```
|
| 134 |
+
python -m venv venv
|
| 135 |
+
source venv/bin/activate # Linux/Mac
|
| 136 |
+
venv\Scripts\activate # Windows
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
### Step 3 — Install PyTorch (GPU)
|
| 140 |
+
|
| 141 |
+
```
|
| 142 |
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
### Step 4 — Install remaining dependencies
|
| 146 |
+
|
| 147 |
+
```
|
| 148 |
+
pip install -r requirements.txt
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
### Optional — Login to HuggingFace
|
| 152 |
+
|
| 153 |
+
```
|
| 154 |
+
huggingface-cli login
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
# ▶️ Running the App
|
| 160 |
+
|
| 161 |
+
```
|
| 162 |
+
python main.py
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
App will run at:
|
| 166 |
+
|
| 167 |
+
```
|
| 168 |
+
http://127.0.0.1:7860
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
---
|
| 172 |
+
|
| 173 |
+
# 🤝 Contributing
|
| 174 |
+
|
| 175 |
+
This project follows **strict formatting and linting standards** to ensure clean, readable, and professional-quality code.
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
#### 1. Install pre-commit hooks
|
| 179 |
+
|
| 180 |
+
This ensures formatting and linting run **automatically** before every commit.
|
| 181 |
+
|
| 182 |
+
```
|
| 183 |
+
pre-commit install
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
#### 2. Format code manually (optional)
|
| 187 |
+
|
| 188 |
+
```
|
| 189 |
+
black .
|
| 190 |
+
isort .
|
| 191 |
+
ruff check .
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
#### 3. Create feature branches
|
| 195 |
+
|
| 196 |
+
Follow standard naming:
|
| 197 |
+
|
| 198 |
+
```
|
| 199 |
+
feature/<feature-name>
|
| 200 |
+
fix/<bug-name>
|
| 201 |
+
refactor/<module>
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
#### 4. Commit messages
|
| 205 |
+
|
| 206 |
+
Use clear, conventional messages:
|
| 207 |
+
|
| 208 |
+
```
|
| 209 |
+
feat: add anime preset
|
| 210 |
+
fix: resolve img2img prompt issue
|
| 211 |
+
refactor: improve pipeline loading speed
|
| 212 |
+
docs: update readme
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
---
|
| 216 |
+
|
| 217 |
+
# 📄 License
|
| 218 |
+
|
| 219 |
+
Released under the [**MIT License**](LICENSE).
|
| 220 |
+
|
| 221 |
+
---
|
| 222 |
+
|
| 223 |
+
# ⭐ Author
|
| 224 |
+
|
| 225 |
+
**[Sanskar Modi](https://github.com/sanskarmodi8)**
|
| 226 |
+
AI Developer & Machine Learning Engineer
|
app/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
app/core/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
app/generator.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/img2img.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/models/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
app/models/metadata.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/pipeline.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/presets/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
app/presets/styles.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/ui.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/upscaler/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
app/upscaler/realesrgan.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/utils/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
app/utils/history.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/utils/logger.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
app/utils/seed.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
assets/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
assets/lora/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Package initialization file for Stable Diffusion Image Generator."""
|
init_structure.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Project Structure Generator for Stable Diffusion Image Generator.
|
| 3 |
+
|
| 4 |
+
Creates all required directories and placeholder files with compliant
|
| 5 |
+
docstrings. Safe for repeated runs — will not overwrite existing files.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
# Placeholder docstrings
|
| 11 |
+
MODULE_PLACEHOLDER = '"""Auto-generated placeholder module for Stable Diffusion Image Generator."""\n'
|
| 12 |
+
INIT_PLACEHOLDER = '"""Package initialization file for Stable Diffusion Image Generator."""\n'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# Utility functions
|
| 16 |
+
def create_dir(path: str):
|
| 17 |
+
"""Create directory if it doesn't already exist."""
|
| 18 |
+
os.makedirs(path, exist_ok=True)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def create_file(path: str, content: str = MODULE_PLACEHOLDER):
|
| 22 |
+
"""Create a file only if it does not already exist."""
|
| 23 |
+
if not os.path.exists(path):
|
| 24 |
+
with open(path, "w") as f:
|
| 25 |
+
f.write(content)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def init_file(path: str):
|
| 29 |
+
"""Create an __init__.py with a placeholder docstring."""
|
| 30 |
+
if not os.path.exists(path):
|
| 31 |
+
with open(path, "w") as f:
|
| 32 |
+
f.write(INIT_PLACEHOLDER)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# Project Directory Structure
|
| 36 |
+
|
| 37 |
+
directories = [
|
| 38 |
+
"app",
|
| 39 |
+
"app/core",
|
| 40 |
+
"app/models",
|
| 41 |
+
"app/utils",
|
| 42 |
+
"app/presets",
|
| 43 |
+
"app/upscaler",
|
| 44 |
+
"assets",
|
| 45 |
+
"assets/samples",
|
| 46 |
+
"assets/lora",
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# File Definitions
|
| 51 |
+
|
| 52 |
+
files = {
|
| 53 |
+
# Entry
|
| 54 |
+
"main.py": MODULE_PLACEHOLDER,
|
| 55 |
+
|
| 56 |
+
# Core pipeline + generation modules
|
| 57 |
+
"app/pipeline.py": MODULE_PLACEHOLDER,
|
| 58 |
+
"app/generator.py": MODULE_PLACEHOLDER,
|
| 59 |
+
"app/img2img.py": MODULE_PLACEHOLDER,
|
| 60 |
+
|
| 61 |
+
# UI
|
| 62 |
+
"app/ui.py": MODULE_PLACEHOLDER,
|
| 63 |
+
|
| 64 |
+
# Presets
|
| 65 |
+
"app/presets/styles.py": MODULE_PLACEHOLDER,
|
| 66 |
+
|
| 67 |
+
# Upscaler
|
| 68 |
+
"app/upscaler/realesrgan.py": MODULE_PLACEHOLDER,
|
| 69 |
+
|
| 70 |
+
# Utils
|
| 71 |
+
"app/utils/history.py": MODULE_PLACEHOLDER,
|
| 72 |
+
"app/utils/seed.py": MODULE_PLACEHOLDER,
|
| 73 |
+
"app/utils/logger.py": MODULE_PLACEHOLDER,
|
| 74 |
+
|
| 75 |
+
# Models or reference files
|
| 76 |
+
"app/models/metadata.py": MODULE_PLACEHOLDER,
|
| 77 |
+
|
| 78 |
+
# Root files
|
| 79 |
+
"requirements.txt": MODULE_PLACEHOLDER,
|
| 80 |
+
"README.md": MODULE_PLACEHOLDER,
|
| 81 |
+
"LICENSE": MODULE_PLACEHOLDER,
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
# Build the structure
|
| 86 |
+
|
| 87 |
+
for d in directories:
|
| 88 |
+
create_dir(d)
|
| 89 |
+
init_file(os.path.join(d, "__init__.py"))
|
| 90 |
+
|
| 91 |
+
for path, content in files.items():
|
| 92 |
+
create_file(path, content)
|
| 93 |
+
|
| 94 |
+
print("Stable Diffusion Image Generator project structure created successfully!")
|
main.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Auto-generated placeholder module for Stable Diffusion Image Generator."""
|
requirements.txt
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CORE GPU LIBRARIES (PyTorch - GPU ONLY)
|
| 2 |
+
# IMPORTANT: Install manually using:
|
| 3 |
+
# pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
| 4 |
+
|
| 5 |
+
torch==2.5.1
|
| 6 |
+
torchvision==0.20.1
|
| 7 |
+
torchaudio==2.5.1
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# HUGGINGFACE DIFFUSION ECOSYSTEM
|
| 11 |
+
diffusers==0.26.3
|
| 12 |
+
transformers==4.39.3
|
| 13 |
+
accelerate==0.28.0
|
| 14 |
+
safetensors==0.4.2
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# UI FRAMEWORK
|
| 18 |
+
gradio==4.29.0
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# IMAGE PROCESSING & UTILITIES
|
| 22 |
+
opencv-python==4.9.0.80
|
| 23 |
+
Pillow==10.2.0
|
| 24 |
+
numpy==1.26.4
|
| 25 |
+
loguru==0.7.2
|
| 26 |
+
tqdm==4.66.2
|
| 27 |
+
python-dotenv==1.0.1
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# UPSCALING / SUPER-RESOLUTION
|
| 31 |
+
realesrgan==0.3.0
|
| 32 |
+
basicsr==1.4.2
|
| 33 |
+
facexlib==0.3.0
|
| 34 |
+
gfpgan==1.3.8
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
# DEV TOOLS
|
| 38 |
+
black==24.3.0
|
| 39 |
+
ruff==0.3.5
|
| 40 |
+
pre-commit==3.7.0
|