Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ model_path = hf_hub_download(repo_id="canadianjosieharrison/texture-logistic-mod
|
|
| 15 |
classifier = joblib.load(model_path) # Make sure this exists
|
| 16 |
|
| 17 |
# Create label map
|
| 18 |
-
id2label = {
|
| 19 |
|
| 20 |
# Prediction function
|
| 21 |
def classify_image(img: Image.Image):
|
|
@@ -27,15 +27,16 @@ def classify_image(img: Image.Image):
|
|
| 27 |
|
| 28 |
# Step 2: Predict using classifier
|
| 29 |
prediction = classifier.predict(embedding)
|
| 30 |
-
return f"Predicted Material: {prediction[0]}"
|
| 31 |
|
| 32 |
# Gradio interface
|
| 33 |
interface = gr.Interface(
|
| 34 |
fn=classify_image,
|
| 35 |
inputs=gr.Image(type="pil"),
|
| 36 |
outputs="text",
|
| 37 |
-
title="
|
| 38 |
-
description="
|
|
|
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
|
|
|
| 15 |
classifier = joblib.load(model_path) # Make sure this exists
|
| 16 |
|
| 17 |
# Create label map
|
| 18 |
+
id2label = {0:"metal", 1:"stone", 2:"wood"}
|
| 19 |
|
| 20 |
# Prediction function
|
| 21 |
def classify_image(img: Image.Image):
|
|
|
|
| 27 |
|
| 28 |
# Step 2: Predict using classifier
|
| 29 |
prediction = classifier.predict(embedding)
|
| 30 |
+
return f"Predicted Material: {id2label[prediction[0]]}"
|
| 31 |
|
| 32 |
# Gradio interface
|
| 33 |
interface = gr.Interface(
|
| 34 |
fn=classify_image,
|
| 35 |
inputs=gr.Image(type="pil"),
|
| 36 |
outputs="text",
|
| 37 |
+
title="Material texture image classifier",
|
| 38 |
+
description="Upload a detail texture image of a material and the model will predict whether it's metal, stone, or wood.",
|
| 39 |
+
examples = ["metal.PNG", "stone.PNG", "wood.PNG"],
|
| 40 |
)
|
| 41 |
|
| 42 |
if __name__ == "__main__":
|