Upload 15 files
Browse files- .gitattributes +1 -0
- app.py +61 -0
- apple_model_transferlearning.keras +3 -0
- images/Gesund1.JPG +0 -0
- images/Gesund2.JPG +0 -0
- images/Gesund3.JPG +0 -0
- images/Schorf1.JPG +0 -0
- images/Schorf2.JPG +0 -0
- images/Schorf3.JPG +0 -0
- images/Schwarzfaeule1.JPG +0 -0
- images/Schwarzfaeule2.JPG +0 -0
- images/Schwarzfaeule3.JPG +0 -0
- images/Zederapfel1.JPG +0 -0
- images/Zederapfel2.JPG +0 -0
- images/Zederapfel3.JPG +0 -0
- requirements.txt +1 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
apple_model_transferlearning.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
print(tf.__version__)
|
| 4 |
+
import numpy as np
|
| 5 |
+
from PIL import Image
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
#model_path = "apple_model_transferlearning.keras"
|
| 10 |
+
model_path = r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\3_Model_Training_and_Application\apple_model_transferlearning.keras"
|
| 11 |
+
print("Existiert die Modell-Datei?:", os.path.exists(model_path))
|
| 12 |
+
model = tf.keras.models.load_model(model_path)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def predict_pokemon(image):
|
| 17 |
+
# Preprocess image
|
| 18 |
+
print(type(image))
|
| 19 |
+
image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
|
| 20 |
+
image = image.resize((150, 150)) # Resize the image to 150x150 pixels
|
| 21 |
+
image = np.array(image)
|
| 22 |
+
image = np.expand_dims(image, axis=0) # Add batch dimension
|
| 23 |
+
|
| 24 |
+
# Predict
|
| 25 |
+
prediction = model.predict(image)
|
| 26 |
+
# Convert the probabilities to rounded values
|
| 27 |
+
prediction = np.round(prediction, 2)
|
| 28 |
+
|
| 29 |
+
# Make sure the indices are correct according to your model's training
|
| 30 |
+
p_schorf = prediction[0][0] # Probability for "Schorf"
|
| 31 |
+
p_schwarzfaeule = prediction[0][1] # Probability for "Schwarzfaeule"
|
| 32 |
+
p_zederapfel = prediction[0][2] # Probability for "Zederapfel"
|
| 33 |
+
p_gesund = prediction[0][3] # Probability for "Gesund"
|
| 34 |
+
|
| 35 |
+
return {'gesund': p_gesund, 'schorf': p_schorf, 'schwarzfaeule': p_schwarzfaeule, 'zederapfel': p_zederapfel}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# Create the Gradio interface
|
| 40 |
+
input_image = gr.Image()
|
| 41 |
+
iface = gr.Interface(
|
| 42 |
+
fn=predict_pokemon,
|
| 43 |
+
inputs=input_image,
|
| 44 |
+
outputs=gr.Label(),
|
| 45 |
+
examples=[r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Gesund1.jpg",
|
| 46 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Gesund2.jpg",
|
| 47 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Gesund3.jpg",
|
| 48 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Schorf1.jpg",
|
| 49 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Schorf2.jpg",
|
| 50 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Schorf3.jpg",
|
| 51 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Schwarzfaeule1.jpg",
|
| 52 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Schwarzfaeule2.jpg",
|
| 53 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Schwarzfaeule3.jpg",
|
| 54 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Zederapfel1.jpg",
|
| 55 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Zederapfel2.jpg",
|
| 56 |
+
r"C:\Users\dom-k\Visual Studio Code\6. Semester\Project1_Kupredom\Image_Classification\2_Data_collection\apple_images\model\Zederapfel3.jpg"],
|
| 57 |
+
description="Model")
|
| 58 |
+
|
| 59 |
+
iface.launch()
|
| 60 |
+
|
| 61 |
+
|
apple_model_transferlearning.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd3884cef0755965ce323e529a6633c3ff994590b2c2f39a3a32b6b0aec89cef
|
| 3 |
+
size 250584735
|
images/Gesund1.JPG
ADDED
|
|
images/Gesund2.JPG
ADDED
|
|
images/Gesund3.JPG
ADDED
|
|
images/Schorf1.JPG
ADDED
|
|
images/Schorf2.JPG
ADDED
|
|
images/Schorf3.JPG
ADDED
|
|
images/Schwarzfaeule1.JPG
ADDED
|
|
images/Schwarzfaeule2.JPG
ADDED
|
|
images/Schwarzfaeule3.JPG
ADDED
|
|
images/Zederapfel1.JPG
ADDED
|
|
images/Zederapfel2.JPG
ADDED
|
|
images/Zederapfel3.JPG
ADDED
|
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
tensorflow
|