acidtib commited on
Commit
41d92c9
1 Parent(s): 8e27089

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -1,19 +1,21 @@
1
  import gradio as gr
2
  from transformers import pipeline
 
3
 
4
  pipeline = pipeline(task="image-classification", model="acidtib/tcg-magic-cards")
5
 
 
 
6
  def predict(input_img):
7
  predictions = pipeline(input_img)
8
  return input_img, {p["label"]: p["score"] for p in predictions}
9
-
10
  gradio_app = gr.Interface(
11
  predict,
12
- inputs=gr.Image(label="Select Magic Card", sources=['upload', 'webcam'], type="pil"),
13
  outputs=gr.Label(label="Result", num_top_classes=2),
 
14
  title="TCG Magic Classifier",
15
- description='This classifier returns the id of cards from scryfall!'
16
  )
17
 
18
- if __name__ == "__main__":
19
- gradio_app.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ from pathlib import Path
4
 
5
  pipeline = pipeline(task="image-classification", model="acidtib/tcg-magic-cards")
6
 
7
+ sample_img_paths = [str(p) for p in Path('./samples').glob('*.png')]
8
+
9
  def predict(input_img):
10
  predictions = pipeline(input_img)
11
  return input_img, {p["label"]: p["score"] for p in predictions}
 
12
  gradio_app = gr.Interface(
13
  predict,
14
+ inputs=gr.inputs.Image(label="Select Magic Card", type="pil"),
15
  outputs=gr.Label(label="Result", num_top_classes=2),
16
+ examples=sample_img_paths,
17
  title="TCG Magic Classifier",
18
+ description='This classifier returns the id of cards from scryfall!, try one of the samples below'
19
  )
20
 
21
+ if __name__ == "__main__":