summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2019-01-10 12:09:12 +0100
committeradamhrv <adam@ahprojects.com>2019-01-10 12:09:12 +0100
commit3202498b5c195f103a7cd13609785c2bb97c2da6 (patch)
treec8400d85366eefe1b740787f4503c61fb6175142
parent62decc28cdfeaa7d62e2fce3f47c82c982008180 (diff)
gender nb
-rw-r--r--megapixels/notebooks/face_analysis/age_gender.ipynb187
1 files changed, 187 insertions, 0 deletions
diff --git a/megapixels/notebooks/face_analysis/age_gender.ipynb b/megapixels/notebooks/face_analysis/age_gender.ipynb
index 98a18fc6..4f5b5cc7 100644
--- a/megapixels/notebooks/face_analysis/age_gender.ipynb
+++ b/megapixels/notebooks/face_analysis/age_gender.ipynb
@@ -248,6 +248,193 @@
},
{
"cell_type": "code",
+ "execution_count": 319,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pywavefront"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 320,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pywavefront\n",
+ "\n",
+ "fp_obj = '/home/adam/Downloads/faces/Hillary_Clinton_official_Secretary_of_State_portrait_crop_0.obj'\n",
+ "scene = pywavefront.Wavefront(fp_obj, strict=True, encoding=\"iso-8859-1\", parse=False)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 336,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "None [<pywavefront.material.Material object at 0x7fb2aae12c88>]\n"
+ ]
+ }
+ ],
+ "source": [
+ "for k, v in scene.meshes.items():\n",
+ " print(k, v.materials)\n",
+ " break"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 332,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "C3F_V3F\n",
+ "133.0\n"
+ ]
+ },
+ {
+ "ename": "TypeError",
+ "evalue": "'NoneType' object is not subscriptable",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m<ipython-input-332-0a9430508b22>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;31m# Contains the vertex list of floats in the format described above\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmaterial\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvertices\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmaterial\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtexture\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;31m# Material properties\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable"
+ ]
+ }
+ ],
+ "source": [
+ "# Iterate vertex data collected in each material\n",
+ "for name, material in scene.materials.items():\n",
+ " # Contains the vertex format (string) such as \"T2F_N3F_V3F\"\n",
+ " # T2F, C3F, N3F and V3F may appear in this string\n",
+ " print(material.vertex_format)\n",
+ " # Contains the vertex list of floats in the format described above\n",
+ " print(material.vertices[0])\n",
+ " print(material.texture[0:10])\n",
+ " break\n",
+ " # Material properties\n",
+ " material.diffuse\n",
+ " material.ambient\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 356,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "a = np.array([[1,100,10], [2,2,12], [3,3,13]])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 358,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "b = np.array([np.min(a[:, 0]), np.min(a[:, 1]), np.min(a[:, 2])]) "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 373,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(5, 3)\n",
+ "['b' 'g' 'r']\n",
+ "(5, 3)\n",
+ "['r' 'g' 'b']\n"
+ ]
+ }
+ ],
+ "source": [
+ "colors = np.array([['b','g','r'], ['b','g','r'], ['b','g','r'], ['b','g','r'], ['b','g','r']])\n",
+ "print(colors.shape)\n",
+ "print(colors[0])\n",
+ "colors = np.array([c[::-1] for c in colors])\n",
+ "print(colors.shape)\n",
+ "print(colors[0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 348,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([[ 1., 100., 1.],\n",
+ " [ 2., 2., 2.],\n",
+ " [ 3., 3., 3.]])"
+ ]
+ },
+ "execution_count": 348,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "b"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 374,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from pathlib import Path"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 375,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "PosixPath('/media/adam/ah8tb/work/megapixels_dev/megapixels/notebooks/face_analysis')"
+ ]
+ },
+ "execution_count": 375,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "\n",
+ "\n",
+ "Path.cwd()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 377,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "a = '/path/to/file.mp3'\n",
+ "fpp_a = Path(a)"
+ ]
+ },
+ {
+ "cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],