|
5 | 5 | "colab": {
|
6 | 6 | "name": "image_classification_api.ipynb",
|
7 | 7 | "provenance": [],
|
8 |
| - "authorship_tag": "ABX9TyPfIvL8gBIX/AmhLYjFsMxz", |
| 8 | + "authorship_tag": "ABX9TyMhXgOvQyLiMY4uFPYQMak+", |
9 | 9 | "include_colab_link": true
|
10 | 10 | },
|
11 | 11 | "kernelspec": {
|
|
182 | 182 | "source": [
|
183 | 183 | "## Receive Post request to classify the image included in its body\n",
|
184 | 184 | "\n",
|
185 |
| - "Using **fastapi** lib, we create a path to be used in a post request url to call the function named ***classifyimage***, in the post request body, there should be a json object that has an image in 64-base format.\n", |
186 |
| - "request body ex.:\n", |
| 185 | + "Using **`fastapi`** lib, we create a path to be used in a post request url to call the function named **`classifyimage`**, in the post request body, there should be a json object that has an image in 64-base format.\n", |
| 186 | + "* request body ex.:\n", |
187 | 187 | "```\n",
|
188 | 188 | "{\n",
|
189 | 189 | " file:\"64-base encoded image\"\n",
|
190 | 190 | "}\n",
|
191 | 191 | "```\n",
|
192 | 192 | "\n",
|
193 |
| - "in ***classifyimage*** function:\n", |
| 193 | + "in **`classifyimage`** function:\n", |
| 194 | + "\n", |
| 195 | + "1. Convert the 64-base encoded image to **`png`** file and save the generated image in \"**`imageToSave.png`**\" file.\n", |
| 196 | + "2. call **`get_animal_name`** to get the animal name from the image using image recognition model.\n", |
| 197 | + "3. replace all white spaces in the animal name with underscore ( **`_`** ).\n", |
| 198 | + "4. convert all letters in the animal name to lowercase.\n", |
| 199 | + "5. use **`Classify`** class to classify the animal using its name and return **`True`** if it not a wild animal and return **`False`** otherwise\n", |
| 200 | + "\n", |
| 201 | + "\n", |
194 | 202 | "\n",
|
195 |
| - "* Convert the 64-base encoded image to **png** file and save the generated image in \"imageToSave.png\" file\n", |
196 |
| - "* call *get_animal_name* to get the animal name from the image using image recognition model\n", |
197 | 203 | "\n"
|
198 | 204 | ]
|
199 | 205 | },
|
|
233 | 239 | "execution_count": null,
|
234 | 240 | "outputs": []
|
235 | 241 | },
|
| 242 | + { |
| 243 | + "cell_type": "markdown", |
| 244 | + "metadata": { |
| 245 | + "id": "g0f-oq5kQeRV" |
| 246 | + }, |
| 247 | + "source": [ |
| 248 | + "## **Calssify class**\n", |
| 249 | + "Using wordnet synsets and hypernyms, this class used to know if the animal_name is belong to **`domestic_animal`**, **`birds`** or **`entity`** using **dfs** algorithm.\n", |
| 250 | + "Then if the animal_name belongs to **`domestic_animal`**, **`birds`** then the function returns **`True`**, otherwise returns **`False`**" |
| 251 | + ] |
| 252 | + }, |
236 | 253 | {
|
237 | 254 | "cell_type": "code",
|
238 | 255 | "metadata": {
|
|
0 commit comments