Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +4 -0
- app/core/model_manager.py +17 -4
Dockerfile
CHANGED
|
@@ -72,6 +72,9 @@ RUN mkdir -p /app/models/pretrained \
|
|
| 72 |
/app/logs \
|
| 73 |
/app/config
|
| 74 |
|
|
|
|
|
|
|
|
|
|
| 75 |
# Save default model configs (restored at runtime if dirs are empty)
|
| 76 |
RUN mkdir -p /opt/fragmenta-defaults/models/config \
|
| 77 |
&& if [ -d /app/models/config ] && ls /app/models/config/*.json 1>/dev/null 2>&1; then \
|
|
@@ -95,6 +98,7 @@ ENV FLASK_HOST=0.0.0.0
|
|
| 95 |
ENV FLASK_PORT=7860
|
| 96 |
ENV FRAGMENTA_LOG_LEVEL=INFO
|
| 97 |
ENV FRAGMENTA_DOCKER=1
|
|
|
|
| 98 |
ENV HOME=/home/user
|
| 99 |
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 100 |
ENV OMP_NUM_THREADS=4
|
|
|
|
| 72 |
/app/logs \
|
| 73 |
/app/config
|
| 74 |
|
| 75 |
+
# Clone fragmenta-models repo into /app/models/pretrained
|
| 76 |
+
RUN git clone https://huggingface.co/MazCodes/fragmenta-models /app/models/pretrained 2>/dev/null || true
|
| 77 |
+
|
| 78 |
# Save default model configs (restored at runtime if dirs are empty)
|
| 79 |
RUN mkdir -p /opt/fragmenta-defaults/models/config \
|
| 80 |
&& if [ -d /app/models/config ] && ls /app/models/config/*.json 1>/dev/null 2>&1; then \
|
|
|
|
| 98 |
ENV FLASK_PORT=7860
|
| 99 |
ENV FRAGMENTA_LOG_LEVEL=INFO
|
| 100 |
ENV FRAGMENTA_DOCKER=1
|
| 101 |
+
ENV FRAGMENTA_USE_CUSTOM_MODELS=true
|
| 102 |
ENV HOME=/home/user
|
| 103 |
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 104 |
ENV OMP_NUM_THREADS=4
|
app/core/model_manager.py
CHANGED
|
@@ -16,11 +16,24 @@ class ModelManager:
|
|
| 16 |
self.models_dir = config.get_path("models_pretrained")
|
| 17 |
self.models_dir.mkdir(exist_ok=True, parents=True)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
self.available_models = {
|
| 20 |
'stable-audio-open-small': {
|
| 21 |
'name': 'Stable Audio Open Small',
|
| 22 |
-
'repo':
|
| 23 |
-
'files': [
|
| 24 |
'size': '2.1 GB',
|
| 25 |
'description': 'Fast generation, good quality, lower memory usage',
|
| 26 |
'best_for': 'Beginners, quick experiments, limited GPU',
|
|
@@ -29,8 +42,8 @@ class ModelManager:
|
|
| 29 |
},
|
| 30 |
'stable-audio-open-1.0': {
|
| 31 |
'name': 'Stable Audio Open 1.0',
|
| 32 |
-
'repo':
|
| 33 |
-
'files': [
|
| 34 |
'size': '8.2 GB',
|
| 35 |
'description': 'Highest quality, more detailed audio',
|
| 36 |
'best_for': 'Professional use, high-end GPUs',
|
|
|
|
| 16 |
self.models_dir = config.get_path("models_pretrained")
|
| 17 |
self.models_dir.mkdir(exist_ok=True, parents=True)
|
| 18 |
|
| 19 |
+
# Use fragmenta-models repo on HF Spaces, Stability AI models elsewhere
|
| 20 |
+
use_custom_repo = os.getenv('FRAGMENTA_USE_CUSTOM_MODELS', '').lower() == 'true'
|
| 21 |
+
|
| 22 |
+
if use_custom_repo:
|
| 23 |
+
models_repo = 'MazCodes/fragmenta-models'
|
| 24 |
+
small_file = 'stable-audio-open-small-model.safetensors'
|
| 25 |
+
large_file = 'stable-audio-open-model.safetensors'
|
| 26 |
+
else:
|
| 27 |
+
models_repo_small = 'stabilityai/stable-audio-open-small'
|
| 28 |
+
models_repo_large = 'stabilityai/stable-audio-open-1.0'
|
| 29 |
+
small_file = 'model.safetensors'
|
| 30 |
+
large_file = 'model.safetensors'
|
| 31 |
+
|
| 32 |
self.available_models = {
|
| 33 |
'stable-audio-open-small': {
|
| 34 |
'name': 'Stable Audio Open Small',
|
| 35 |
+
'repo': models_repo if use_custom_repo else models_repo_small,
|
| 36 |
+
'files': [small_file],
|
| 37 |
'size': '2.1 GB',
|
| 38 |
'description': 'Fast generation, good quality, lower memory usage',
|
| 39 |
'best_for': 'Beginners, quick experiments, limited GPU',
|
|
|
|
| 42 |
},
|
| 43 |
'stable-audio-open-1.0': {
|
| 44 |
'name': 'Stable Audio Open 1.0',
|
| 45 |
+
'repo': models_repo if use_custom_repo else models_repo_large,
|
| 46 |
+
'files': [large_file],
|
| 47 |
'size': '8.2 GB',
|
| 48 |
'description': 'Highest quality, more detailed audio',
|
| 49 |
'best_for': 'Professional use, high-end GPUs',
|