Skip to content

Commit

Permalink
Merge pull request #21 from dominikkawka/slightModelChanges
Browse files Browse the repository at this point in the history
slight model changes; 90%acc + 55%valAcc
  • Loading branch information
dominikkawka authored Dec 28, 2023
2 parents 06846df + 92bf6cb commit 566de4b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.keras
*.h5
*.tf
__pycache__/

bin/
Expand Down
2 changes: 1 addition & 1 deletion backend/commonVariables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import env

breedLabel = ['chihuahua', 'japaneseSpaniel', 'malteseDog', 'pekinese', 'shihtzu', 'blenheimSpaniel' ,'papillon' ,'toyTerrier','rhodesianRidgeback' ,'afghanHound' ,'basset' ,'beagle' ,'bloodhound' ,'bluetick' ,'blackAndTanCoonhound' ,'walkerHound' ,'englishFoxhound' ,'redbone' ,'borzoi' ,'irishWolfhound' ,'italianGreyhound' ,'whippet' ,'ibizanHound' ,'norwegianElkhound' ,'otterhound' ,'saluki' ,'scottishDeerhound' ,'weimaraner' ,'staffordshireBullTerrier' ,'americanStaffordshireTerrier' ,'bedlingtonTerrier' ,'borderTerrier' ,'kerryBlueTerrier' ,'irishTerrier' ,'norfolkTerrier' ,'norwichTerrier' ,'yorkshireTerrier' ,'wireHairedFoxTerrier' ,'lakelandTerrier' ,'sealyhamTerrier' ,'airedale' ,'cairn' ,'australianTerrier' ,'dandieDinmont' ,'bostonBull' ,'miniatureSchnauzer' ,'giantSchnauzer' ,'standardSchnauzer' ,'scotchTerrier' ,'tibetanTerrier' ,'silkyTerrier' ,'softCoatedWheatenTerrier' ,'westHighlandWhiteTerrier' ,'lhasa' ,'flatCoatedRetriever' ,'curlyCoatedRetriever' ,'goldenRetriever' ,'labradorRetriever' ,'ChesapeakeBayRetriever' ,'germanShortHairedPointer' ,'vizsla' ,'englishSetter' ,'irishSetter' ,'gordonSetter' ,'brittanySpaniel' ,'clumber' ,'englishSpringer' ,'welshSpringerSpaniel' ,'cockerSpaniel' ,'sussexSpainel' ,'irishWaterSpaniel' ,'kuvasz' ,'schipperke' ,'groenendael' ,'malinois' ,'briard' ,'kelpie' ,'komondor' ,'oldEnglishSheepdog' ,'shetlandSheepdog' ,'collie' ,'borderCollie' ,'bouvierDesFlandres' ,'rottweiler' ,'germanShepard' ,'doberman' ,'miniaturePinscher' ,'greaterSwissMountainDog' ,'berneseMountainDog' ,'appenzeller' ,'EntleBucher' ,'boxer' ,'bullMastiff' ,'tibetanMastiff' ,'frenchBulldog' ,'greatDane' ,'saintBernard', 'eskimoDog' ,'malamute' ,'siberianHusky' ,'affenpinscher' ,'basenji' ,'pug' ,'leonberg' ,'newfoundland' ,'greatPyrenees' ,'samoyed' ,'pomeranian' ,'chow', 'keeshond' ,'brabanconGriffon' ,'pembroke' ,'cardigan' ,'toyPoodle' ,'miniaturePoodle' ,'standardPoodle' ,'mexicanHairless' ,'dingo' ,'dhole', 'africanHuntingDog']
image_size = 192
image_size = 256
datasetDir = '../../dogBreedDataset/images/Images'
uri = env.uri
9 changes: 5 additions & 4 deletions backend/dogBreedModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
monitor="val_accuracy",
patience=10,
mode="max",
start_from_epoch=40 #not available in version 2.8
start_from_epoch=40
)

hist = model.fit(trainDataset, validation_data=validationDataset, epochs=epochs, callbacks=[earlyStop])
Expand All @@ -97,9 +97,10 @@
loss = hist.history['loss']
val_loss = hist.history['val_loss']

model.save('model/InceptionV3-2.15-24Dec-Augmented.keras')
model.save('model/InceptionV3-2.15-24Dec-Augmented.h5')
model.save('model/InceptionV3-2.15-24Dec-Augmented.tf')
# In TF2.15, the .keras file will infinately stall when trying to analyse a photo.
#model.save('model/InceptionV3-2.15-28Dec-Augmented.keras')
model.save('model/InceptionV3-2.15-28Dec-Augmented.h5')
#model.save('model/InceptionV3-2.15-28Dec-Augmented.tf')

fig = plt.figure()
plt.plot(hist.history['accuracy'], color='red', label='accuracy')
Expand Down
2 changes: 1 addition & 1 deletion backend/loadRunModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def modelPrediction(dogBreedImage):
img_array = tf.keras.utils.img_to_array(valueBreed)
img_array = tf.expand_dims(img_array, 0) # Create a batch

loadModel = load_model('model/InceptionV3-2.8-Augmented.keras')
loadModel = load_model('model/InceptionV3-2.15-28Dec-Augmented.h5')
predictions = loadModel.predict(img_array)

# each result here has 0.00 ... instead of a full number in front, which is why the confidence is low no matter what.
Expand Down
1 change: 1 addition & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ async def getPrediction(image):

@app.patch("/prediction")
async def patchCorrectBreed(predictedBreed: str, image, actualBreed: str):
#https://fastapi.tiangolo.com/tutorial/encoder/
response = await database.update_breed(predictedBreed, image, actualBreed)
return response
4 changes: 3 additions & 1 deletion frontend/src/components/FileForm/FileForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function FileForm() {
<Typography>
Predicted Breed: {prediction} + Confidence: {confidence}
</Typography>
<Typography>
<Box
sx={{ alignContent: "center"}}>
{imagePreview && (
Expand All @@ -95,7 +96,8 @@ function FileForm() {
</CardContent>
</Card>
)}
</Box>
</Box>
</Typography>
<Box style={{paddingLeft: "42%"}}>
<SelectCorrectBreed />
</Box>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/WebcamFeed/WebcamFeed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function WebcamFeed() {
}, [webcamRef]);

const videoConstraints = {
width: 192,
height: 192,
width: 256,
height: 256,
facingMode: "user",
};

Expand All @@ -38,8 +38,8 @@ function WebcamFeed() {
screenshotFormat="image/jpeg"
videoConstraints={videoConstraints}
audio={false}
height={192}
width={192}
height={256}
width={256}
ref={webcamRef}
mirrored={true}
/>
Expand Down

0 comments on commit 566de4b

Please sign in to comment.