checkbox for waterfall

master
ml server 2020-01-24 23:53:45 -07:00
parent bb6b54ce81
commit 85e047e46c
1 changed files with 24 additions and 16 deletions

View File

@ -24,6 +24,9 @@
"import ipywidgets as wg\n",
"import matplotlib.pyplot as plt\n",
"from ipywidgets import HBox, Label\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"from ipywidgets import Layout, Button, Box\n",
"from ipywidgets import Layout, Button, Box, FloatText, Textarea, Dropdown, Label, IntSlider\n",
"from IPython.display import display, Image\n",
"from IPython.utils import text\n",
"from PIL import Image as im\n",
@ -86,7 +89,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"#site_intro()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def wut_model(model_file):\n",
" model = load_model(model_file)\n",
" \n",
@ -107,7 +118,8 @@
" target_size=(IMG_HEIGHT, IMG_WIDTH),\n",
" shuffle=True,\n",
" class_mode='binary')\n",
" return test_data_gen"
" return test_data_gen\n",
"# Get rid of, but %%capture fails: Found 1 images belonging to 1 classes."
]
},
{
@ -116,7 +128,6 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"def rm_image_tmp(test_dir):\n",
" #print('Not removed:', test_dir)\n",
" shutil.rmtree(test_dir)"
@ -128,15 +139,15 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture --no-stderr --no-stdout\n",
"def gen_image_tmp(obs_waterfalltmp):\n",
"def gen_image_tmp(obs_waterfalltmp, showwater):\n",
" tmp_dir = tempfile.mkdtemp()\n",
" test_dir = os.path.join(tmp_dir)\n",
" os.makedirs(test_dir + '/unvetted', exist_ok=True)\n",
" shutil.copy(obs_waterfalltmp, test_dir + '/unvetted/') \n",
" \n",
" img = im.open(obs_waterfalltmp).resize( (100,200))\n",
" display(img)\n",
" if showwater == True:\n",
" display(img)\n",
"\n",
" return test_dir"
]
@ -147,7 +158,6 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"def obs_wutsay(test_data_gen):\n",
" prediction = model.predict(\n",
" x=test_data_gen,\n",
@ -196,14 +206,13 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"def doallthethings(datObs):\n",
"def doallthethings(datObs, showwater):\n",
"\n",
" obs_waterfall=get_obs_var('waterfall', datObs) \n",
" obs_waterfallpic=os.path.basename(obs_waterfall)\n",
" obs_waterfalltmp = os.path.join('/srv/satnogs/download', str(get_obs_var('id', datObs)), obs_waterfallpic)\n",
"\n",
" test_dir=gen_image_tmp(obs_waterfalltmp);\n",
" test_dir=gen_image_tmp(obs_waterfalltmp, showwater);\n",
" test_data_gen=gen_image(obs_waterfalltmp, test_dir);\n",
" \n",
" prediction_bool=obs_wutsay(test_data_gen);\n",
@ -225,7 +234,7 @@
" print()\n",
" print('https://network.satnogs.org/observations/' + str(get_obs_var('id', datObs)))\n",
" #!cat $obsjsonfile\n",
" rm_image_tmp(test_dir)"
" rm_image_tmp(test_dir) "
]
},
{
@ -234,10 +243,9 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"def wutObs(datObs):\n",
"def wutObs(datObs, showwater):\n",
" if int(datObs) > ( minobsid - 1 ) and int(datObs) < ( maxobsid + 1):\n",
" doallthethings(datObs)"
" doallthethings(datObs, showwater)"
]
},
{
@ -246,12 +254,12 @@
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"def display_main(model):\n",
" print('Enter an Observation ID between', minobsid, 'and', maxobsid)\n",
" rand_obsid=random.randint(minobsid,maxobsid)\n",
" wutObs_slide = wg.IntText(value=rand_obsid, description=' ')\n",
" wg.interact(wutObs, datObs=wutObs_slide)"
" wutObs_check = wg.Checkbox(value=True, disabled=False)\n",
" wg.interact(wutObs, datObs=wutObs_slide, showwater=wutObs_check.value)"
]
},
{