Skip to content

Commit

Permalink
Merge pull request #11 from CornellDataScience/siamese-model
Browse files Browse the repository at this point in the history
Siamese model
  • Loading branch information
JamesZhang2 authored Dec 3, 2023
2 parents 38039e0 + 151755e commit d9b7148
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 514 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ Images/**
**/cmake_install.cmake
**/CMakeCache.txt
camera
CMakeFiles/**
**/.env
src/lfwa/**
**/__pycache__/**
src/model/message/__pycache__/**
src/model/__pycache__/utils.cpython-38.pyc
src/model/message/__pycache__/__init__.cpython-38.pyc
src/model/message/__pycache__/sms_message.cpython-38.pyc
**/Makefile
src/lfwa/**
192 changes: 0 additions & 192 deletions Makefile

This file was deleted.

15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
Make sure git-clang-format is installed with `npm install -g clang-format`
1. Call `clang-format.sh` under ci/
2. `git add` and `git commit`!
To run:

## To run

`cd build`

Expand All @@ -15,3 +16,15 @@ To run:
`make`

`./camera`

## Setting up Twilio

- `cd` to `src/message/`

- Make a `.env` file with `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` set to your account SID and Auth Token

- macOS: `brew tap twilio/brew && brew install twilio`

- `twilio login`

- `pip install twilio`
Binary file removed camera
Binary file not shown.
134 changes: 0 additions & 134 deletions src/Makefile

This file was deleted.

12 changes: 7 additions & 5 deletions src/model/Siamese_Network.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from sklearn.model_selection import train_test_split

import os
import pickle
import random

import numpy as np
import tensorflow as tf
from sklearn.model_selection import train_test_split

from tensorflow.keras import Input, Sequential, Model
from tensorflow.keras import backend as K
from tensorflow.keras.callbacks import EarlyStopping
Expand Down Expand Up @@ -279,10 +281,10 @@ def evaluate(self, test_file, batch_size, analyze=False):
def predict(self, x_test, names):
prob = self.siamese_net.predict(x_test)

for pair_index in range(len(names)):
name = names[pair_index]
pair_prob = prob[pair_index][0]
print(f"Similar to {name} with probability: ", pair_prob)
name = names[0]
pair_prob = prob[0][0]
print(f"Similar to {name} with probability: ", pair_prob)
return pair_prob

def _analyze(self, x_test, y_test, names):
"""
Expand Down
Loading

0 comments on commit d9b7148

Please sign in to comment.