wut-web-dev cruft tests

master
ml server 2020-01-23 14:07:31 -07:00
parent 71ce17de48
commit 530694c0d8
1 changed files with 69 additions and 11 deletions

View File

@ -20,6 +20,7 @@
"import tensorflow as tf\n", "import tensorflow as tf\n",
"import numpy as np\n", "import numpy as np\n",
"from IPython.display import display, Image\n", "from IPython.display import display, Image\n",
"from IPython.utils import text\n",
"from tensorflow.python.keras.models import load_model\n", "from tensorflow.python.keras.models import load_model\n",
"from tensorflow.python.keras.preprocessing.image import ImageDataGenerator\n", "from tensorflow.python.keras.preprocessing.image import ImageDataGenerator\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n", "from ipywidgets import interact, interactive, fixed, interact_manual\n",
@ -82,6 +83,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%%capture\n",
"n=0\n", "n=0\n",
"random.seed();\n", "random.seed();\n",
"for root, dirs, files in os.walk(sample_dir):\n", "for root, dirs, files in os.walk(sample_dir):\n",
@ -98,8 +100,17 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"model = load_model(model_file)\n", "%%capture\n",
"\n", "model = load_model(model_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"test_image_generator = ImageDataGenerator(\n", "test_image_generator = ImageDataGenerator(\n",
" rescale=1./255\n", " rescale=1./255\n",
")\n", ")\n",
@ -107,24 +118,52 @@
" directory=test_dir,\n", " directory=test_dir,\n",
" target_size=(IMG_HEIGHT, IMG_WIDTH),\n", " target_size=(IMG_HEIGHT, IMG_WIDTH),\n",
" shuffle=True,\n", " shuffle=True,\n",
" class_mode='binary')\n", " class_mode='binary')"
"\n", ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"prediction = model.predict(\n", "prediction = model.predict(\n",
" x=test_data_gen,\n", " x=test_data_gen,\n",
" verbose=0\n", " verbose=0\n",
")\n", ")\n",
"predictions=[]\n", "predictions=[]\n",
"prediction_bool = (prediction >0.8)\n", "prediction_bool = (prediction >0.8)\n",
"predictions = prediction_bool.astype(int)\n", "predictions = prediction_bool.astype(int)"
"if prediction_bool[0] == False:\n", ]
" rating = 'bad'\n", },
"else:\n", {
" rating = 'good'\n", "cell_type": "code",
"print('Observation: %s' % (rating))\n", "execution_count": null,
"\n", "metadata": {},
"outputs": [],
"source": [
"shutil.rmtree(test_dir)" "shutil.rmtree(test_dir)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"waterfallpng=os.path.basename(rfile)\n",
"print('Random waterfall:', waterfallpng)\n",
"f=text.EvalFormatter()\n",
"obsid=(f.format(\"{waterfall[slice(10,17)]}\", waterfall=waterfallpng))\n",
"print('Observation URL: https://network.satnogs.org/observations/{}'.format(obsid))\n",
"if prediction_bool[0] == False:\n",
" rating = 'BAD'\n",
"else:\n",
" rating = 'GOOD'\n",
"print('AI Observation rating: %s' % (rating))"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@ -401,6 +440,25 @@
"print(text.marquee('wut?',40,'*'))" "print(text.marquee('wut?',40,'*'))"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = input()\n",
"print(a)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('mkay')"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,