Spaces:
Sleeping
Sleeping
root
commited on
Commit
·
f709fa8
1
Parent(s):
77b9e27
Fix bug in gradio
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ def classifyArchitecture(img):
|
|
7 |
classifier = AutoModelForImageClassification.from_pretrained("hanslab37/architectural_styles_classifier")
|
8 |
|
9 |
# Transform our image and pass it through the model
|
10 |
-
inputs = image_processor(
|
11 |
output = classifier(**inputs)
|
12 |
|
13 |
# Display the image
|
@@ -18,13 +18,8 @@ def classifyArchitecture(img):
|
|
18 |
preds = proba.argmax(1)
|
19 |
|
20 |
result = f'Predicted Architectural Styles: {classifier.config.id2label[preds.item()]} (Confidence: {proba[0][preds.item()].item()})'
|
21 |
-
|
22 |
-
# score: {0},
|
23 |
-
# label: {1}
|
24 |
-
# }
|
25 |
-
# '''.format(proba[0][preds.item()].item(), classifier.config.id2label[preds.item()])
|
26 |
-
# epred = "Label: {0}, Score: {1}".format(classifier.config.id2label[i], proba[0][i].item())
|
27 |
return result
|
28 |
|
29 |
-
page = gr.Interface(fn=classifyArchitecture, inputs="image", outputs="text")
|
30 |
page.launch()
|
|
|
7 |
classifier = AutoModelForImageClassification.from_pretrained("hanslab37/architectural_styles_classifier")
|
8 |
|
9 |
# Transform our image and pass it through the model
|
10 |
+
inputs = image_processor(img, return_tensors="pt")
|
11 |
output = classifier(**inputs)
|
12 |
|
13 |
# Display the image
|
|
|
18 |
preds = proba.argmax(1)
|
19 |
|
20 |
result = f'Predicted Architectural Styles: {classifier.config.id2label[preds.item()]} (Confidence: {proba[0][preds.item()].item()})'
|
21 |
+
|
|
|
|
|
|
|
|
|
|
|
22 |
return result
|
23 |
|
24 |
+
page = gr.Interface(fn=classifyArchitecture, inputs="image", outputs="text", title="Classify Architecture Styles",)
|
25 |
page.launch()
|