Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,8 @@ model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
|
|
11 |
|
12 |
def predict(image):
|
13 |
inputs = feature_extractor(images=image, return_tensors="pt").to(device)
|
14 |
-
outputs = model(**inputs)
|
15 |
-
logits = outputs.logits
|
16 |
predicted_class_prob = F.softmax(logits, dim=-1).detach().numpy().max()
|
17 |
predicted_class_idx = logits.argmax(-1).item()
|
18 |
label = model.config.id2label[predicted_class_idx].split(",")[0]
|
|
|
11 |
|
12 |
def predict(image):
|
13 |
inputs = feature_extractor(images=image, return_tensors="pt").to(device)
|
14 |
+
outputs = model(**inputs)
|
15 |
+
logits = outputs.logits
|
16 |
predicted_class_prob = F.softmax(logits, dim=-1).detach().numpy().max()
|
17 |
predicted_class_idx = logits.argmax(-1).item()
|
18 |
label = model.config.id2label[predicted_class_idx].split(",")[0]
|