Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,16 @@ import torch
|
|
| 5 |
import torch.nn as nn
|
| 6 |
import torchvision.transforms as transforms
|
| 7 |
from utils import preprocess_image
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
# Initialize labels and model
|
| 10 |
labels = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
|
| 11 |
-
|
| 12 |
-
model.
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
# Customized Streamlit layout
|
| 15 |
st.set_page_config(
|
| 16 |
page_title="EcoIdentify by EcoClim Solutions",
|
|
|
|
| 5 |
import torch.nn as nn
|
| 6 |
import torchvision.transforms as transforms
|
| 7 |
from utils import preprocess_image
|
| 8 |
+
import torch
|
| 9 |
+
from transformers import ViTForImageClassification
|
| 10 |
|
|
|
|
| 11 |
labels = ['cardboard', 'glass', 'metal', 'paper', 'plastic', 'trash']
|
| 12 |
+
# Initialize a ViT model
|
| 13 |
+
model = ViTForImageClassification.from_pretrained("facebook/deit-base-distilled-patch16-224")
|
| 14 |
|
| 15 |
+
# Load your weights
|
| 16 |
+
model.load_state_dict(torch.load("best.pt", map_location="cpu"))
|
| 17 |
+
model.eval() # Set to evaluation mode
|
| 18 |
# Customized Streamlit layout
|
| 19 |
st.set_page_config(
|
| 20 |
page_title="EcoIdentify by EcoClim Solutions",
|