Skip to content

Instantly share code, notes, and snippets.

View zaidalyafeai's full-sized avatar
:octocat:
Working from home

Zaid Alyafeai zaidalyafeai

:octocat:
Working from home
View GitHub Profile
import os
os.chdir('<git-directory>')
!git clone <path-to-page>
!git config --global user.email "email"
!git config --global user.name "user"
!git add .
!git commit -m "create xor project"
!git push <token>:[email protected]/<path-to-page> master
with open('index.html','w') as f:
f.write(header+script+body)
f.close()
body = '\
<body>\n\
<p id =\'out\'></p> \n\
</body>'
script = '\
<script>\n\
async function loadModel(){ \n\
model = await tf.loadModel(\'web_model/model.json\') \n\
y = model.predict(tf.zeros([1,2])) \n\
document.getElementById(\'out\').innerHTML = y.dataSync()[0] \n\
} \n\
loadModel() \n\
</script>\n\
</head> \n'
header = '<head><script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script>\n'
!tensorflowjs_converter --input_format keras saved_model/keras.h5 web_model
!pip install tensorflowjs