canadianjosieharrison commited on
Commit
0292ce3
·
verified ·
1 Parent(s): ee7abbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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 = {"0":"metal", "1":"stone", "2":"wood"}
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="Image Classifier with Embedding Pipeline",
38
- description="Uses a ViT transformer to generate image embeddings, then classifies them using a trained model."
 
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__":