Michal2203 commited on
Commit
35ef7f2
verified
1 Parent(s): 4a911b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -1,22 +1,21 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the pipeline once
5
- pipe = pipeline("image-classification", model="google/vit-base-patch16-224")
 
 
6
 
7
- # Define function for Gradio
8
  def classify_image(img):
9
  results = pipe(img)
10
  return {res["label"]: float(res["score"]) for res in results}
11
 
12
- # Gradio interface
13
  demo = gr.Interface(
14
  fn=classify_image,
15
- inputs=gr.Image(type="filepath"), # user uploads/selects image
16
- outputs=gr.Label(num_top_classes=5), # show top 5 predictions with scores
17
- title="Image Classification with ViT",
18
- description="Upload an image (e.g., SHrek.png) and see predicted labels."
19
  )
20
 
21
- # Launch
22
  demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Wybierz l偶ejszy model
5
+ model_name = "facebook/deit-tiny-patch16-224"
6
+
7
+ pipe = pipeline("image-classification", model=model_name)
8
 
 
9
  def classify_image(img):
10
  results = pipe(img)
11
  return {res["label"]: float(res["score"]) for res in results}
12
 
 
13
  demo = gr.Interface(
14
  fn=classify_image,
15
+ inputs=gr.Image(type="filepath"),
16
+ outputs=gr.Label(num_top_classes=5),
17
+ title="Lekka klasyfikacja obraz贸w",
18
+ description=f"Model: {model_name}"
19
  )
20
 
 
21
  demo.launch()