Spaces:
Sleeping
Sleeping
Download app.py from Kashi-Kumari/Manufacturing_Defect: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/Kashi-Kumari/Manufacturing_Defect/resolve/main/app.py
- Command line
-
hf download hf://spaces/Kashi-Kumari/Manufacturing_Defect/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Kashi-Kumari/Manufacturing_Defect/resolve/main/app.py
1.32 kB
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # Load model | |
| model = joblib.load("model.pkl") | |
| scaler = joblib.load("scaler.pkl") | |
| def predict(*inputs): | |
| data = np.array(inputs).reshape(1, -1) | |
| data = scaler.transform(data) | |
| pred = model.predict(data)[0] | |
| return "Defective" if pred == 1 else "Not Defective" | |
| interface = gr.Interface( | |
| fn=predict, | |
| inputs=[ | |
| gr.Number(label="Maintenance Hours"), | |
| gr.Number(label="Defect Rate"), | |
| gr.Number(label="Quality Score"), | |
| gr.Number(label="Production Volume"), | |
| gr.Number(label="Additive Material Cost"), | |
| gr.Number(label="Stockout Rate"), | |
| gr.Number(label="Energy Efficiency"), | |
| gr.Number(label="Inventory Turnover"), | |
| gr.Number(label="Production Cost"), | |
| gr.Number(label="Energy Consumption"), | |
| gr.Number(label="Downtime Percentage"), | |
| gr.Number(label="Supplier Quality"), | |
| gr.Number(label="Additive Process Time"), | |
| gr.Number(label="Worker Productivity"), | |
| gr.Number(label="Safety Incidents"), | |
| gr.Number(label="Delivery Delay"), | |
| ], | |
| outputs="text", | |
| title="Manufacturing Defect Prediction", | |
| description="Enter production parameters to predict defect status" | |
| ) | |
| interface.launch(server_name="0.0.0.0", server_port=7860) |