Spaces:
Running
Running
Auto-deploy from GitHub: ffd9fa1fec8ca15ebb48cf1bb9be21334166a6cc
Browse files- Dockerfile +3 -3
- src/musiclime/wrapper.py +9 -2
Dockerfile
CHANGED
|
@@ -32,11 +32,11 @@ RUN python3.11 -m pip install poetry && \
|
|
| 32 |
poetry install --only=main
|
| 33 |
|
| 34 |
# Copy application code
|
| 35 |
-
COPY src/ ./src/
|
| 36 |
-
COPY app/ ./app/
|
| 37 |
-
COPY config/ ./config/
|
| 38 |
COPY models/ ./models/
|
|
|
|
|
|
|
| 39 |
COPY scripts/ ./scripts/
|
|
|
|
| 40 |
|
| 41 |
# Create cache directories with proper permissions
|
| 42 |
RUN mkdir -p /app/.cache/huggingface /app/.cache/torch /tmp/numba_cache && \
|
|
|
|
| 32 |
poetry install --only=main
|
| 33 |
|
| 34 |
# Copy application code
|
|
|
|
|
|
|
|
|
|
| 35 |
COPY models/ ./models/
|
| 36 |
+
COPY config/ ./config/
|
| 37 |
+
COPY app/ ./app/
|
| 38 |
COPY scripts/ ./scripts/
|
| 39 |
+
COPY src/ ./src/
|
| 40 |
|
| 41 |
# Create cache directories with proper permissions
|
| 42 |
RUN mkdir -p /app/.cache/huggingface /app/.cache/torch /tmp/numba_cache && \
|
src/musiclime/wrapper.py
CHANGED
|
@@ -127,14 +127,21 @@ class MusicLIMEPredictor:
|
|
| 127 |
pca_model = joblib.load("models/fusion/pca.pkl")
|
| 128 |
reduced_lyrics_batch = pca_model.transform(scaled_lyrics_batch) # (batch, 512)
|
| 129 |
|
| 130 |
-
# Step 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
combined_features_batch = np.concatenate(
|
| 132 |
[scaled_audio_batch, reduced_lyrics_batch], axis=1
|
| 133 |
) # (batch, sum of lyrics & audio vector dims)
|
| 134 |
scaling_time = time.time() - start_time
|
| 135 |
print(green_bold(f"[MusicLIME] Scaling completed in {scaling_time:.2f}s"))
|
| 136 |
|
| 137 |
-
# Step
|
| 138 |
start_time = time.time()
|
| 139 |
print("[MusicLIME] Running MLP predictions (batch)...")
|
| 140 |
if self.classifier is None:
|
|
|
|
| 127 |
pca_model = joblib.load("models/fusion/pca.pkl")
|
| 128 |
reduced_lyrics_batch = pca_model.transform(scaled_lyrics_batch) # (batch, 512)
|
| 129 |
|
| 130 |
+
# Step 5: Apply scaler to PCA-scaled lyrics batch
|
| 131 |
+
print("[MusicLIME] Reapplying scaler to PCA-scaled batch")
|
| 132 |
+
pca_scaler = joblib.load("models/fusion/pca_scaler.pkl")
|
| 133 |
+
reduced_lyrics_batch = pca_scaler.transform(
|
| 134 |
+
reduced_lyrics_batch
|
| 135 |
+
) # (batch, 512)
|
| 136 |
+
|
| 137 |
+
# Step 6: Concatenate features
|
| 138 |
combined_features_batch = np.concatenate(
|
| 139 |
[scaled_audio_batch, reduced_lyrics_batch], axis=1
|
| 140 |
) # (batch, sum of lyrics & audio vector dims)
|
| 141 |
scaling_time = time.time() - start_time
|
| 142 |
print(green_bold(f"[MusicLIME] Scaling completed in {scaling_time:.2f}s"))
|
| 143 |
|
| 144 |
+
# Step 7: Batch MLP prediction
|
| 145 |
start_time = time.time()
|
| 146 |
print("[MusicLIME] Running MLP predictions (batch)...")
|
| 147 |
if self.classifier is None:
|