wut-web cleaup
parent
7881d9aad2
commit
566f1eb139
|
@ -10,15 +10,8 @@
|
|||
"#\n",
|
||||
"# https://spacecruft.org/spacecruft/satnogs-wut\n",
|
||||
"#\n",
|
||||
"# GPLv3+"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# GPLv3+\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"import random\n",
|
||||
"import tempfile\n",
|
||||
|
@ -26,15 +19,8 @@
|
|||
"import tensorflow as tf\n",
|
||||
"from IPython.display import display, Image\n",
|
||||
"from tensorflow.python.keras.models import load_model\n",
|
||||
"from tensorflow.python.keras.preprocessing.image import ImageDataGenerator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from tensorflow.python.keras.preprocessing.image import ImageDataGenerator\n",
|
||||
"\n",
|
||||
"print(\"wut --- What U Think? SatNOGS Observation AI.\")\n",
|
||||
"print(\"\")\n",
|
||||
"print(\"wut is an AI that rates SatNOGS Observations good or bad.\")\n",
|
||||
|
@ -47,15 +33,8 @@
|
|||
"print(\"\")\n",
|
||||
"print(\"Source Code:\")\n",
|
||||
"print(\"https://spacecruft.org/spacecruft/satnogs-wut\")\n",
|
||||
"print(\"Alpha stage.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(\"Alpha stage.\")\n",
|
||||
"\n",
|
||||
"IMG_HEIGHT = 416\n",
|
||||
"IMG_WIDTH= 804\n",
|
||||
"batch_size = 32\n",
|
||||
|
@ -78,15 +57,8 @@
|
|||
"for root, dirs, files in os.walk(sample_dir):\n",
|
||||
" for name in files:\n",
|
||||
" n=n+1\n",
|
||||
" if random.uniform(0, n) < 1: rfile=os.path.join(root, name)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" if random.uniform(0, n) < 1: rfile=os.path.join(root, name)\n",
|
||||
"\n",
|
||||
"shutil.copy(rfile, test_dir + '/unvetted/')"
|
||||
]
|
||||
},
|
||||
|
@ -96,15 +68,8 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model = load_model(model_file)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model = load_model(model_file)\n",
|
||||
"\n",
|
||||
"test_image_generator = ImageDataGenerator(\n",
|
||||
" rescale=1./255\n",
|
||||
")\n",
|
||||
|
@ -112,23 +77,12 @@
|
|||
" directory=test_dir,\n",
|
||||
" target_size=(IMG_HEIGHT, IMG_WIDTH),\n",
|
||||
" shuffle=True,\n",
|
||||
" class_mode='binary')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"baserfile=os.path.basename(rfile)\n",
|
||||
"print(\"Rating:\", baserfile)\n",
|
||||
" class_mode='binary')\n",
|
||||
"\n",
|
||||
"prediction = model.predict(\n",
|
||||
" x=test_data_gen,\n",
|
||||
" verbose=0\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"predictions=[]\n",
|
||||
"prediction_bool = (prediction >0.8)\n",
|
||||
"predictions = prediction_bool.astype(int)\n",
|
||||
|
@ -136,15 +90,8 @@
|
|||
" rating = 'bad'\n",
|
||||
"else:\n",
|
||||
" rating = 'good'\n",
|
||||
"print('Observation: %s' % (rating))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print('Observation: %s' % (rating))\n",
|
||||
"\n",
|
||||
"shutil.rmtree(test_dir)"
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue