Update app.py
Browse files
app.py
CHANGED
@@ -6,10 +6,10 @@ feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/dit-base-fin
|
|
6 |
model = AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip")
|
7 |
|
8 |
def classify_image(image):
|
9 |
-
|
10 |
|
11 |
with torch.no_grad():
|
12 |
-
outputs = model(
|
13 |
logits = outputs.logits
|
14 |
|
15 |
predicted_class = model.config.id2label[logits.argmax(-1).item()]
|
|
|
6 |
model = AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip")
|
7 |
|
8 |
def classify_image(image):
|
9 |
+
encoding = feature_extractor(image, return_tensors="pt")
|
10 |
|
11 |
with torch.no_grad():
|
12 |
+
outputs = model(**encoding)
|
13 |
logits = outputs.logits
|
14 |
|
15 |
predicted_class = model.config.id2label[logits.argmax(-1).item()]
|