Skip to content

Commit

Permalink
Testing things
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebedel committed Apr 11, 2024
2 parents 84e767f + 43b7956 commit f9aa887
Show file tree
Hide file tree
Showing 20 changed files with 14,356 additions and 1,872 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ venv/
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.DS_Store
.DS_Store

input/cleanDataset
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"files.associations": {
"vector": "cpp"
}
},
"python.analysis.typeCheckingMode": "basic",
"python.analysis.autoImportCompletions": false
}
18 changes: 11 additions & 7 deletions ai/predict.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import sys
import os
import numpy as np
from tensorflow.keras.preprocessing import image
import cv2
# from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import load_model

class_labels = ["cardboard", "glass", "metal", "paper", "plastic", "trash"]


def get_class(img_path: str, model) -> str:
img = image.load_img(img_path, target_size=(512, 384))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array /= 255.0 # Normalisation des pixels
img = cv2.imread(img_path)
img = cv2.resize(img, (256, 256))

# Prédiction de la classe
prediction = model.predict(img_array, verbose=0)
prediction = model.predict(np.expand_dims(img, axis=0), verbose=0)
predicted_class = class_labels[np.argmax(prediction)]
if predicted_class in ["plastic", "cardboard", "paper"]:
return "recyclable"
Expand All @@ -30,8 +28,14 @@ def main():
print("No such image found on the arguments list")
return -1

<<<<<<< HEAD
model = load_model(os.path.dirname(
os.path.abspath(__file__)) + "/alex.keras",
compile=False
=======
model = load_model(
os.path.dirname(os.path.abspath(__file__)) + "/trash_detection_model.keras"
>>>>>>> develop
)
print(get_class(sys.argv[1], model))
return 0
Expand Down
6 changes: 4 additions & 2 deletions ai/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
numpy
tensorflow
pillow
tensorflow==2.15.1
pillow
opencv-python
matplotlib
Binary file added ai/test-images/cardboard47.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai/test-images/metal17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai/test-images/paper403.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai/test-images/paper404.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai/test-images/test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai/test-images/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ai/test-images/trash1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,405 changes: 927 additions & 478 deletions ai/training.ipynb

Large diffs are not rendered by default.

1,383 changes: 0 additions & 1,383 deletions ai/training2.ipynb

This file was deleted.

2 changes: 2 additions & 0 deletions mobile/ios/.xcode.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export NODE_BINARY=/Users/alexandrebedel/.nvm/versions/node/v20.9.0/bin/node

1,992 changes: 1,992 additions & 0 deletions mobile/ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec-generated.mm

Large diffs are not rendered by default.

Loading

0 comments on commit f9aa887

Please sign in to comment.