sidharthg commited on
Commit
20a1b7c
Β·
verified Β·
1 Parent(s): 3b70330

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +78 -103
  2. app.py +0 -1
  3. requirements.txt +1 -1
README.md CHANGED
@@ -1,103 +1,78 @@
1
- ---
2
- title: Stable Diffusion Style Explorer
3
- emoji: 🎨
4
- colorFrom: purple
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 5.9.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- # 🎨 Stable Diffusion Guided Style Explorer
14
-
15
- This project demonstrates the power of **Textual Inversion** combined with **Artistic Guided Sampling** to steer Stable Diffusion v1-4 towards specific artistic styles and visual attributes.
16
-
17
- ## πŸš€ Overview
18
-
19
- The project consists of two main components:
20
- 1. **Jupyter Notebook (`stable_conceptualizer_inference (1).ipynb`)**: A research-focused environment for experimenting with loss-based guidance and exploring the mechanics of Textual Inversion.
21
- 2. **Gradio Web App (`app.py`)**: A user-friendly interface for generating images with real-time control over artistic guidance.
22
-
23
- ---
24
-
25
- ## πŸ”¬ Core Concepts
26
-
27
- ### 1. Textual Inversion
28
- Instead of retraining the entire Stable Diffusion model, we use **Textual Inversion** to learn new "pseudo-words" (tokens) that represent specific concepts or styles.
29
- * **Token Injection**: By adding a learned embedding to the CLIP text encoder, we can invoke complex styles with a simple keyword like `<style>`.
30
- * **Integrated Styles**: The project includes styles from the SD Concepts Library such as:
31
- * **Madhubani Art**: Traditional Indian folk art.
32
- * **Cat Toy**: Plastic, cute aesthetic.
33
- * **Seletti**: Porcelain/ceramic design.
34
- * **Indian Watercolor**: Expressive portraits.
35
- * **Chucky & Anime Boy**: Character-specific styles.
36
-
37
- ### 2. Guided Sampling (Artistic Steering)
38
- While standard sampling follows the prompt, our **Guided Sampling** implementation injects extra gradients during the diffusion process to maximize specific visual features:
39
-
40
- | Guidance Type | Technical Implementation | Artistic Effect |
41
- | :--- | :--- | :--- |
42
- | **Contrast** | Maximizes pixel variance from 0.5 | Dramatic lighting, deep shadows. |
43
- | **Complexity** | Edge-detection (Sobel-like) gradients | Intricate details, sharp textures. |
44
- | **Vibrancy** | Maximizes color channel variance | Vivid, punchy color saturation. |
45
-
46
- ---
47
-
48
- ## πŸ›  Features
49
-
50
- ### πŸ““ Jupyter Notebook
51
- * **Step-by-Step implementation**: Detailed code for applying loss gradients during the UNet sampling loop.
52
- * **Reproducibility**: Uses fixed seeds (`torch.Generator`) to isolate the effect of guidance scales, ensuring that changes in output are purely due to artistic steering.
53
- * **Deep Dive Documentation**: Explains the math and logic behind each loss function.
54
-
55
- ## πŸ“± User Guide: Gradio App
56
-
57
- The **Stable Diffusion Style Explorer** provides two distinct ways to interact with the model.
58
-
59
- ### 1. Single Style Generation
60
- Use this tab for granular control over a specific aesthetic.
61
- * **Select Style**: Choose one of the 5+ pre-loaded textual inversion concepts.
62
- * **Prompt**: Write your prompt using the `<style>` placeholder. (e.g., `"a futuristic city in the style of <style>"`).
63
- * **Artistic Sliders**:
64
- * **Contrast Strength**: Increase to add drama and deeper shadows.
65
- * **Complexity Strength**: Increase to force intricate patterns and fine details.
66
- * **Vibrancy Strength**: Increase for more saturated and "glowing" colors.
67
- * **Seed Management**: Each style comes with a pre-configured "best" seed, but you can override it to explore different variations.
68
-
69
- ### 2. Compare All Styles
70
- Use this tab to see how a single prompt manifests across different artistic interpretations.
71
- * **Batch Generation**: Generates 3 images (default) for every single style simultaneously.
72
- * **Unified Guidance**: Apply the same Contrast, Complexity, and Vibrancy scales across all styles to compare their response to guidance.
73
- * **Style-Specific Seeds**: Configure individual seeds for each style to ensure reproducibility across separate runs.
74
-
75
- ---
76
-
77
- ## 🚦 Getting Started
78
-
79
- ### Prerequisites
80
- * Python 3.10+
81
- * GPU with 8GB+ VRAM (Recommended)
82
- * Hugging Face Token (for model and style loading)
83
-
84
- ### Setup
85
- 1. **Clone the repository**.
86
- 2. **Environment Setup**:
87
- ```bash
88
- pip install -r requirements.txt
89
- ```
90
- 3. **Run the App**:
91
- ```bash
92
- python app.py
93
- ```
94
-
95
- ## πŸ’‘ Tips for Best Results
96
- * **Guidance Scales**: Typical effective values for Contrast/Complexity/Vibrancy range from **500 to 1500**. Start low and increase gradually.
97
- * **Prompting**: Keep prompts relatively simple to let the Textual Inversion style shine.
98
- * **Seeds**: If you find an image layout you like, keep the seed fixed while adjusting the loss sliders to see exactly how the guidance "sculpts" that specific composition.
99
-
100
- ## πŸ“œ Credits
101
- * **Model**: Stable Diffusion v1-4
102
- * **Concepts**: πŸ€— Hugging Face [SD Concepts Library](https://huggingface.co/sd-concepts-library)
103
- * **Implementation**: Custom Triple-Loss Guidance Suite.
 
1
+ ---
2
+ title: Stable Diffusion Style Explorer
3
+ emoji: 🎨
4
+ colorFrom: purple
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 6.0.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ # Stable Diffusion Style Explorer
14
+
15
+ An interactive web application for exploring different artistic styles using Stable Diffusion with textual inversion.
16
+
17
+ ## Features
18
+
19
+ - **5 Pre-configured Styles**: Cat Toy, GTA5 Artwork, Birb Style, Midjourney Style, and Arcane Style
20
+ - **Single Style Mode**: Generate images with a specific style, custom seed, and parameters
21
+ - **Compare All Styles**: Generate the same prompt across all 5 styles simultaneously
22
+ - **Seed Control**: Full control over random seeds for reproducible results
23
+ - **Adjustable Parameters**: Configure inference steps and guidance scale
24
+
25
+ ## Usage
26
+
27
+ ### Single Style Mode
28
+ 1. Enter your prompt (use `<style>` as a placeholder for the style token)
29
+ 2. Select a style from the dropdown
30
+ 3. Set your desired seed value
31
+ 4. Adjust inference steps and guidance scale if needed
32
+ 5. Click "Generate Image"
33
+
34
+ ### Compare All Styles Mode
35
+ 1. Enter your prompt (use `<style>` as a placeholder)
36
+ 2. Set a base seed value
37
+ 3. Each style will use: `base_seed + (style_index * 100)`
38
+ 4. Click "Generate All Styles" to see all variations
39
+
40
+ ## Styles
41
+
42
+ - **Cat Toy**: Cute cat toy aesthetic
43
+ - **GTA5 Artwork**: GTA V game art style
44
+ - **Birb Style**: Artistic bird illustration style
45
+ - **Midjourney Style**: Midjourney AI art aesthetic
46
+ - **Arcane Style**: Arcane Netflix series art style
47
+
48
+ ## Technical Details
49
+
50
+ - **Base Model**: CompVis/stable-diffusion-v1-4
51
+ - **Textual Inversion**: Concepts from [SD Concepts Library](https://huggingface.co/sd-concepts-library)
52
+ - **Framework**: Gradio + Diffusers
53
+ - **GPU**: Recommended for faster generation
54
+
55
+ ## Local Development
56
+
57
+ ```bash
58
+ # Clone the repository
59
+ git clone <your-repo-url>
60
+ cd <repo-name>
61
+
62
+ # Install dependencies
63
+ pip install -r requirements.txt
64
+
65
+ # Run the app
66
+ python app.py
67
+ ```
68
+
69
+ ## Deployment to Hugging Face Spaces
70
+
71
+ 1. Create a new Space on Hugging Face
72
+ 2. Select "Gradio" as the SDK
73
+ 3. Upload `app.py`, `requirements.txt`, and `README.md`
74
+ 4. The app will automatically build and deploy
75
+
76
+ ## License
77
+
78
+ MIT License - Feel free to use and modify!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -544,6 +544,5 @@ with gr.Blocks(title="Stable Diffusion Style Explorer",theme=gr.themes.Soft()) a
544
  if __name__ == "__main__":
545
  #demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
546
  print("RUNNING THIS FILE:", __file__)
547
- python -c "import gradio; print(gradio.__version__)"
548
  demo.launch()
549
 
 
544
  if __name__ == "__main__":
545
  #demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
546
  print("RUNNING THIS FILE:", __file__)
 
547
  demo.launch()
548
 
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- gradio>=5.9.0
2
  torch
3
  torchvision
4
  diffusers
 
1
+ gradio>=6.0.0
2
  torch
3
  torchvision
4
  diffusers