Spaces:
Sleeping
Sleeping
App.py revision 2
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import torch
|
|
6 |
model = ViTForImageClassification.from_pretrained('sreeramajay/pollution')
|
7 |
transforms = ViTFeatureExtractor.from_pretrained('sreeramajay/pollution')
|
8 |
|
9 |
-
def
|
10 |
labels = {0:"Air Pollution", 1: "Land Pollution" , 2: "Water Pollution"}
|
11 |
inputs = transforms(image, return_tensors='pt')
|
12 |
output = model(**inputs)
|
@@ -15,9 +15,9 @@ def predict(image):
|
|
15 |
return {labels[i.item()]: v.item() for i, v in zip(indices.numpy()[0], values.detach().numpy()[0])}
|
16 |
|
17 |
|
18 |
-
gr.Interface(
|
19 |
-
predict,
|
20 |
inputs = gr.inputs.Image(type="pil", label="Chosen Image"),
|
21 |
outputs = 'label',
|
|
|
22 |
theme="seafoam",
|
23 |
).launch(debug=True)
|
|
|
6 |
model = ViTForImageClassification.from_pretrained('sreeramajay/pollution')
|
7 |
transforms = ViTFeatureExtractor.from_pretrained('sreeramajay/pollution')
|
8 |
|
9 |
+
def polln_classify(image):
|
10 |
labels = {0:"Air Pollution", 1: "Land Pollution" , 2: "Water Pollution"}
|
11 |
inputs = transforms(image, return_tensors='pt')
|
12 |
output = model(**inputs)
|
|
|
15 |
return {labels[i.item()]: v.item() for i, v in zip(indices.numpy()[0], values.detach().numpy()[0])}
|
16 |
|
17 |
|
18 |
+
gr.Interface(polln_classify,
|
|
|
19 |
inputs = gr.inputs.Image(type="pil", label="Chosen Image"),
|
20 |
outputs = 'label',
|
21 |
+
examples = ["air_pollution.jpg","land_pollution.jpg","water_pollution.jpg"],
|
22 |
theme="seafoam",
|
23 |
).launch(debug=True)
|