Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
CHANGED
|
@@ -1,24 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
import torch.nn.functional as F
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
-
extractor =
|
| 9 |
-
model = AutoModelForImageClassification.from_pretrained("
|
| 10 |
|
| 11 |
POUBELLES = {
|
| 12 |
-
"
|
| 13 |
"glass": "verre",
|
| 14 |
"metal": "métal",
|
| 15 |
"paper": "papier",
|
| 16 |
-
"
|
| 17 |
"trash": "ordures ménagères",
|
| 18 |
-
"compost": "biodéchets",
|
| 19 |
-
"battery": "déchet dangereux",
|
| 20 |
-
"clothes": "textile",
|
| 21 |
-
# Ajoute d'autres si nécessaire
|
| 22 |
}
|
| 23 |
|
| 24 |
def classify_image(image):
|
|
@@ -43,12 +39,10 @@ def classify_image(image):
|
|
| 43 |
|
| 44 |
return pd.DataFrame(rows)
|
| 45 |
|
| 46 |
-
|
| 47 |
fn=classify_image,
|
| 48 |
inputs=gr.Image(type="pil"),
|
| 49 |
outputs=gr.Dataframe(),
|
| 50 |
title="🗑️ Classifieur de Déchets",
|
| 51 |
description="Dépose une image de déchet pour savoir dans quelle poubelle le trier."
|
| 52 |
-
)
|
| 53 |
-
|
| 54 |
-
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
import torch.nn.functional as F
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
+
extractor = AutoImageProcessor.from_pretrained("mrm8488/resnet50-finetuned-trashnet")
|
| 9 |
+
model = AutoModelForImageClassification.from_pretrained("mrm8488/resnet50-finetuned-trashnet")
|
| 10 |
|
| 11 |
POUBELLES = {
|
| 12 |
+
"cardboard": "papier/carton",
|
| 13 |
"glass": "verre",
|
| 14 |
"metal": "métal",
|
| 15 |
"paper": "papier",
|
| 16 |
+
"plastic": "plastique",
|
| 17 |
"trash": "ordures ménagères",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
def classify_image(image):
|
|
|
|
| 39 |
|
| 40 |
return pd.DataFrame(rows)
|
| 41 |
|
| 42 |
+
gr.Interface(
|
| 43 |
fn=classify_image,
|
| 44 |
inputs=gr.Image(type="pil"),
|
| 45 |
outputs=gr.Dataframe(),
|
| 46 |
title="🗑️ Classifieur de Déchets",
|
| 47 |
description="Dépose une image de déchet pour savoir dans quelle poubelle le trier."
|
| 48 |
+
).launch()
|
|
|
|
|
|