Skip to content

Commit

Permalink
Update parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
VikParuchuri committed Sep 29, 2022
1 parent bb20e0c commit ecc919e
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 141 deletions.
1 change: 1 addition & 0 deletions dog_emotions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ To follow this project, please install the following locally:
* torch
* torchvision
* Pillow
* flickrapi

## Data

Expand Down
41 changes: 16 additions & 25 deletions dog_emotions/clean_images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"cells": [
{
"cell_type": "code",
"execution_count": 111,
"execution_count": 7,
"id": "8dce0353-f881-4e99-83bc-77d88854a7ec",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import os\n",
"import shutil\n",
"from PIL import Image\n",
Expand All @@ -16,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 112,
"execution_count": 8,
"id": "b7727151-3993-443c-9c75-d7a0bdc8b709",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -46,17 +45,17 @@
},
{
"cell_type": "code",
"execution_count": 113,
"execution_count": 9,
"id": "2591fcde-c21f-499c-828b-dd2b9b0999c3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
"559"
]
},
"execution_count": 113,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -67,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 114,
"execution_count": 10,
"id": "f95b1435-1e8a-49b6-8249-6eaa4e79de8d",
"metadata": {},
"outputs": [],
Expand All @@ -77,14 +76,12 @@
" try:\n",
" os.remove(item)\n",
" except PermissionError:\n",
" shutil.rmtree(item)\n",
" except FileNotFoundError:\n",
" print(item)"
" shutil.rmtree(item)"
]
},
{
"cell_type": "code",
"execution_count": 115,
"execution_count": 11,
"id": "c9f85000-7533-46a4-a113-be3246773da1",
"metadata": {},
"outputs": [],
Expand All @@ -94,7 +91,7 @@
},
{
"cell_type": "code",
"execution_count": 108,
"execution_count": 12,
"id": "06d69004-63bb-42bd-9857-966e828a1667",
"metadata": {},
"outputs": [],
Expand All @@ -113,10 +110,12 @@
" if img.size[0] != img.size[1]:\n",
" img_min_size = min(img.size)\n",
" try:\n",
" img_resized = img.crop(((img.size[0] - img_min_size) // 2,\n",
" img_resized = img.crop((\n",
" (img.size[0] - img_min_size) // 2,\n",
" (img.size[1] - img_min_size) // 2,\n",
" (img.size[0] + img_min_size) // 2,\n",
" (img.size[1] + img_min_size) // 2))\n",
" (img.size[1] + img_min_size) // 2\n",
" ))\n",
"\n",
" except Exception:\n",
" to_delete.append(impath)\n",
Expand All @@ -133,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 109,
"execution_count": 13,
"id": "8a10d424-eccf-41d7-b691-41c6777b8617",
"metadata": {},
"outputs": [
Expand All @@ -143,7 +142,7 @@
"0"
]
},
"execution_count": 109,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -154,21 +153,13 @@
},
{
"cell_type": "code",
"execution_count": 110,
"execution_count": 14,
"id": "c7173e93-2205-4bbb-889e-e527d9ef3dc3",
"metadata": {},
"outputs": [],
"source": [
"remove_items(to_delete)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7768a97a-ba14-4d25-a711-6efe8ba06ec1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
8 changes: 4 additions & 4 deletions dog_emotions/download_images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 1,
"id": "aa537cc8-5908-4633-a220-8ac1ab7d4398",
"metadata": {},
"outputs": [],
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 2,
"id": "4f375fe9-8aef-4339-b690-e66f903c5050",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -84,13 +84,13 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": null,
"id": "39fc3055-2254-4485-a245-4c04899588c4",
"metadata": {},
"outputs": [],
"source": [
"for emotion in FOLDERS:\n",
" download_photos(emotion, 1500)"
" download_photos(emotion, 5000)"
]
},
{
Expand Down
Loading

0 comments on commit ecc919e

Please sign in to comment.