fender70 commited on
Commit
e72162f
·
1 Parent(s): 539900a

first version

Browse files
Files changed (9) hide show
  1. .gitattributes +1 -0
  2. acoustic.jpg +0 -0
  3. app.py +32 -4
  4. fly.jpeg +0 -0
  5. guitar_classifier_model.pkl +3 -0
  6. lespaul.jpeg +0 -0
  7. sg.jpg +0 -0
  8. strat.jpg +0 -0
  9. 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
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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