Spaces:
Build error
Build error
first version
Browse files- .gitattributes +1 -0
- acoustic.jpg +0 -0
- app.py +32 -4
- fly.jpeg +0 -0
- guitar_classifier_model.pkl +3 -0
- lespaul.jpeg +0 -0
- sg.jpg +0 -0
- strat.jpg +0 -0
- telecaster.jpg +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
.pkl filter=lfs diff=lfs merge=lfs -text
|
acoustic.jpg
ADDED
|
app.py
CHANGED
|
@@ -1,7 +1,35 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
from fastcore.all import *
|
| 4 |
+
from fastdownload import download_url
|
| 5 |
+
from PIL import Image
|
| 6 |
|
| 7 |
+
learn = load_learner("/kaggle/input/guitar-classifier/pytorch/gc-1/1/guitar_classifier_model.pkl")
|
|
|
|
| 8 |
|
| 9 |
+
def predict(image):
|
| 10 |
+
# Ensure the image is a PIL image (if not already)
|
| 11 |
+
if not isinstance(image, Image.Image):
|
| 12 |
+
image = Image.fromarray(image)
|
| 13 |
+
# Resize the image to (192, 192)
|
| 14 |
+
image = image.resize((192, 192))
|
| 15 |
+
# Predict
|
| 16 |
+
pred, idx, probs = learn.predict(image)
|
| 17 |
+
return dict(zip(categories, map(float, probs)))
|
| 18 |
+
|
| 19 |
+
# Remove the 'shape' parameter from gr.Image
|
| 20 |
+
image_component = gr.Image(type="pil")
|
| 21 |
+
label_component = gr.Label()
|
| 22 |
+
|
| 23 |
+
# Example images (ensure these files are available)
|
| 24 |
+
examples = ["acoustic.jpg", "fly.jpeg", "lespaul.jpeg", "sg.jpg" "strat.jpg", "telecaster.jpg"]
|
| 25 |
+
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=predict,
|
| 28 |
+
inputs=image_component,
|
| 29 |
+
outputs=label_component,
|
| 30 |
+
examples=examples,
|
| 31 |
+
title="Guitar Classifier",
|
| 32 |
+
description="Upload a guitar image to get a prediction.",
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
iface.launch()
|
fly.jpeg
ADDED
|
guitar_classifier_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9930f70f71609bc392be340a65536b4be01b18112d37c9a9f0e0fb59cac2128b
|
| 3 |
+
size 47003084
|
lespaul.jpeg
ADDED
|
sg.jpg
ADDED
|
strat.jpg
ADDED
|
telecaster.jpg
ADDED
|