Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,15 +23,18 @@ print(predicted_labels)
|
|
23 |
|
24 |
labels = []
|
25 |
def predict(img):
|
26 |
-
|
27 |
|
28 |
-
|
|
|
|
|
29 |
logits = model(**inputs)['logits'].cpu().detach().numpy()
|
30 |
-
predictions = np.argmax(logits, axis=1)
|
31 |
predicted_labels = [labels[prediction] for prediction in predictions]
|
|
|
32 |
|
33 |
|
34 |
-
return {"
|
35 |
|
36 |
title = "Geometric Shape Classifier"
|
37 |
description = "A geometric shape setector."
|
|
|
23 |
|
24 |
labels = []
|
25 |
def predict(img):
|
26 |
+
image = PILImage.create(img)
|
27 |
|
28 |
+
feature_extractor = AutoImageProcessor.from_pretrained('0-ma/vit-geometric-shapes-tiny')
|
29 |
+
model = AutoModelForImageClassification.from_pretrained('0-ma/vit-geometric-shapes-tiny')
|
30 |
+
inputs = feature_extractor(images=[image], return_tensors="pt")
|
31 |
logits = model(**inputs)['logits'].cpu().detach().numpy()
|
32 |
+
predictions = np.argmax(logits, axis=1)
|
33 |
predicted_labels = [labels[prediction] for prediction in predictions]
|
34 |
+
print(predicted_labels[0],logits[0][predictions[0]])
|
35 |
|
36 |
|
37 |
+
return {"predicted_label" : predicted_labels[0] }
|
38 |
|
39 |
title = "Geometric Shape Classifier"
|
40 |
description = "A geometric shape setector."
|