{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "6003f943-4355-446f-a48a-2ceb3b194f35", "metadata": {}, "outputs": [], "source": [ "#| default_exp app" ] }, { "cell_type": "markdown", "id": "120a54e9-3144-4bb7-ba4b-949c80951030", "metadata": {}, "source": [ "# Snake Image Classification" ] }, { "cell_type": "code", "execution_count": 25, "id": "eda4b34e-199c-4358-baf8-235bc0b995c7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('2.7.12', '0.8.6dev0', '0.10.2', '1.5.2', '1.3.0')" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import toml\n", "import fastai\n", "import timm\n", "import pandas\n", "import albumentations\n", "fastai.__version__, timm.__version__ , toml.__version__, pandas.__version__, albumentations.__version__" ] }, { "cell_type": "code", "execution_count": 3, "id": "dc77cb01-22f1-4d1c-bdd2-ab1caff5123a", "metadata": {}, "outputs": [], "source": [ "#| export\n", "from fastai.vision.all import *\n", "from huggingface_hub import from_pretrained_fastai\n", "import gradio as gr\n", "import wikipedia\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 4, "id": "f8bdf35f-049b-4554-b32c-b07f0095336c", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f9c510daca78426eb98bc06971fd267f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Fetching 4 files: 0%| | 0/4 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#| export\n", "repo_id = \"Jimmie/snake-species-identification\"\n", "\n", "# loading the model from huggingface_hub\n", "learner = from_pretrained_fastai(repo_id)" ] }, { "cell_type": "code", "execution_count": 5, "id": "f2ee25de-552b-4f04-8a3c-ca009d67f55e", "metadata": {}, "outputs": [], "source": [ "#| export\n", "path = Path('demo-images/')\n", "countries = pd.read_csv('species_to_country_mapping.csv', index_col=0)" ] }, { "cell_type": "code", "execution_count": 6, "id": "bd470688-5ed8-4620-9a9e-735ae0b8b79e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[Path('demo-images/masticophis.jpg'),\n", " Path('demo-images/micrurus.jpg'),\n", " Path('demo-images/agkistrodon.png'),\n", " Path('demo-images/Pantherophis.jpg'),\n", " Path('demo-images/lampropeltis.jpg'),\n", " Path('demo-images/thamnophis.jpg'),\n", " Path('demo-images/natrix.jpg'),\n", " Path('demo-images/nerodia.jpg'),\n", " Path('demo-images/tantilla.jpg'),\n", " Path('demo-images/crotalus.jpg')]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(path.ls())" ] }, { "cell_type": "code", "execution_count": 7, "id": "aee8d52d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | afghanistan | \n", "albania | \n", "algeria | \n", "angola | \n", "anguilla | \n", "antigua and barbuda | \n", "argentina | \n", "armenia | \n", "aruba | \n", "australia | \n", "... | \n", "uruguay | \n", "usa | \n", "uzbekistan | \n", "vanuatu | \n", "venezuela | \n", "vietnam | \n", "western sahara | \n", "yemen | \n", "zambia | \n", "zimbabwe | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Acanthophis antarcticus | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acanthophis cryptamydros | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acanthophis hawkei | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acanthophis laevis | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
Acanthophis praelongus | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
5 rows × 195 columns
\n", "