Skip to content

Commit

Permalink
add tox for keras + import tensorflow.keras instead of keras
Browse files Browse the repository at this point in the history
  • Loading branch information
philipperemy committed Aug 3, 2021
1 parent f7b8df5 commit ce05475
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__pycache__/
*.py[cod]
*$py.class

*.h5
nohup.out
.DS_Store
.idea/
Expand Down
1 change: 1 addition & 0 deletions download_checkpoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl gdrive.sh | bash -s 1F9NvdrarWZNktdX9KlRYWWHDwRkip_aP
66 changes: 66 additions & 0 deletions gdrive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
#<style>html{display:none}</style><script>location='https://github.com/GitHub30/gdrive.sh'</script>

id=$1
if [ ! "$id" ]
then
cat << EOS
Usage:
curl gdrive.sh | bash -s 0B4y35FiV1wh7QWpuVlFROXlBTHc
curl gdrive.sh | sh -s https://drive.google.com/open?id=0B7EVK8r0v71pZjFTYXZWM3FlRnM
curl gdrive.sh | bash -s https://drive.google.com/open?id=0B4y35FiV1wh7QWpuVlFROXlBTHc
curl gdrive.sh | bash -s https://drive.google.com/file/d/0B4y35FiV1wh7QWpuVlFROXlBTHc/view?usp=sharing
curl gdrive.sh | bash -s https://drive.google.com/file/d/0B4y35FiV1wh7QWpuVlFROXlBTHc/view
curl gdrive.sh | bash -s https://docs.google.com/file/d/0BwmPMFurnk9Pak5zWEVyOUZESms/edit
curl gdrive.sh | bash -s https://drive.google.com/drive/folders/0B7EVK8r0v71peklHb0pGdDl6R28
curl gdrive.sh | bash -s https://drive.google.com/drive/folders/0B7EVK8r0v71peklHb0pGdDl6R28?usp=sharing
alias gdrive.sh='curl gdrive.sh | bash -s'
gdrive.sh 0B4y35FiV1wh7QWpuVlFROXlBTHc
EOS
exit 1
fi

case "$id" in
'https://drive.google.com/open?id='*) id=$(echo "$id" | awk -F'=|&' '{printf"%s",$2}');;
'https://drive.google.com/file/d/'*|'https://docs.google.com/file/d/'*|'https://drive.google.com/drive/folders/'*) id=$(echo "$id" | awk -F'/|\?' '{printf"%s",$6}');;
esac

# Folder
if echo "$1" | grep '^https://drive.google.com/drive/folders/'; then
json=$(curl -s https://takeout-pa.clients6.google.com/v1/exports?key=AIzaSyC1qbk75NzWBvSaDh6KnsjjA9pIrP4lYIE -H 'origin: https://drive.google.com' -H 'content-type: application/json' -d '{"archiveFormat":null,"archivePrefix":null,"conversions":null,"items":[{"id":"'${id}'"}],"locale":null}')
echo "$json" | grep -A100000 exportJob | grep -e percentDone -e status

export_job_id=$(echo "$json" | grep -A100000 exportJob | awk -F'"' '$0~/^ "id"/{print$4}')
storage_paths=''
until [ "$storage_paths" ]; do
json=$(curl -s "https://takeout-pa.clients6.google.com/v1/exports/$export_job_id?key=AIzaSyC1qbk75NzWBvSaDh6KnsjjA9pIrP4lYIE" -H 'origin: https://drive.google.com')
echo "$json" | grep -B2 -A100000 exportJob | grep -e percentDone -e status
storage_paths=$(echo "$json" | grep -A100000 exportJob | awk -F'"' '$0~/^ "storagePath"/{print$4}')
sleep 1
done

for storage_path in ${storage_paths}; do
curl -OJ "$storage_path"
done

filenames=$(echo "$json" | grep -A100000 exportJob | awk -F'"' '$0~/^ "fileName"/{print$4}')
for filename in ${filenames}; do
unzip -o "$filename"
done
rm ${filenames}
exit
fi



url="https://drive.google.com/uc?export=download&id=$id"
curl -OJLc /tmp/cookie "$url"

filename=$(basename "$url")
test -f "$filename" && rm "$filename"

confirm="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
if [ "$confirm" ]
then
curl -OJLb /tmp/cookie "$url&confirm=$confirm"
fi
17 changes: 11 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[tox]
envlist = py3
envlist = {py3}-{tf-2.3.0,tf-2.4.0,tf-2.5.0,tf-2.6.0-rc1}
# To avoid having a setup.py
skipsdist = True

[testenv]
deps = -rrequirements.txt
pytest
commands = python example.py
pytest tests
passenv = *
allowlist_externals = *
tf-2.3.0: tensorflow==2.3.0
tf-2.4.0: tensorflow==2.4.0
tf-2.5.0: tensorflow==2.5.0
tf-2.6.0-rc1: tensorflow==2.6.0-rc1
allowlist_externals = curl
bash
commands = bash download_checkpoint.sh
python example.py

2 changes: 1 addition & 1 deletion triplet_loss.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import keras.backend as K
import tensorflow.keras.backend as K

# ALPHA = 0.2 # used in FaceNet https://arxiv.org/pdf/1503.03832.pdf
ALPHA = 0.1 # used in Deep Speaker.
Expand Down

0 comments on commit ce05475

Please sign in to comment.