Spaces:
Running
Running
gallery fix
Browse files- .DS_Store +0 -0
- app.py +14 -0
- app/.DS_Store +0 -0
- app/core/pipeline.py +31 -6
- app/llm/.DS_Store +0 -0
- app/ui/app.py +29 -5
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
app.py
CHANGED
@@ -26,6 +26,20 @@ os.environ["HTTPX_VERIFY"] = "0"
|
|
26 |
os.environ["UI_PORT"] = "7860" # Standard Spaces port
|
27 |
os.environ["HF_SPACES"] = "1" # Flag to indicate we're running in Spaces
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
# Set model environment variables explicitly for Hugging Face Spaces
|
30 |
# These will override any variables loaded from .env.spaces
|
31 |
os.environ["MODEL_ID"] = (
|
|
|
26 |
os.environ["UI_PORT"] = "7860" # Standard Spaces port
|
27 |
os.environ["HF_SPACES"] = "1" # Flag to indicate we're running in Spaces
|
28 |
|
29 |
+
# Configure persistent data directory for Spaces
|
30 |
+
# Use /home/user/app/data for persistent storage in Hugging Face Spaces
|
31 |
+
persistent_data_dir = "/home/user/app/data"
|
32 |
+
os.environ["DATA_DIR"] = persistent_data_dir # This is critical for gallery to work
|
33 |
+
os.environ["IMAGE_OUTPUT_DIR"] = f"{persistent_data_dir}/images"
|
34 |
+
os.environ["MODEL_OUTPUT_DIR"] = f"{persistent_data_dir}/models"
|
35 |
+
logger.info(f"Set persistent data directory to {persistent_data_dir}")
|
36 |
+
|
37 |
+
# Create directories if they don't exist
|
38 |
+
for subdir in ["", "images", "models", "downloads"]:
|
39 |
+
dir_path = f"{persistent_data_dir}/{subdir}" if subdir else persistent_data_dir
|
40 |
+
os.makedirs(dir_path, exist_ok=True)
|
41 |
+
logger.info(f"Ensured directory exists: {dir_path}")
|
42 |
+
|
43 |
# Set model environment variables explicitly for Hugging Face Spaces
|
44 |
# These will override any variables loaded from .env.spaces
|
45 |
os.environ["MODEL_ID"] = (
|
app/.DS_Store
CHANGED
Binary files a/app/.DS_Store and b/app/.DS_Store differ
|
|
app/core/pipeline.py
CHANGED
@@ -116,17 +116,42 @@ class CreativePipeline:
|
|
116 |
logger.info(f"Initializing ImageTo3DGenerator with app_id: {i2m_app_id}")
|
117 |
self.image_to_3d = ImageTo3DGenerator(stub, app_id=i2m_app_id)
|
118 |
|
119 |
-
# Get directory paths based on environment or defaults
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
else:
|
|
|
124 |
data_dir = Path(__file__).parent.parent / "data"
|
|
|
125 |
|
126 |
# Ensure app/data directories exist
|
127 |
data_dir.mkdir(exist_ok=True)
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
(data_dir / "downloads").mkdir(exist_ok=True)
|
131 |
|
132 |
logger.info("Creative pipeline initialized successfully")
|
|
|
116 |
logger.info(f"Initializing ImageTo3DGenerator with app_id: {i2m_app_id}")
|
117 |
self.image_to_3d = ImageTo3DGenerator(stub, app_id=i2m_app_id)
|
118 |
|
119 |
+
# Get directory paths based on environment variables or defaults
|
120 |
+
# First check for specific environment variables
|
121 |
+
if os.environ.get("DATA_DIR"):
|
122 |
+
# Use persistent data directory from environment
|
123 |
+
data_dir = Path(os.environ.get("DATA_DIR"))
|
124 |
+
logger.info(f"Using DATA_DIR environment variable: {data_dir}")
|
125 |
+
elif spaces_mode:
|
126 |
+
# Use persistent location for Hugging Face Spaces
|
127 |
+
data_dir = Path("/home/user/app/data")
|
128 |
+
logger.info(f"Using persistent storage in Spaces: {data_dir}")
|
129 |
else:
|
130 |
+
# Fall back to default local path
|
131 |
data_dir = Path(__file__).parent.parent / "data"
|
132 |
+
logger.info(f"Using default local data path: {data_dir}")
|
133 |
|
134 |
# Ensure app/data directories exist
|
135 |
data_dir.mkdir(exist_ok=True)
|
136 |
+
|
137 |
+
# Use specific output directories if provided in environment variables
|
138 |
+
if os.environ.get("IMAGE_OUTPUT_DIR"):
|
139 |
+
images_dir = Path(os.environ.get("IMAGE_OUTPUT_DIR"))
|
140 |
+
logger.info(f"Using IMAGE_OUTPUT_DIR from environment: {images_dir}")
|
141 |
+
else:
|
142 |
+
images_dir = data_dir / "images"
|
143 |
+
logger.info(f"Using default images directory: {images_dir}")
|
144 |
+
|
145 |
+
if os.environ.get("MODEL_OUTPUT_DIR"):
|
146 |
+
models_dir = Path(os.environ.get("MODEL_OUTPUT_DIR"))
|
147 |
+
logger.info(f"Using MODEL_OUTPUT_DIR from environment: {models_dir}")
|
148 |
+
else:
|
149 |
+
models_dir = data_dir / "models"
|
150 |
+
logger.info(f"Using default models directory: {models_dir}")
|
151 |
+
|
152 |
+
# Create subdirectories
|
153 |
+
images_dir.mkdir(exist_ok=True)
|
154 |
+
models_dir.mkdir(exist_ok=True)
|
155 |
(data_dir / "downloads").mkdir(exist_ok=True)
|
156 |
|
157 |
logger.info("Creative pipeline initialized successfully")
|
app/llm/.DS_Store
CHANGED
Binary files a/app/llm/.DS_Store and b/app/llm/.DS_Store differ
|
|
app/ui/app.py
CHANGED
@@ -60,19 +60,43 @@ IMAGE_TO_3D_APP_ID = os.environ.get(
|
|
60 |
def main():
|
61 |
"""AI Creative application interface"""
|
62 |
|
63 |
-
# Paths for saving generated content -
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
else:
|
67 |
data_path = Path(__file__).parent.parent / "data"
|
|
|
68 |
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# Ensure necessary directories exist
|
73 |
images_path.mkdir(exist_ok=True, parents=True)
|
74 |
models_path.mkdir(exist_ok=True, parents=True)
|
75 |
|
|
|
|
|
|
|
76 |
# Initialize pipeline only if modules are available
|
77 |
pipeline = None
|
78 |
if CORE_MODULES_AVAILABLE:
|
|
|
60 |
def main():
|
61 |
"""AI Creative application interface"""
|
62 |
|
63 |
+
# Paths for saving generated content - prefer environment variable for persistent storage
|
64 |
+
data_path = None
|
65 |
+
|
66 |
+
# Check for DATA_DIR environment variable first (set in the app.py entry point)
|
67 |
+
if os.environ.get("DATA_DIR"):
|
68 |
+
data_path = Path(os.environ.get("DATA_DIR"))
|
69 |
+
logger.info(f"Using DATA_DIR environment variable: {data_path}")
|
70 |
+
# Fall back to default paths otherwise
|
71 |
+
elif RUNNING_IN_SPACES:
|
72 |
+
data_path = Path("/home/user/app/data") # Persistent storage in Spaces
|
73 |
+
logger.info(f"Using persistent storage in Spaces: {data_path}")
|
74 |
else:
|
75 |
data_path = Path(__file__).parent.parent / "data"
|
76 |
+
logger.info(f"Using default local data path: {data_path}")
|
77 |
|
78 |
+
# Use environment variables for image and model output dirs if specified
|
79 |
+
if os.environ.get("IMAGE_OUTPUT_DIR"):
|
80 |
+
images_path = Path(os.environ.get("IMAGE_OUTPUT_DIR"))
|
81 |
+
logger.info(f"Using IMAGE_OUTPUT_DIR from environment: {images_path}")
|
82 |
+
else:
|
83 |
+
images_path = data_path / "images"
|
84 |
+
logger.info(f"Using default images path: {images_path}")
|
85 |
+
|
86 |
+
if os.environ.get("MODEL_OUTPUT_DIR"):
|
87 |
+
models_path = Path(os.environ.get("MODEL_OUTPUT_DIR"))
|
88 |
+
logger.info(f"Using MODEL_OUTPUT_DIR from environment: {models_path}")
|
89 |
+
else:
|
90 |
+
models_path = data_path / "models"
|
91 |
+
logger.info(f"Using default models path: {models_path}")
|
92 |
|
93 |
# Ensure necessary directories exist
|
94 |
images_path.mkdir(exist_ok=True, parents=True)
|
95 |
models_path.mkdir(exist_ok=True, parents=True)
|
96 |
|
97 |
+
logger.info(f"Image gallery path: {images_path}")
|
98 |
+
logger.info(f"Model gallery path: {models_path}")
|
99 |
+
|
100 |
# Initialize pipeline only if modules are available
|
101 |
pipeline = None
|
102 |
if CORE_MODULES_AVAILABLE:
|