Skip to content

Commit

Permalink
clean up sandbox code
Browse files Browse the repository at this point in the history
  • Loading branch information
pmhalvor committed Sep 28, 2024
1 parent 19014d2 commit 2d4b087
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 31 deletions.
2 changes: 2 additions & 0 deletions examples/model_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def predict():
})

except Exception as e:
logging.error(f"An error occurred: {str(e)}")
print(f"An error occurred: {str(e)}")
return jsonify({'error': str(e)}), 500

# Main entry point
Expand Down
32 changes: 1 addition & 31 deletions examples/quantized_model.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,18 @@
import tempfile
import os
import csv

import tensorflow as tf
import numpy as np
import tflite as tfl

# import tensorflow.keras.utils
from tensorflow import keras
# import tensorflow.compat.v1 as tf
import tensorflow as tf
import tensorflow_hub as hub
import itertools
import soundfile as sf
import librosa
import math
import time
# from prune import prune
# import tensorflow_model_optimization as tfmot


interpreter=tf.lite.Interpreter(model_path='data/model/quantized_model1.tflite')

interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

i=0
whales_identified=0
whale_samples=0
other_samples_identified=0
other_samples=0
directory_mn='./clips/mn/'
directory_not_mn='./clips/not_mn/'

# filename = os.fsdecode(file)

# # try opening the file
# waveform, sample_rate = tf.audio.decode_wav(tf.io.read_file(directory_mn+filename))

# waveform = tf.slice(tf.squeeze(tf.expand_dims(waveform, 0),[2]),[1,0],[1,15600]) # makes a batch of size 1
waveform = tf.convert_to_tensor(np.random.random((1, 15600)).astype(np.float32))
print(waveform.shape)


# Create input tensor out of raw features
interpreter.set_tensor(input_details[0]['index'], waveform)

Expand Down

0 comments on commit 2d4b087

Please sign in to comment.