ollamadiffuser 1.1.1__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {ollamadiffuser-1.1.1/ollamadiffuser.egg-info → ollamadiffuser-1.1.2}/PKG-INFO +68 -2
  2. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/README.md +67 -1
  3. ollamadiffuser-1.1.2/ollamadiffuser/__init__.py +31 -0
  4. ollamadiffuser-1.1.2/ollamadiffuser/__main__.py +9 -0
  5. ollamadiffuser-1.1.2/ollamadiffuser/cli/commands.py +133 -0
  6. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/cli/main.py +69 -4
  7. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/utils/controlnet_preprocessors.py +79 -7
  8. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2/ollamadiffuser.egg-info}/PKG-INFO +68 -2
  9. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser.egg-info/SOURCES.txt +1 -0
  10. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/pyproject.toml +1 -1
  11. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/setup.py +44 -23
  12. ollamadiffuser-1.1.1/ollamadiffuser/__main__.py +0 -50
  13. ollamadiffuser-1.1.1/ollamadiffuser/utils/__init__.py +0 -0
  14. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/CHANGELOG.md +0 -0
  15. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/LICENSE +0 -0
  16. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/MANIFEST.in +0 -0
  17. {ollamadiffuser-1.1.1/ollamadiffuser → ollamadiffuser-1.1.2/ollamadiffuser/api}/__init__.py +0 -0
  18. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/api/server.py +0 -0
  19. {ollamadiffuser-1.1.1/ollamadiffuser/api → ollamadiffuser-1.1.2/ollamadiffuser/cli}/__init__.py +0 -0
  20. {ollamadiffuser-1.1.1/ollamadiffuser/cli → ollamadiffuser-1.1.2/ollamadiffuser/core}/__init__.py +0 -0
  21. {ollamadiffuser-1.1.1/ollamadiffuser/core → ollamadiffuser-1.1.2/ollamadiffuser/core/config}/__init__.py +0 -0
  22. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/config/settings.py +0 -0
  23. {ollamadiffuser-1.1.1/ollamadiffuser/core/config → ollamadiffuser-1.1.2/ollamadiffuser/core/inference}/__init__.py +0 -0
  24. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/inference/engine.py +0 -0
  25. {ollamadiffuser-1.1.1/ollamadiffuser/core/inference → ollamadiffuser-1.1.2/ollamadiffuser/core/models}/__init__.py +0 -0
  26. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/models/manager.py +0 -0
  27. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/utils/__init__.py +0 -0
  28. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/utils/download_utils.py +0 -0
  29. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/core/utils/lora_manager.py +0 -0
  30. {ollamadiffuser-1.1.1/ollamadiffuser/core/models → ollamadiffuser-1.1.2/ollamadiffuser/ui}/__init__.py +0 -0
  31. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/ui/templates/index.html +0 -0
  32. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser/ui/web.py +0 -0
  33. {ollamadiffuser-1.1.1/ollamadiffuser/ui → ollamadiffuser-1.1.2/ollamadiffuser/utils}/__init__.py +0 -0
  34. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser.egg-info/dependency_links.txt +0 -0
  35. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser.egg-info/entry_points.txt +0 -0
  36. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser.egg-info/not-zip-safe +0 -0
  37. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser.egg-info/requires.txt +0 -0
  38. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/ollamadiffuser.egg-info/top_level.txt +0 -0
  39. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/requirements.txt +0 -0
  40. {ollamadiffuser-1.1.1 → ollamadiffuser-1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ollamadiffuser
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: 🎨 Local AI Image Generation with Ollama-style CLI for Stable Diffusion, FLUX.1, and LoRA support
5
5
  Home-page: https://github.com/ollamadiffuser/ollamadiffuser
6
6
  Author: OllamaDiffuser Team
@@ -119,6 +119,9 @@ pip install -e .
119
119
 
120
120
  ### Basic Usage
121
121
  ```bash
122
+ # Check version
123
+ ollamadiffuser -V
124
+
122
125
  # Install a model
123
126
  ollamadiffuser pull stable-diffusion-1.5
124
127
 
@@ -134,7 +137,7 @@ curl -X POST http://localhost:8000/api/generate \
134
137
  # Start web interface
135
138
  ollamadiffuser --mode ui
136
139
 
137
- open http://localhost:8001 in your browser
140
+ open http://localhost:8001
138
141
  ```
139
142
 
140
143
  ### ControlNet Quick Start
@@ -267,6 +270,9 @@ ollamadiffuser load stable-diffusion-1.5
267
270
  curl -X POST http://localhost:8000/api/generate \
268
271
  -H "Content-Type: application/json" \
269
272
  -d '{"prompt": "a beautiful landscape", "width": 1024, "height": 1024}'
273
+
274
+ # API document
275
+ http://localhost:8000/docs
270
276
  ```
271
277
 
272
278
  ### Python API
@@ -389,6 +395,43 @@ with open("control.jpg", "rb") as f:
389
395
 
390
396
  ## 🔧 Troubleshooting
391
397
 
398
+ ### Installation Issues
399
+
400
+ #### Missing Dependencies (cv2/OpenCV Error)
401
+ If you encounter `ModuleNotFoundError: No module named 'cv2'`, run:
402
+
403
+ ```bash
404
+ # Quick fix
405
+ pip install opencv-python>=4.8.0
406
+
407
+ # Or use the built-in verification tool
408
+ ollamadiffuser verify-deps
409
+
410
+ # Or install with all optional dependencies
411
+ pip install ollamadiffuser[full]
412
+ ```
413
+
414
+ #### Complete Dependency Check
415
+ ```bash
416
+ # Run comprehensive system diagnostics
417
+ ollamadiffuser doctor
418
+
419
+ # Verify and install missing dependencies interactively
420
+ ollamadiffuser verify-deps
421
+ ```
422
+
423
+ #### Clean Installation
424
+ If you're having persistent issues:
425
+
426
+ ```bash
427
+ # Uninstall and reinstall
428
+ pip uninstall ollamadiffuser
429
+ pip install --no-cache-dir ollamadiffuser[full]
430
+
431
+ # Verify installation
432
+ ollamadiffuser verify-deps
433
+ ```
434
+
392
435
  ### Common Issues
393
436
 
394
437
  #### Slow Startup
@@ -424,6 +467,29 @@ curl -X POST http://localhost:8000/api/generate \
424
467
  # Use basic preprocessors instead of advanced ones
425
468
  ```
426
469
 
470
+ ### Platform-Specific Issues
471
+
472
+ #### macOS Apple Silicon
473
+ ```bash
474
+ # If you encounter OpenCV issues on Apple Silicon
475
+ pip uninstall opencv-python
476
+ pip install opencv-python-headless>=4.8.0
477
+ ```
478
+
479
+ #### Windows
480
+ ```bash
481
+ # If you encounter build errors
482
+ pip install --only-binary=all opencv-python>=4.8.0
483
+ ```
484
+
485
+ #### Linux
486
+ ```bash
487
+ # If you need system dependencies
488
+ sudo apt-get update
489
+ sudo apt-get install libgl1-mesa-glx libglib2.0-0
490
+ pip install opencv-python>=4.8.0
491
+ ```
492
+
427
493
  ### Debug Mode
428
494
  ```bash
429
495
  # Enable verbose logging
@@ -53,6 +53,9 @@ pip install -e .
53
53
 
54
54
  ### Basic Usage
55
55
  ```bash
56
+ # Check version
57
+ ollamadiffuser -V
58
+
56
59
  # Install a model
57
60
  ollamadiffuser pull stable-diffusion-1.5
58
61
 
@@ -68,7 +71,7 @@ curl -X POST http://localhost:8000/api/generate \
68
71
  # Start web interface
69
72
  ollamadiffuser --mode ui
70
73
 
71
- open http://localhost:8001 in your browser
74
+ open http://localhost:8001
72
75
  ```
73
76
 
74
77
  ### ControlNet Quick Start
@@ -201,6 +204,9 @@ ollamadiffuser load stable-diffusion-1.5
201
204
  curl -X POST http://localhost:8000/api/generate \
202
205
  -H "Content-Type: application/json" \
203
206
  -d '{"prompt": "a beautiful landscape", "width": 1024, "height": 1024}'
207
+
208
+ # API document
209
+ http://localhost:8000/docs
204
210
  ```
205
211
 
206
212
  ### Python API
@@ -323,6 +329,43 @@ with open("control.jpg", "rb") as f:
323
329
 
324
330
  ## 🔧 Troubleshooting
325
331
 
332
+ ### Installation Issues
333
+
334
+ #### Missing Dependencies (cv2/OpenCV Error)
335
+ If you encounter `ModuleNotFoundError: No module named 'cv2'`, run:
336
+
337
+ ```bash
338
+ # Quick fix
339
+ pip install opencv-python>=4.8.0
340
+
341
+ # Or use the built-in verification tool
342
+ ollamadiffuser verify-deps
343
+
344
+ # Or install with all optional dependencies
345
+ pip install ollamadiffuser[full]
346
+ ```
347
+
348
+ #### Complete Dependency Check
349
+ ```bash
350
+ # Run comprehensive system diagnostics
351
+ ollamadiffuser doctor
352
+
353
+ # Verify and install missing dependencies interactively
354
+ ollamadiffuser verify-deps
355
+ ```
356
+
357
+ #### Clean Installation
358
+ If you're having persistent issues:
359
+
360
+ ```bash
361
+ # Uninstall and reinstall
362
+ pip uninstall ollamadiffuser
363
+ pip install --no-cache-dir ollamadiffuser[full]
364
+
365
+ # Verify installation
366
+ ollamadiffuser verify-deps
367
+ ```
368
+
326
369
  ### Common Issues
327
370
 
328
371
  #### Slow Startup
@@ -358,6 +401,29 @@ curl -X POST http://localhost:8000/api/generate \
358
401
  # Use basic preprocessors instead of advanced ones
359
402
  ```
360
403
 
404
+ ### Platform-Specific Issues
405
+
406
+ #### macOS Apple Silicon
407
+ ```bash
408
+ # If you encounter OpenCV issues on Apple Silicon
409
+ pip uninstall opencv-python
410
+ pip install opencv-python-headless>=4.8.0
411
+ ```
412
+
413
+ #### Windows
414
+ ```bash
415
+ # If you encounter build errors
416
+ pip install --only-binary=all opencv-python>=4.8.0
417
+ ```
418
+
419
+ #### Linux
420
+ ```bash
421
+ # If you need system dependencies
422
+ sudo apt-get update
423
+ sudo apt-get install libgl1-mesa-glx libglib2.0-0
424
+ pip install opencv-python>=4.8.0
425
+ ```
426
+
361
427
  ### Debug Mode
362
428
  ```bash
363
429
  # Enable verbose logging
@@ -0,0 +1,31 @@
1
+ """
2
+ OllamaDiffuser - Local AI Image Generation with Ollama-style CLI
3
+
4
+ A tool for managing and running Stable Diffusion, FLUX.1, and other AI image generation models locally.
5
+ """
6
+
7
+ __version__ = "1.1.1"
8
+ __author__ = "OllamaDiffuser Team"
9
+ __email__ = "ollamadiffuser@gmail.com"
10
+ __description__ = "🎨 Local AI Image Generation with Ollama-style CLI for Stable Diffusion, FLUX.1, and LoRA support"
11
+ __url__ = "https://www.ollamadiffuser.com/"
12
+ __repository__ = "https://github.com/ollamadiffuser/ollamadiffuser"
13
+
14
+ def get_version_info():
15
+ """Get formatted version information"""
16
+ return {
17
+ "version": __version__,
18
+ "description": __description__,
19
+ "url": __url__,
20
+ "repository": __repository__
21
+ }
22
+
23
+ def print_version():
24
+ """Print formatted version information"""
25
+ from rich import print as rprint
26
+ rprint(f"[bold cyan]OllamaDiffuser v{__version__}[/bold cyan]")
27
+ rprint(__description__)
28
+ rprint(f"🔗 {__url__}")
29
+
30
+ # For backward compatibility
31
+ __all__ = ["__version__", "__author__", "__email__", "__description__", "__url__", "__repository__", "get_version_info", "print_version"]
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python3
2
+ from .cli.main import cli
3
+
4
+ def main():
5
+ """Main entry function"""
6
+ cli()
7
+
8
+ if __name__ == '__main__':
9
+ main()
@@ -0,0 +1,133 @@
1
+ import click
2
+ import subprocess
3
+ import sys
4
+ from rich.console import Console
5
+ from rich.table import Table
6
+ from rich.panel import Panel
7
+ from ..core.models.manager import model_manager
8
+ from ..core.config.settings import settings
9
+
10
+ console = Console()
11
+
12
+ @click.command()
13
+ def verify_deps():
14
+ """Verify and install missing dependencies"""
15
+ console.print("\n🔍 [bold blue]Checking OllamaDiffuser Dependencies[/bold blue]")
16
+
17
+ # Check critical dependencies
18
+ deps_status = {}
19
+
20
+ # OpenCV check
21
+ try:
22
+ import cv2
23
+ deps_status['opencv-python'] = f"✅ Installed (v{cv2.__version__})"
24
+ except ImportError:
25
+ deps_status['opencv-python'] = "❌ Missing"
26
+
27
+ # ControlNet Aux check
28
+ try:
29
+ import controlnet_aux
30
+ deps_status['controlnet-aux'] = "✅ Installed"
31
+ except ImportError:
32
+ deps_status['controlnet-aux'] = "❌ Missing"
33
+
34
+ # Torch check
35
+ try:
36
+ import torch
37
+ deps_status['torch'] = f"✅ Installed (v{torch.__version__})"
38
+ except ImportError:
39
+ deps_status['torch'] = "❌ Missing"
40
+
41
+ # Diffusers check
42
+ try:
43
+ import diffusers
44
+ deps_status['diffusers'] = f"✅ Installed (v{diffusers.__version__})"
45
+ except ImportError:
46
+ deps_status['diffusers'] = "❌ Missing"
47
+
48
+ # Create status table
49
+ table = Table(title="Dependency Status")
50
+ table.add_column("Package", style="cyan")
51
+ table.add_column("Status", style="white")
52
+
53
+ missing_deps = []
54
+ for dep, status in deps_status.items():
55
+ table.add_row(dep, status)
56
+ if "❌ Missing" in status:
57
+ missing_deps.append(dep)
58
+
59
+ console.print(table)
60
+
61
+ if missing_deps:
62
+ console.print(f"\n⚠️ [bold yellow]{len(missing_deps)} dependencies are missing[/bold yellow]")
63
+
64
+ if click.confirm("\nWould you like to install missing dependencies?"):
65
+ for dep in missing_deps:
66
+ console.print(f"\n📦 Installing {dep}...")
67
+
68
+ # Determine package name
69
+ if dep == 'opencv-python':
70
+ package = 'opencv-python>=4.8.0'
71
+ elif dep == 'controlnet-aux':
72
+ package = 'controlnet-aux>=0.0.7'
73
+ else:
74
+ package = dep
75
+
76
+ try:
77
+ subprocess.check_call([
78
+ sys.executable, "-m", "pip", "install", package
79
+ ])
80
+ console.print(f"✅ {dep} installed successfully")
81
+ except subprocess.CalledProcessError as e:
82
+ console.print(f"❌ Failed to install {dep}: {e}")
83
+
84
+ console.print("\n🔄 Re-run 'ollamadiffuser verify-deps' to check status")
85
+ else:
86
+ console.print("\n🎉 [bold green]All dependencies are installed![/bold green]")
87
+
88
+ # Check ControlNet preprocessors
89
+ console.print("\n🔧 [bold blue]Testing ControlNet Preprocessors[/bold blue]")
90
+ try:
91
+ from ..core.utils.controlnet_preprocessors import controlnet_preprocessor
92
+ if controlnet_preprocessor.is_available():
93
+ available_types = controlnet_preprocessor.get_available_types()
94
+ console.print(f"✅ Available types: {', '.join(available_types)}")
95
+ else:
96
+ console.print("⚠️ ControlNet preprocessors not fully available")
97
+ except Exception as e:
98
+ console.print(f"❌ Error testing preprocessors: {e}")
99
+
100
+ @click.command()
101
+ def doctor():
102
+ """Run comprehensive system diagnostics"""
103
+ console.print(Panel.fit("🩺 [bold blue]OllamaDiffuser Doctor[/bold blue]"))
104
+
105
+ # System info
106
+ import platform
107
+ console.print(f"\n💻 System: {platform.system()} {platform.release()}")
108
+ console.print(f"🐍 Python: {sys.version.split()[0]}")
109
+
110
+ # GPU info
111
+ try:
112
+ import torch
113
+ if torch.cuda.is_available():
114
+ console.print(f"🎮 CUDA: Available ({torch.cuda.get_device_name()})")
115
+ elif hasattr(torch.backends, 'mps') and torch.backends.mps.is_available():
116
+ console.print("🍎 Apple Metal: Available")
117
+ else:
118
+ console.print("⚙️ GPU: CPU only")
119
+ except ImportError:
120
+ console.print("❌ PyTorch not installed")
121
+
122
+ # Memory info
123
+ try:
124
+ import psutil
125
+ memory = psutil.virtual_memory()
126
+ console.print(f"🧠 RAM: {memory.total // (1024**3)} GB total, {memory.available // (1024**3)} GB available")
127
+ except ImportError:
128
+ console.print("⚠️ Cannot check memory (psutil missing)")
129
+
130
+ # Run dependency check
131
+ console.print("\n" + "="*50)
132
+ ctx = click.Context(verify_deps)
133
+ ctx.invoke(verify_deps)
@@ -9,6 +9,7 @@ from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, Downlo
9
9
  from rich import print as rprint
10
10
  import time
11
11
 
12
+ from .. import __version__, print_version
12
13
  from ..core.models.manager import model_manager
13
14
  from ..core.config.settings import settings
14
15
  from ..api.server import run_server
@@ -53,14 +54,47 @@ class OllamaStyleProgress:
53
54
  # For other messages, print with dimmed style
54
55
  self.console.print(f"[dim]{message}[/dim]")
55
56
 
56
- @click.group()
57
+ @click.group(invoke_without_command=True)
57
58
  @click.option('--verbose', '-v', is_flag=True, help='Enable verbose output')
58
- def cli(verbose):
59
+ @click.option('--version', '-V', is_flag=True, help='Show version and exit')
60
+ @click.option('--mode', type=click.Choice(['cli', 'api', 'ui']), help='Running mode: cli (command line), api (API server), ui (Web interface)')
61
+ @click.option('--host', default=None, help='Server host address (for api/ui modes)')
62
+ @click.option('--port', type=int, default=None, help='Server port (for api/ui modes)')
63
+ @click.pass_context
64
+ def cli(ctx, verbose, version, mode, host, port):
59
65
  """OllamaDiffuser - Image generation model management tool"""
66
+ if version:
67
+ print_version()
68
+ sys.exit(0)
69
+
60
70
  if verbose:
61
71
  logging.basicConfig(level=logging.DEBUG)
62
72
  else:
63
73
  logging.basicConfig(level=logging.WARNING)
74
+
75
+ # Handle mode-based execution
76
+ if mode:
77
+ if mode == 'api':
78
+ rprint("[blue]Starting OllamaDiffuser API server...[/blue]")
79
+ run_server(host=host, port=port)
80
+ sys.exit(0)
81
+ elif mode == 'ui':
82
+ rprint("[blue]Starting OllamaDiffuser Web UI...[/blue]")
83
+ import uvicorn
84
+ from ..ui.web import create_ui_app
85
+ app = create_ui_app()
86
+ ui_host = host or settings.server.host
87
+ ui_port = port or (settings.server.port + 1) # Web UI uses different port
88
+ uvicorn.run(app, host=ui_host, port=ui_port)
89
+ sys.exit(0)
90
+ elif mode == 'cli':
91
+ # Continue with normal CLI processing
92
+ pass
93
+
94
+ # If no subcommand is provided and no mode/version flag, show help
95
+ if ctx.invoked_subcommand is None and not version and not mode:
96
+ rprint(ctx.get_help())
97
+ sys.exit(0)
64
98
 
65
99
  @cli.command()
66
100
  @click.argument('model_name')
@@ -890,8 +924,39 @@ def show(lora_name: str):
890
924
  @cli.command()
891
925
  def version():
892
926
  """Show version information"""
893
- rprint("[bold cyan]OllamaDiffuser v1.0.0[/bold cyan]")
894
- rprint("Image generation model management tool")
927
+ print_version()
928
+ rprint("\n[bold]Features:[/bold]")
929
+ rprint("• 🚀 Fast Startup with lazy loading architecture")
930
+ rprint("• 🎛️ ControlNet Support with 10+ control types")
931
+ rprint("• 🔄 LoRA Integration with dynamic loading")
932
+ rprint("• 🌐 Multiple Interfaces: CLI, Python API, Web UI, REST API")
933
+ rprint("• 📦 Easy model management and switching")
934
+ rprint("• ⚡ Performance optimized with GPU acceleration")
935
+
936
+ rprint("\n[bold]Supported Models:[/bold]")
937
+ rprint("• FLUX.1-schnell (Apache 2.0, Commercial OK, 4-step generation)")
938
+ rprint("• FLUX.1-dev (Non-commercial, High quality, 50-step generation)")
939
+ rprint("• Stable Diffusion 3.5 Medium")
940
+ rprint("• Stable Diffusion XL Base")
941
+ rprint("• Stable Diffusion 1.5")
942
+ rprint("• ControlNet models for SD15 and SDXL")
943
+
944
+ rprint("\n[dim]For help: ollamadiffuser --help[/dim]")
945
+ rprint("[dim]For diagnostics: ollamadiffuser doctor[/dim]")
946
+
947
+ @cli.command(name='verify-deps')
948
+ def verify_deps_cmd():
949
+ """Verify and install missing dependencies"""
950
+ from .commands import verify_deps
951
+ ctx = click.Context(verify_deps)
952
+ ctx.invoke(verify_deps)
953
+
954
+ @cli.command()
955
+ def doctor():
956
+ """Run comprehensive system diagnostics"""
957
+ from .commands import doctor
958
+ ctx = click.Context(doctor)
959
+ ctx.invoke(doctor)
895
960
 
896
961
  if __name__ == '__main__':
897
962
  cli()
@@ -1,4 +1,10 @@
1
- import cv2
1
+ try:
2
+ import cv2
3
+ CV2_AVAILABLE = True
4
+ except ImportError:
5
+ CV2_AVAILABLE = False
6
+ cv2 = None
7
+
2
8
  import numpy as np
3
9
  from PIL import Image
4
10
  import logging
@@ -15,6 +21,13 @@ class ControlNetPreprocessorManager:
15
21
  self._initialized = False
16
22
  self._initialization_attempted = False
17
23
  self._available_types = []
24
+
25
+ # Check dependencies on initialization
26
+ if not CV2_AVAILABLE:
27
+ logger.warning(
28
+ "OpenCV (cv2) is not installed. "
29
+ "Install it with: pip install opencv-python>=4.8.0"
30
+ )
18
31
 
19
32
  def is_initialized(self) -> bool:
20
33
  """Check if preprocessors are initialized"""
@@ -22,6 +35,9 @@ class ControlNetPreprocessorManager:
22
35
 
23
36
  def is_available(self) -> bool:
24
37
  """Check if ControlNet preprocessors are available"""
38
+ if not CV2_AVAILABLE:
39
+ return False
40
+
25
41
  if not self._initialization_attempted:
26
42
  # Try a lightweight check without full initialization
27
43
  try:
@@ -41,6 +57,12 @@ class ControlNetPreprocessorManager:
41
57
  Returns:
42
58
  True if initialization successful, False otherwise
43
59
  """
60
+ if not CV2_AVAILABLE:
61
+ raise ImportError(
62
+ "OpenCV (cv2) is required for ControlNet preprocessors. "
63
+ "Install it with: pip install opencv-python>=4.8.0"
64
+ )
65
+
44
66
  if self._initialized and not force:
45
67
  return True
46
68
 
@@ -164,17 +186,28 @@ class ControlNetPreprocessorManager:
164
186
 
165
187
  def _init_basic_processors(self):
166
188
  """Initialize basic OpenCV-based processors as fallback"""
167
- logger.info("Using basic OpenCV-based preprocessors")
168
- self.processors = {
169
- 'canny': self._canny_opencv,
170
- 'depth': self._depth_basic,
171
- 'scribble': self._scribble_basic,
172
- }
189
+ if not CV2_AVAILABLE:
190
+ logger.warning("OpenCV not available, using minimal fallback processors")
191
+ self.processors = {
192
+ 'canny': self._simple_edge_fallback,
193
+ 'depth': self._simple_depth_fallback,
194
+ 'scribble': self._simple_edge_fallback,
195
+ }
196
+ else:
197
+ logger.info("Using basic OpenCV-based preprocessors")
198
+ self.processors = {
199
+ 'canny': self._canny_opencv,
200
+ 'depth': self._depth_basic,
201
+ 'scribble': self._scribble_basic,
202
+ }
173
203
  self._initialized = True
174
204
  self._available_types = list(self.processors.keys())
175
205
 
176
206
  def _canny_opencv(self, image: Image.Image, low_threshold: int = 100, high_threshold: int = 200) -> Image.Image:
177
207
  """Basic Canny edge detection using OpenCV"""
208
+ if not CV2_AVAILABLE:
209
+ raise ImportError("OpenCV is required for Canny edge detection")
210
+
178
211
  # Convert PIL to OpenCV format
179
212
  image_cv = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
180
213
 
@@ -187,6 +220,9 @@ class ControlNetPreprocessorManager:
187
220
 
188
221
  def _depth_basic(self, image: Image.Image) -> Image.Image:
189
222
  """Basic depth estimation using simple gradients"""
223
+ if not CV2_AVAILABLE:
224
+ raise ImportError("OpenCV is required for depth estimation")
225
+
190
226
  # Convert to grayscale
191
227
  gray = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2GRAY)
192
228
 
@@ -207,6 +243,9 @@ class ControlNetPreprocessorManager:
207
243
 
208
244
  def _scribble_basic(self, image: Image.Image) -> Image.Image:
209
245
  """Basic scribble detection using edge detection"""
246
+ if not CV2_AVAILABLE:
247
+ raise ImportError("OpenCV is required for scribble detection")
248
+
210
249
  # Convert to grayscale
211
250
  gray = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2GRAY)
212
251
 
@@ -221,6 +260,39 @@ class ControlNetPreprocessorManager:
221
260
  edges_rgb = cv2.cvtColor(edges, cv2.COLOR_GRAY2RGB)
222
261
  return Image.fromarray(edges_rgb)
223
262
 
263
+ def _simple_edge_fallback(self, image: Image.Image, **kwargs) -> Image.Image:
264
+ """Simple edge detection fallback using PIL/numpy only"""
265
+ # Convert to numpy array
266
+ img_array = np.array(image.convert('L')) # Convert to grayscale
267
+
268
+ # Simple gradient-based edge detection
269
+ grad_x = np.abs(np.diff(img_array, axis=1))
270
+ grad_y = np.abs(np.diff(img_array, axis=0))
271
+
272
+ # Pad to maintain original size
273
+ grad_x = np.pad(grad_x, ((0, 0), (0, 1)), mode='edge')
274
+ grad_y = np.pad(grad_y, ((0, 1), (0, 0)), mode='edge')
275
+
276
+ # Combine gradients
277
+ edges = np.sqrt(grad_x**2 + grad_y**2)
278
+ edges = np.uint8(255 * edges / np.max(edges) if np.max(edges) > 0 else edges)
279
+
280
+ # Convert to RGB
281
+ edges_rgb = np.stack([edges, edges, edges], axis=2)
282
+ return Image.fromarray(edges_rgb)
283
+
284
+ def _simple_depth_fallback(self, image: Image.Image, **kwargs) -> Image.Image:
285
+ """Simple depth estimation fallback using PIL/numpy only"""
286
+ # Convert to grayscale
287
+ gray = np.array(image.convert('L'))
288
+
289
+ # Simple depth based on intensity (brighter = closer)
290
+ depth = 255 - gray # Invert so darker areas are "further"
291
+
292
+ # Convert to RGB
293
+ depth_rgb = np.stack([depth, depth, depth], axis=2)
294
+ return Image.fromarray(depth_rgb)
295
+
224
296
  def preprocess(self,
225
297
  image: Union[Image.Image, str],
226
298
  control_type: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ollamadiffuser
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: 🎨 Local AI Image Generation with Ollama-style CLI for Stable Diffusion, FLUX.1, and LoRA support
5
5
  Home-page: https://github.com/ollamadiffuser/ollamadiffuser
6
6
  Author: OllamaDiffuser Team
@@ -119,6 +119,9 @@ pip install -e .
119
119
 
120
120
  ### Basic Usage
121
121
  ```bash
122
+ # Check version
123
+ ollamadiffuser -V
124
+
122
125
  # Install a model
123
126
  ollamadiffuser pull stable-diffusion-1.5
124
127
 
@@ -134,7 +137,7 @@ curl -X POST http://localhost:8000/api/generate \
134
137
  # Start web interface
135
138
  ollamadiffuser --mode ui
136
139
 
137
- open http://localhost:8001 in your browser
140
+ open http://localhost:8001
138
141
  ```
139
142
 
140
143
  ### ControlNet Quick Start
@@ -267,6 +270,9 @@ ollamadiffuser load stable-diffusion-1.5
267
270
  curl -X POST http://localhost:8000/api/generate \
268
271
  -H "Content-Type: application/json" \
269
272
  -d '{"prompt": "a beautiful landscape", "width": 1024, "height": 1024}'
273
+
274
+ # API document
275
+ http://localhost:8000/docs
270
276
  ```
271
277
 
272
278
  ### Python API
@@ -389,6 +395,43 @@ with open("control.jpg", "rb") as f:
389
395
 
390
396
  ## 🔧 Troubleshooting
391
397
 
398
+ ### Installation Issues
399
+
400
+ #### Missing Dependencies (cv2/OpenCV Error)
401
+ If you encounter `ModuleNotFoundError: No module named 'cv2'`, run:
402
+
403
+ ```bash
404
+ # Quick fix
405
+ pip install opencv-python>=4.8.0
406
+
407
+ # Or use the built-in verification tool
408
+ ollamadiffuser verify-deps
409
+
410
+ # Or install with all optional dependencies
411
+ pip install ollamadiffuser[full]
412
+ ```
413
+
414
+ #### Complete Dependency Check
415
+ ```bash
416
+ # Run comprehensive system diagnostics
417
+ ollamadiffuser doctor
418
+
419
+ # Verify and install missing dependencies interactively
420
+ ollamadiffuser verify-deps
421
+ ```
422
+
423
+ #### Clean Installation
424
+ If you're having persistent issues:
425
+
426
+ ```bash
427
+ # Uninstall and reinstall
428
+ pip uninstall ollamadiffuser
429
+ pip install --no-cache-dir ollamadiffuser[full]
430
+
431
+ # Verify installation
432
+ ollamadiffuser verify-deps
433
+ ```
434
+
392
435
  ### Common Issues
393
436
 
394
437
  #### Slow Startup
@@ -424,6 +467,29 @@ curl -X POST http://localhost:8000/api/generate \
424
467
  # Use basic preprocessors instead of advanced ones
425
468
  ```
426
469
 
470
+ ### Platform-Specific Issues
471
+
472
+ #### macOS Apple Silicon
473
+ ```bash
474
+ # If you encounter OpenCV issues on Apple Silicon
475
+ pip uninstall opencv-python
476
+ pip install opencv-python-headless>=4.8.0
477
+ ```
478
+
479
+ #### Windows
480
+ ```bash
481
+ # If you encounter build errors
482
+ pip install --only-binary=all opencv-python>=4.8.0
483
+ ```
484
+
485
+ #### Linux
486
+ ```bash
487
+ # If you need system dependencies
488
+ sudo apt-get update
489
+ sudo apt-get install libgl1-mesa-glx libglib2.0-0
490
+ pip install opencv-python>=4.8.0
491
+ ```
492
+
427
493
  ### Debug Mode
428
494
  ```bash
429
495
  # Enable verbose logging
@@ -17,6 +17,7 @@ ollamadiffuser.egg-info/top_level.txt
17
17
  ollamadiffuser/api/__init__.py
18
18
  ollamadiffuser/api/server.py
19
19
  ollamadiffuser/cli/__init__.py
20
+ ollamadiffuser/cli/commands.py
20
21
  ollamadiffuser/cli/main.py
21
22
  ollamadiffuser/core/__init__.py
22
23
  ollamadiffuser/core/config/__init__.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ollamadiffuser"
7
- version = "1.1.1"
7
+ version = "1.1.2"
8
8
  authors = [
9
9
  {name = "OllamaDiffuser Team", email = "ollamadiffuser@gmail.com"}
10
10
  ]
@@ -1,11 +1,49 @@
1
1
  from setuptools import setup, find_packages
2
+ import sys
2
3
 
3
4
  with open("README.md", "r", encoding="utf-8") as fh:
4
5
  long_description = fh.read()
5
6
 
7
+ # Core dependencies that must be installed
8
+ REQUIRED = [
9
+ "torch>=2.1.0",
10
+ "diffusers>=0.26.0",
11
+ "transformers>=4.35.0",
12
+ "accelerate>=0.25.0",
13
+ "fastapi>=0.104.0",
14
+ "uvicorn>=0.23.0",
15
+ "huggingface-hub>=0.16.0",
16
+ "Pillow>=9.0.0",
17
+ "click>=8.0.0",
18
+ "rich>=13.0.0",
19
+ "pydantic>=2.0.0",
20
+ "protobuf>=3.20.0",
21
+ "sentencepiece>=0.1.99",
22
+ "safetensors>=0.3.0",
23
+ "python-multipart>=0.0.0",
24
+ "psutil>=5.9.0",
25
+ "jinja2>=3.0.0",
26
+ "peft>=0.10.0",
27
+ "numpy>=1.21.0",
28
+ ]
29
+
30
+ # Optional dependencies that can fall back gracefully
31
+ OPTIONAL = [
32
+ "controlnet-aux>=0.0.7",
33
+ "opencv-python>=4.8.0",
34
+ ]
35
+
36
+ # Try to install optional dependencies, but don't fail if they can't be installed
37
+ install_requires = REQUIRED[:]
38
+ for dep in OPTIONAL:
39
+ try:
40
+ install_requires.append(dep)
41
+ except Exception:
42
+ print(f"Warning: Optional dependency {dep} could not be added to requirements")
43
+
6
44
  setup(
7
45
  name="ollamadiffuser",
8
- version="1.1.1",
46
+ version="1.1.2",
9
47
  author="OllamaDiffuser Team",
10
48
  author_email="ollamadiffuser@gmail.com",
11
49
  description="🎨 Ollama-like image generation model management tool with LoRA support",
@@ -27,28 +65,7 @@ setup(
27
65
  "Topic :: Multimedia :: Graphics",
28
66
  ],
29
67
  python_requires=">=3.10",
30
- install_requires=[
31
- "torch>=2.1.0",
32
- "diffusers>=0.26.0",
33
- "transformers>=4.35.0",
34
- "accelerate>=0.25.0",
35
- "fastapi>=0.104.0",
36
- "uvicorn>=0.23.0",
37
- "huggingface-hub>=0.16.0",
38
- "Pillow>=9.0.0",
39
- "click>=8.0.0",
40
- "rich>=13.0.0",
41
- "pydantic>=2.0.0",
42
- "protobuf>=3.20.0",
43
- "sentencepiece>=0.1.99",
44
- "safetensors>=0.3.0",
45
- "python-multipart>=0.0.0",
46
- "psutil>=5.9.0",
47
- "jinja2>=3.0.0",
48
- "peft>=0.10.0",
49
- "controlnet-aux>=0.0.7",
50
- "opencv-python>=4.8.0"
51
- ],
68
+ install_requires=install_requires,
52
69
  extras_require={
53
70
  "dev": [
54
71
  "pytest>=7.0.0",
@@ -57,6 +74,10 @@ setup(
57
74
  "isort>=5.12.0",
58
75
  "flake8>=6.0.0",
59
76
  ],
77
+ "full": [
78
+ "controlnet-aux>=0.0.7",
79
+ "opencv-python>=4.8.0",
80
+ ],
60
81
  },
61
82
  entry_points={
62
83
  "console_scripts": [
@@ -1,50 +0,0 @@
1
- #!/usr/bin/env python3
2
- import sys
3
- import argparse
4
- from .cli.main import cli
5
- from .api.server import run_server
6
- from .ui.web import create_ui_app
7
- from .core.config.settings import settings
8
-
9
- def main():
10
- """Main entry function"""
11
- # Check if first argument is a mode flag
12
- if len(sys.argv) > 1 and sys.argv[1] in ['--mode']:
13
- # Use argparse for mode selection
14
- parser = argparse.ArgumentParser(
15
- description='OllamaDiffuser - Image generation model management tool'
16
- )
17
- parser.add_argument(
18
- '--mode',
19
- choices=['cli', 'api', 'ui'],
20
- required=True,
21
- help='Running mode: cli (command line), api (API server), ui (Web interface)'
22
- )
23
- parser.add_argument('--host', default=None, help='Server host address')
24
- parser.add_argument('--port', type=int, default=None, help='Server port')
25
- parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output')
26
-
27
- args, unknown = parser.parse_known_args()
28
-
29
- if args.mode == 'cli':
30
- # Command line mode
31
- sys.argv = [sys.argv[0]] + unknown
32
- cli()
33
- elif args.mode == 'api':
34
- # API server mode
35
- print("Starting OllamaDiffuser API server...")
36
- run_server(host=args.host, port=args.port)
37
- elif args.mode == 'ui':
38
- # Web UI mode
39
- print("Starting OllamaDiffuser Web UI...")
40
- import uvicorn
41
- app = create_ui_app()
42
- host = args.host or settings.server.host
43
- port = args.port or (settings.server.port + 1) # Web UI uses different port
44
- uvicorn.run(app, host=host, port=port)
45
- else:
46
- # Default to CLI mode for direct command usage
47
- cli()
48
-
49
- if __name__ == '__main__':
50
- main()
File without changes
File without changes
File without changes