Spaces:
Sleeping
Sleeping
Commit
Β·
349493b
1
Parent(s):
b4e28c8
clean
Browse files- .gitignore +9 -0
- app.py +25 -13
.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.venv/
|
| 2 |
+
*.pyc
|
| 3 |
+
*.pyo
|
| 4 |
+
*.pyd
|
| 5 |
+
*.pyw
|
| 6 |
+
*.pyz
|
| 7 |
+
*.pywz
|
| 8 |
+
*.pyzw
|
| 9 |
+
|
app.py
CHANGED
|
@@ -3,21 +3,30 @@ import spaces
|
|
| 3 |
import torch
|
| 4 |
import numpy as np
|
| 5 |
from typing import Tuple, List
|
| 6 |
-
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler
|
| 7 |
import random
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
if
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
MAX_SEED = np.iinfo(np.int32).max
|
| 23 |
|
|
@@ -111,7 +120,7 @@ def quantum_memory_ops(
|
|
| 111 |
results.append(f"Device: {wave.device}")
|
| 112 |
|
| 113 |
# Generate artistic visualization if requested
|
| 114 |
-
if generate_art:
|
| 115 |
prompt = generate_memory_prompt(operation, emotion_valence)
|
| 116 |
generator = torch.Generator().manual_seed(seed)
|
| 117 |
art_viz = pipe(
|
|
@@ -127,6 +136,9 @@ def quantum_memory_ops(
|
|
| 127 |
results.append(f"\nArtistic Visualization:")
|
| 128 |
results.append(f"Prompt: {prompt}")
|
| 129 |
results.append(f"Seed: {seed}")
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
return "\n".join(results), wave_viz, art_viz
|
| 132 |
|
|
|
|
| 3 |
import torch
|
| 4 |
import numpy as np
|
| 5 |
from typing import Tuple, List
|
|
|
|
| 6 |
import random
|
| 7 |
|
| 8 |
+
# Try importing Stable Diffusion dependencies
|
| 9 |
+
try:
|
| 10 |
+
from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler
|
| 11 |
+
STABLE_DIFFUSION_AVAILABLE = True
|
| 12 |
+
except ImportError:
|
| 13 |
+
print("Warning: diffusers package not available. Artistic visualization will be disabled.")
|
| 14 |
+
STABLE_DIFFUSION_AVAILABLE = False
|
| 15 |
|
| 16 |
+
# Initialize Stable Diffusion only if available
|
| 17 |
+
pipe = None
|
| 18 |
+
if STABLE_DIFFUSION_AVAILABLE:
|
| 19 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 20 |
+
model_repo_id = "tensorart/stable-diffusion-3.5-large-TurboX"
|
| 21 |
+
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
| 25 |
+
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained(model_repo_id, subfolder="scheduler", shift=5)
|
| 26 |
+
pipe = pipe.to(device)
|
| 27 |
+
except Exception as e:
|
| 28 |
+
print(f"Warning: Could not initialize Stable Diffusion: {e}")
|
| 29 |
+
STABLE_DIFFUSION_AVAILABLE = False
|
| 30 |
|
| 31 |
MAX_SEED = np.iinfo(np.int32).max
|
| 32 |
|
|
|
|
| 120 |
results.append(f"Device: {wave.device}")
|
| 121 |
|
| 122 |
# Generate artistic visualization if requested
|
| 123 |
+
if generate_art and STABLE_DIFFUSION_AVAILABLE and pipe is not None:
|
| 124 |
prompt = generate_memory_prompt(operation, emotion_valence)
|
| 125 |
generator = torch.Generator().manual_seed(seed)
|
| 126 |
art_viz = pipe(
|
|
|
|
| 136 |
results.append(f"\nArtistic Visualization:")
|
| 137 |
results.append(f"Prompt: {prompt}")
|
| 138 |
results.append(f"Seed: {seed}")
|
| 139 |
+
elif generate_art:
|
| 140 |
+
results.append(f"\nArtistic Visualization:")
|
| 141 |
+
results.append(f"Not available - Stable Diffusion could not be initialized")
|
| 142 |
|
| 143 |
return "\n".join(results), wave_viz, art_viz
|
| 144 |
|