gbryan commited on
Commit
c9b3fda
1 Parent(s): 5815b4c
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -1,14 +1,6 @@
1
- from transformers import ViTForImageClassification, ViTFeatureExtractor
2
- from PIL import Image
3
- import torch
4
 
5
- # Loading in Model
6
- device = "cuda" if torch.cuda.is_available() else "cpu"
7
- model = ViTForImageClassification.from_pretrained( "imjeffhi/pokemon_classifier").to(device)
8
- feature_extractor = ViTFeatureExtractor.from_pretrained('imjeffhi/pokemon_classifier')
9
 
10
- # Caling the model on a test image
11
- img = Image.open('test.jpg')
12
- extracted = feature_extractor(images=img, return_tensors='pt').to(device)
13
- predicted_id = model(**extracted).logits.argmax(-1).item()
14
- predicted_pokemon = model.config.id2label[predicted_id]
 
1
+ import gradio as gr
2
+ from transformers import pipeline
 
3
 
4
+ pipe = pipeline(task="image-classification", model="microsoft/beit-base-patch16-224-pt22k-ft22k")
 
 
 
5
 
6
+ gr.Interface.from_pipeline(pipe, title="22k Image Classification", description="Object Recognition using Microsoft BEIT", examples = ['wonder_cat.jpg', 'aki_dog.jpg',], allow_flagging="never").launch(inbrowser=True)