ankz22 commited on
Commit
e7ed4b7
·
1 Parent(s): 0797cfd

Add application file

Browse files
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -1,24 +1,20 @@
1
  import gradio as gr
2
- from transformers import AutoFeatureExtractor, AutoModelForImageClassification
3
  from PIL import Image
4
  import torch
5
  import torch.nn.functional as F
6
  import pandas as pd
7
 
8
- extractor = AutoFeatureExtractor.from_pretrained("nateraw/resnet50-trash-classifier")
9
- model = AutoModelForImageClassification.from_pretrained("nateraw/resnet50-trash-classifier")
10
 
11
  POUBELLES = {
12
- "plastic": "plastique",
13
  "glass": "verre",
14
  "metal": "métal",
15
  "paper": "papier",
16
- "cardboard": "papier/carton",
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
- interface = gr.Interface(
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()