File size: 1,678 Bytes
87bd492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Waste Classifier AI

## Dataset Structure

Place your dataset in a directory like:

```

waste_dataset/

β”œβ”€β”€ biodegradable/

β”‚   β”œβ”€β”€ img1.jpg

β”‚   └── ...

└── non_biodegradable/

    β”œβ”€β”€ img2.jpg

    └── ...

```

## Training the Model

1. Install dependencies:
   ```

   pip install -r requirements.txt

   ```
2. Run the training script:
   ```

   python train_waste_classifier.py

   ```
   This will save the model and processor to `models/waste_classifier_model/`.

## Running the API

1. Start the Flask API:
   ```

   python waste_classification_api.py

   ```
2. The API will be available at `http://localhost:5000/classify`.

## API Usage

- **Endpoint:** `/classify` (POST)
- **Payload:** Multipart form with one or more images (field name: `images`)
- **Response:**
  ```json

  {

    "results": [

      {

        "label": "biodegradable",

        "confidence": 0.94,

        "description": "Easily breaks down naturally. Good for composting.",

        "recyclable": false,

        "disposal": "Use compost or organic bin",

        "example_items": ["banana peel", "food waste", "paper"]

      },

      ...

    ]

  }

  ```

## Frontend Integration

- The React Native frontend can POST images to `/classify` and display the results using the modal.
- No changes are needed to the modal if it expects the above JSON structure.

## Notes
- If your dataset folders are named differently (e.g., `R` and `O`), update the LABEL2INFO mapping and class names in the training script.
- The model is based on `google/vit-base-patch16-224` and fine-tuned for binary classification.