Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +3 -1
- README.md +14 -2
- app.py +2 -4
- deploy.py +30 -0
- requirements.txt +0 -2
Dockerfile
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
-
|
| 2 |
FROM python:3.10-slim
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
COPY requirements.txt .
|
| 5 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 6 |
COPY app.py .
|
|
|
|
| 7 |
EXPOSE 7860
|
| 8 |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
WORKDIR /app
|
| 4 |
COPY requirements.txt .
|
| 5 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 6 |
+
|
| 7 |
COPY app.py .
|
| 8 |
+
|
| 9 |
EXPOSE 7860
|
| 10 |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
README.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
-
|
| 3 |
|
| 4 |
-
Streamlit
|
| 5 |
|
| 6 |
Author: Sharley Kulkarni
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
---
|
| 3 |
+
title: Predictive Maintenance
|
| 4 |
+
emoji: 🔧
|
| 5 |
+
colorFrom: blue
|
| 6 |
+
colorTo: green
|
| 7 |
+
sdk: docker
|
| 8 |
+
python_version: "3.10"
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
---
|
| 12 |
|
| 13 |
+
## Predictive Maintenance – Engine Failure Prediction
|
| 14 |
|
| 15 |
+
Streamlit app deployed on **Hugging Face Spaces** using Docker.
|
| 16 |
|
| 17 |
Author: Sharley Kulkarni
|
| 18 |
+
|
app.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
-
import numpy as np
|
| 5 |
import joblib
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
|
|
@@ -36,9 +34,9 @@ if st.button("Predict"):
|
|
| 36 |
}])
|
| 37 |
|
| 38 |
X_scaled = scaler.transform(X)
|
| 39 |
-
|
| 40 |
|
| 41 |
-
if
|
| 42 |
st.error("Engine Failure Detected")
|
| 43 |
else:
|
| 44 |
st.success("Engine Operating Normally")
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
import joblib
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
|
|
|
|
| 34 |
}])
|
| 35 |
|
| 36 |
X_scaled = scaler.transform(X)
|
| 37 |
+
pred = model.predict(X_scaled)[0]
|
| 38 |
|
| 39 |
+
if pred == 1:
|
| 40 |
st.error("Engine Failure Detected")
|
| 41 |
else:
|
| 42 |
st.success("Engine Operating Normally")
|
deploy.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import HfApi, login
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
HF_USERNAME = "SharleyK"
|
| 5 |
+
SPACE_NAME = "PredictiveMaintenance"
|
| 6 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 7 |
+
|
| 8 |
+
if not HF_TOKEN:
|
| 9 |
+
raise RuntimeError("HF_TOKEN environment variable not set")
|
| 10 |
+
|
| 11 |
+
login(token=HF_TOKEN)
|
| 12 |
+
api = HfApi()
|
| 13 |
+
|
| 14 |
+
repo_id = f"{HF_USERNAME}/{SPACE_NAME}"
|
| 15 |
+
|
| 16 |
+
api.create_repo(
|
| 17 |
+
repo_id=repo_id,
|
| 18 |
+
repo_type="space",
|
| 19 |
+
space_sdk="docker",
|
| 20 |
+
exist_ok=True
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
api.upload_folder(
|
| 24 |
+
folder_path=".",
|
| 25 |
+
repo_id=repo_id,
|
| 26 |
+
repo_type="space"
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
print("Deployment successful!")
|
| 30 |
+
print(f"https://huggingface.co/spaces/{HF_USERNAME}/{SPACE_NAME}")
|
requirements.txt
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
-
|
| 2 |
streamlit
|
| 3 |
pandas
|
| 4 |
numpy
|
| 5 |
scikit-learn
|
| 6 |
joblib
|
| 7 |
huggingface-hub
|
| 8 |
-
sdk: docker
|
|
|
|
|
|
|
| 1 |
streamlit
|
| 2 |
pandas
|
| 3 |
numpy
|
| 4 |
scikit-learn
|
| 5 |
joblib
|
| 6 |
huggingface-hub
|
|
|