Spaces:
Sleeping
Sleeping
Commit ·
2d5e6d5
1
Parent(s): ce91d74
Cleaned up processes
Browse files- Pets_Classification/__init__.py +0 -1
- Pets_Classification/app.py +0 -31
- app.html +273 -35
- app.ipynb +0 -0
- app.py +9 -41
Pets_Classification/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
__version__ = "0.0.1"
|
|
|
|
|
|
Pets_Classification/app.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
| 2 |
-
|
| 3 |
-
# %% auto 0
|
| 4 |
-
__all__ = ['plt', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 5 |
-
|
| 6 |
-
# %% ../app.ipynb 2
|
| 7 |
-
from fastai.vision.all import *
|
| 8 |
-
import gradio as gr
|
| 9 |
-
import pathlib as pl
|
| 10 |
-
plt = platform.system()
|
| 11 |
-
|
| 12 |
-
def is_cat(x): return x[0].isupper()
|
| 13 |
-
|
| 14 |
-
# %% ../app.ipynb 4
|
| 15 |
-
if plt == 'Linux' : pl.WindowsPath = pl.PosixPath
|
| 16 |
-
learn = load_learner('model.pkl')
|
| 17 |
-
|
| 18 |
-
# %% ../app.ipynb 6
|
| 19 |
-
categories = ('Dog', 'Cat')
|
| 20 |
-
|
| 21 |
-
def classify_image(img):
|
| 22 |
-
pred,idx,probs = learn.predict(img)
|
| 23 |
-
return dict(zip(categories, map(float,probs)))
|
| 24 |
-
|
| 25 |
-
# %% ../app.ipynb 8
|
| 26 |
-
image = gr.Image(height=192, width = 192)
|
| 27 |
-
label = gr.Label()
|
| 28 |
-
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 29 |
-
|
| 30 |
-
intf = gr.Interface(fn=classify_image, inputs = image, outputs=label, examples = examples)
|
| 31 |
-
intf.launch(inline=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.html
CHANGED
|
@@ -67,6 +67,9 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
| 67 |
<script src="app_files/libs/bootstrap/bootstrap.min.js"></script>
|
| 68 |
<link href="app_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 69 |
<link href="app_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
</head>
|
|
@@ -79,53 +82,288 @@ pre > code.sourceCode > span > a:first-child::before { text-decoration: underlin
|
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
-
<div class="cell">
|
| 83 |
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>pip install gradio<span class="op">==</span><span class="fl">3.50</span></span>
|
| 84 |
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>pip install fastai</span>
|
| 85 |
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>pip install ipywidgets</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
</div>
|
| 87 |
-
<div class="cell">
|
| 88 |
-
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> fastai.vision.<span class="bu">all</span> <span class="im">import</span> <span class="op">*</span></span>
|
| 89 |
-
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> gradio <span class="im">as</span> gr</span>
|
| 90 |
-
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pathlib <span class="im">as</span> pl</span>
|
| 91 |
-
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>plt <span class="op">=</span> platform.system()</span>
|
| 92 |
-
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
|
| 93 |
-
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> is_cat(x): <span class="cf">return</span> x[<span class="dv">0</span>].isupper()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 94 |
</div>
|
| 95 |
-
<div class="cell">
|
| 96 |
-
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>im <span class="
|
| 97 |
-
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>
|
| 98 |
-
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>
|
|
|
|
|
|
|
|
|
|
| 99 |
</div>
|
| 100 |
-
<div class="cell">
|
| 101 |
-
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>
|
| 102 |
-
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>
|
|
|
|
|
|
|
|
|
|
| 103 |
</div>
|
| 104 |
-
<div class="cell">
|
| 105 |
-
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>learn.predict(im)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 106 |
</div>
|
| 107 |
-
<div class="cell">
|
| 108 |
-
<div class="sourceCode cell-code" id="
|
| 109 |
-
<span id="
|
| 110 |
-
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> classify_image(img):</span>
|
| 111 |
-
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> pred,idx,probs <span class="op">=</span> learn.predict(img)</span>
|
| 112 |
-
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="bu">dict</span>(<span class="bu">zip</span>(categories, <span class="bu">map</span>(<span class="bu">float</span>,probs)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 113 |
</div>
|
| 114 |
-
<div class="cell">
|
| 115 |
-
<div class="sourceCode cell-code" id="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
</div>
|
| 117 |
-
<div class="cell">
|
| 118 |
-
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>image <span class="op">=</span> gr.Image(height<span class="op">=</span><span class="dv">192</span>, width <span class="op">=</span> <span class="dv">192</span>)</span>
|
| 119 |
-
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>label <span class="op">=</span> gr.Label()</span>
|
| 120 |
-
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>examples <span class="op">=</span> [<span class="st">'dog.jpg'</span>, <span class="st">'cat.jpg'</span>, <span class="st">'dunno.jpg'</span>]</span>
|
| 121 |
-
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a></span>
|
| 122 |
-
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a>intf <span class="op">=</span> gr.Interface(fn<span class="op">=</span>classify_image, inputs <span class="op">=</span> image, outputs<span class="op">=</span>label, examples <span class="op">=</span> examples)</span>
|
| 123 |
-
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>intf.launch(inline<span class="op">=</span><span class="va">False</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 124 |
</div>
|
| 125 |
<div class="cell">
|
| 126 |
-
<div class="sourceCode cell-code" id="
|
| 127 |
-
<span id="
|
| 128 |
-
<span id="
|
| 129 |
</div>
|
| 130 |
|
| 131 |
</main>
|
|
|
|
| 67 |
<script src="app_files/libs/bootstrap/bootstrap.min.js"></script>
|
| 68 |
<link href="app_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 69 |
<link href="app_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
|
| 70 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" integrity="sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==" crossorigin="anonymous"></script>
|
| 71 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
|
| 72 |
+
<script type="application/javascript">define('jquery', [],function() {return window.jQuery;})</script>
|
| 73 |
|
| 74 |
|
| 75 |
</head>
|
|
|
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
+
<div class="cell" data-execution_count="1">
|
| 86 |
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>pip install gradio<span class="op">==</span><span class="fl">3.50</span></span>
|
| 87 |
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>pip install fastai</span>
|
| 88 |
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>pip install ipywidgets</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 89 |
+
<div class="cell-output cell-output-stdout">
|
| 90 |
+
<pre><code>Defaulting to user installation because normal site-packages is not writeable
|
| 91 |
+
Requirement already satisfied: gradio==3.50 in /usr/local/lib/python3.10/dist-packages (3.50.0)
|
| 92 |
+
Requirement already satisfied: uvicorn>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.25.0)
|
| 93 |
+
Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (4.9.0)
|
| 94 |
+
Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (10.2.0)
|
| 95 |
+
Requirement already satisfied: aiofiles<24.0,>=22.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (23.2.1)
|
| 96 |
+
Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (2.1.4)
|
| 97 |
+
Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (2.1.3)
|
| 98 |
+
Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (2.5.3)
|
| 99 |
+
Requirement already satisfied: websockets<12.0,>=10.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (11.0.3)
|
| 100 |
+
Requirement already satisfied: python-multipart in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.0.6)
|
| 101 |
+
Requirement already satisfied: gradio-client==0.6.1 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.6.1)
|
| 102 |
+
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (23.2)
|
| 103 |
+
Requirement already satisfied: numpy~=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (1.26.2)
|
| 104 |
+
Requirement already satisfied: orjson~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (3.9.10)
|
| 105 |
+
Requirement already satisfied: huggingface-hub>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.20.1)
|
| 106 |
+
Requirement already satisfied: ffmpy in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.3.1)
|
| 107 |
+
Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (3.8.2)
|
| 108 |
+
Requirement already satisfied: importlib-resources<7.0,>=1.3 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (6.1.1)
|
| 109 |
+
Requirement already satisfied: requests~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (2.31.0)
|
| 110 |
+
Requirement already satisfied: pydub in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.25.1)
|
| 111 |
+
Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (3.1.2)
|
| 112 |
+
Requirement already satisfied: fastapi in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.108.0)
|
| 113 |
+
Requirement already satisfied: altair<6.0,>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (5.2.0)
|
| 114 |
+
Requirement already satisfied: semantic-version~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (2.10.0)
|
| 115 |
+
Requirement already satisfied: httpx in /usr/local/lib/python3.10/dist-packages (from gradio==3.50) (0.26.0)
|
| 116 |
+
Requirement already satisfied: pyyaml<7.0,>=5.0 in /usr/lib/python3/dist-packages (from gradio==3.50) (5.4.1)
|
| 117 |
+
Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client==0.6.1->gradio==3.50) (2023.12.2)
|
| 118 |
+
Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio==3.50) (4.20.0)
|
| 119 |
+
Requirement already satisfied: toolz in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio==3.50) (0.12.0)
|
| 120 |
+
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio==3.50) (3.13.1)
|
| 121 |
+
Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio==3.50) (4.66.1)
|
| 122 |
+
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio==3.50) (1.2.0)
|
| 123 |
+
Requirement already satisfied: python-dateutil>=2.7 in /home/devcontainers/.local/lib/python3.10/site-packages (from matplotlib~=3.0->gradio==3.50) (2.8.2)
|
| 124 |
+
Requirement already satisfied: pyparsing>=2.3.1 in /usr/lib/python3/dist-packages (from matplotlib~=3.0->gradio==3.50) (2.4.7)
|
| 125 |
+
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio==3.50) (4.47.0)
|
| 126 |
+
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio==3.50) (0.12.1)
|
| 127 |
+
Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio==3.50) (1.4.5)
|
| 128 |
+
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio==3.50) (2023.3.post1)
|
| 129 |
+
Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio==3.50) (2023.4)
|
| 130 |
+
Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,<3.0.0,>=1.7.4->gradio==3.50) (0.6.0)
|
| 131 |
+
Requirement already satisfied: pydantic-core==2.14.6 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,<3.0.0,>=1.7.4->gradio==3.50) (2.14.6)
|
| 132 |
+
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio==3.50) (3.3.2)
|
| 133 |
+
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio==3.50) (2.1.0)
|
| 134 |
+
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio==3.50) (2023.11.17)
|
| 135 |
+
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio==3.50) (3.6)
|
| 136 |
+
Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.10/dist-packages (from uvicorn>=0.14.0->gradio==3.50) (8.1.7)
|
| 137 |
+
Requirement already satisfied: h11>=0.8 in /usr/local/lib/python3.10/dist-packages (from uvicorn>=0.14.0->gradio==3.50) (0.14.0)
|
| 138 |
+
Requirement already satisfied: starlette<0.33.0,>=0.29.0 in /usr/local/lib/python3.10/dist-packages (from fastapi->gradio==3.50) (0.32.0.post1)
|
| 139 |
+
Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio==3.50) (1.3.0)
|
| 140 |
+
Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx->gradio==3.50) (1.0.2)
|
| 141 |
+
Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio==3.50) (4.2.0)
|
| 142 |
+
Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio==3.50) (0.16.2)
|
| 143 |
+
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio==3.50) (2023.12.1)
|
| 144 |
+
Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio==3.50) (0.32.0)
|
| 145 |
+
Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio==3.50) (23.2.0)
|
| 146 |
+
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio==3.50) (1.16.0)
|
| 147 |
+
Requirement already satisfied: exceptiongroup>=1.0.2 in /home/devcontainers/.local/lib/python3.10/site-packages (from anyio->httpx->gradio==3.50) (1.2.0)
|
| 148 |
+
Note: you may need to restart the kernel to use updated packages.
|
| 149 |
+
Defaulting to user installation because normal site-packages is not writeable
|
| 150 |
+
Requirement already satisfied: fastai in /usr/local/lib/python3.10/dist-packages (2.7.13)
|
| 151 |
+
Requirement already satisfied: spacy<4 in /usr/local/lib/python3.10/dist-packages (from fastai) (3.7.2)
|
| 152 |
+
Requirement already satisfied: torch<2.2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from fastai) (2.1.2)
|
| 153 |
+
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (from fastai) (22.0.2)
|
| 154 |
+
Requirement already satisfied: fastprogress>=0.2.4 in /usr/local/lib/python3.10/dist-packages (from fastai) (1.0.3)
|
| 155 |
+
Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from fastai) (1.11.4)
|
| 156 |
+
Requirement already satisfied: fastcore<1.6,>=1.5.29 in /usr/local/lib/python3.10/dist-packages (from fastai) (1.5.29)
|
| 157 |
+
Requirement already satisfied: fastdownload<2,>=0.0.5 in /usr/local/lib/python3.10/dist-packages (from fastai) (0.0.7)
|
| 158 |
+
Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from fastai) (2.1.4)
|
| 159 |
+
Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from fastai) (10.2.0)
|
| 160 |
+
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from fastai) (5.4.1)
|
| 161 |
+
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from fastai) (1.3.2)
|
| 162 |
+
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from fastai) (23.2)
|
| 163 |
+
Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from fastai) (3.8.2)
|
| 164 |
+
Requirement already satisfied: torchvision>=0.11 in /usr/local/lib/python3.10/dist-packages (from fastai) (0.16.2)
|
| 165 |
+
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from fastai) (2.31.0)
|
| 166 |
+
Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.3.0)
|
| 167 |
+
Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.5.3)
|
| 168 |
+
Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.1.2)
|
| 169 |
+
Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.1.2)
|
| 170 |
+
Requirement already satisfied: weasel<0.4.0,>=0.1.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (0.3.4)
|
| 171 |
+
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.0.8)
|
| 172 |
+
Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.4.8)
|
| 173 |
+
Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (2.0.10)
|
| 174 |
+
Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.0.5)
|
| 175 |
+
Requirement already satisfied: typer<0.10.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (0.9.0)
|
| 176 |
+
Requirement already satisfied: thinc<8.3.0,>=8.1.8 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (8.2.2)
|
| 177 |
+
Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (6.4.0)
|
| 178 |
+
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.0.10)
|
| 179 |
+
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.0.9)
|
| 180 |
+
Requirement already satisfied: numpy>=1.19.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (1.26.2)
|
| 181 |
+
Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (4.66.1)
|
| 182 |
+
Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /usr/local/lib/python3.10/dist-packages (from spacy<4->fastai) (3.0.12)
|
| 183 |
+
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from spacy<4->fastai) (59.6.0)
|
| 184 |
+
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (3.6)
|
| 185 |
+
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (2023.11.17)
|
| 186 |
+
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (3.3.2)
|
| 187 |
+
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->fastai) (2.1.0)
|
| 188 |
+
Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (10.3.2.106)
|
| 189 |
+
Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (11.4.5.107)
|
| 190 |
+
Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2.1.0)
|
| 191 |
+
Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (12.1.0.106)
|
| 192 |
+
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (3.13.1)
|
| 193 |
+
Requirement already satisfied: nvidia-cudnn-cu12==8.9.2.26 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (8.9.2.26)
|
| 194 |
+
Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (12.1.3.1)
|
| 195 |
+
Requirement already satisfied: nvidia-nccl-cu12==2.18.1 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2.18.1)
|
| 196 |
+
Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (11.0.2.54)
|
| 197 |
+
Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (12.1.105)
|
| 198 |
+
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (4.9.0)
|
| 199 |
+
Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (12.1.105)
|
| 200 |
+
Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (12.1.105)
|
| 201 |
+
Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (2023.12.2)
|
| 202 |
+
Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (1.12)
|
| 203 |
+
Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (3.2.1)
|
| 204 |
+
Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch<2.2,>=1.10->fastai) (12.1.105)
|
| 205 |
+
Requirement already satisfied: nvidia-nvjitlink-cu12 in /usr/local/lib/python3.10/dist-packages (from nvidia-cusolver-cu12==11.4.5.107->torch<2.2,>=1.10->fastai) (12.3.101)
|
| 206 |
+
Requirement already satisfied: python-dateutil>=2.7 in /home/devcontainers/.local/lib/python3.10/site-packages (from matplotlib->fastai) (2.8.2)
|
| 207 |
+
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (1.2.0)
|
| 208 |
+
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (0.12.1)
|
| 209 |
+
Requirement already satisfied: pyparsing>=2.3.1 in /usr/lib/python3/dist-packages (from matplotlib->fastai) (2.4.7)
|
| 210 |
+
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (4.47.0)
|
| 211 |
+
Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->fastai) (1.4.5)
|
| 212 |
+
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->fastai) (2023.3.post1)
|
| 213 |
+
Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->fastai) (2023.4)
|
| 214 |
+
Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->fastai) (1.3.2)
|
| 215 |
+
Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->fastai) (3.2.0)
|
| 216 |
+
Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4->fastai) (0.6.0)
|
| 217 |
+
Requirement already satisfied: pydantic-core==2.14.6 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4->fastai) (2.14.6)
|
| 218 |
+
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.7->matplotlib->fastai) (1.16.0)
|
| 219 |
+
Requirement already satisfied: blis<0.8.0,>=0.7.8 in /usr/local/lib/python3.10/dist-packages (from thinc<8.3.0,>=8.1.8->spacy<4->fastai) (0.7.11)
|
| 220 |
+
Requirement already satisfied: confection<1.0.0,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from thinc<8.3.0,>=8.1.8->spacy<4->fastai) (0.1.4)
|
| 221 |
+
Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/local/lib/python3.10/dist-packages (from typer<0.10.0,>=0.3.0->spacy<4->fastai) (8.1.7)
|
| 222 |
+
Requirement already satisfied: cloudpathlib<0.17.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from weasel<0.4.0,>=0.1.0->spacy<4->fastai) (0.16.0)
|
| 223 |
+
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->spacy<4->fastai) (2.1.3)
|
| 224 |
+
Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch<2.2,>=1.10->fastai) (1.3.0)
|
| 225 |
+
Note: you may need to restart the kernel to use updated packages.
|
| 226 |
+
Defaulting to user installation because normal site-packages is not writeable
|
| 227 |
+
Requirement already satisfied: ipywidgets in /usr/local/lib/python3.10/dist-packages (8.0.4)
|
| 228 |
+
Requirement already satisfied: widgetsnbextension~=4.0 in /usr/local/lib/python3.10/dist-packages (from ipywidgets) (4.0.9)
|
| 229 |
+
Requirement already satisfied: ipython>=6.1.0 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipywidgets) (8.19.0)
|
| 230 |
+
Requirement already satisfied: ipykernel>=4.5.1 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipywidgets) (6.28.0)
|
| 231 |
+
Requirement already satisfied: jupyterlab-widgets~=3.0 in /usr/local/lib/python3.10/dist-packages (from ipywidgets) (3.0.9)
|
| 232 |
+
Requirement already satisfied: traitlets>=4.3.1 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipywidgets) (5.14.1)
|
| 233 |
+
Requirement already satisfied: debugpy>=1.6.5 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (1.8.0)
|
| 234 |
+
Requirement already satisfied: comm>=0.1.1 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (0.2.1)
|
| 235 |
+
Requirement already satisfied: nest-asyncio in /usr/local/lib/python3.10/dist-packages (from ipykernel>=4.5.1->ipywidgets) (1.5.8)
|
| 236 |
+
Requirement already satisfied: pyzmq>=24 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (25.1.2)
|
| 237 |
+
Requirement already satisfied: tornado>=6.1 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (6.4)
|
| 238 |
+
Requirement already satisfied: matplotlib-inline>=0.1 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (0.1.6)
|
| 239 |
+
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from ipykernel>=4.5.1->ipywidgets) (23.2)
|
| 240 |
+
Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from ipykernel>=4.5.1->ipywidgets) (5.9.7)
|
| 241 |
+
Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (5.7.0)
|
| 242 |
+
Requirement already satisfied: jupyter-client>=6.1.12 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipykernel>=4.5.1->ipywidgets) (8.6.0)
|
| 243 |
+
Requirement already satisfied: pexpect>4.3 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets) (4.9.0)
|
| 244 |
+
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets) (3.0.43)
|
| 245 |
+
Requirement already satisfied: decorator in /home/devcontainers/.local/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets) (5.1.1)
|
| 246 |
+
Requirement already satisfied: exceptiongroup in /home/devcontainers/.local/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets) (1.2.0)
|
| 247 |
+
Requirement already satisfied: pygments>=2.4.0 in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets) (2.17.2)
|
| 248 |
+
Requirement already satisfied: jedi>=0.16 in /home/devcontainers/.local/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets) (0.19.1)
|
| 249 |
+
Requirement already satisfied: stack-data in /home/devcontainers/.local/lib/python3.10/site-packages (from ipython>=6.1.0->ipywidgets) (0.6.3)
|
| 250 |
+
Requirement already satisfied: parso<0.9.0,>=0.8.3 in /home/devcontainers/.local/lib/python3.10/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets) (0.8.3)
|
| 251 |
+
Requirement already satisfied: python-dateutil>=2.8.2 in /home/devcontainers/.local/lib/python3.10/site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets) (2.8.2)
|
| 252 |
+
Requirement already satisfied: platformdirs>=2.5 in /home/devcontainers/.local/lib/python3.10/site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel>=4.5.1->ipywidgets) (4.1.0)
|
| 253 |
+
Requirement already satisfied: ptyprocess>=0.5 in /home/devcontainers/.local/lib/python3.10/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets) (0.7.0)
|
| 254 |
+
Requirement already satisfied: wcwidth in /usr/local/lib/python3.10/dist-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets) (0.2.12)
|
| 255 |
+
Requirement already satisfied: asttokens>=2.1.0 in /home/devcontainers/.local/lib/python3.10/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.4.1)
|
| 256 |
+
Requirement already satisfied: pure-eval in /home/devcontainers/.local/lib/python3.10/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (0.2.2)
|
| 257 |
+
Requirement already satisfied: executing>=1.2.0 in /home/devcontainers/.local/lib/python3.10/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.0.1)
|
| 258 |
+
Requirement already satisfied: six>=1.12.0 in /usr/lib/python3/dist-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets) (1.16.0)
|
| 259 |
+
Note: you may need to restart the kernel to use updated packages.</code></pre>
|
| 260 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
</div>
|
| 262 |
+
<div class="cell" data-execution_count="2">
|
| 263 |
+
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> fastai.vision.<span class="bu">all</span> <span class="im">import</span> <span class="op">*</span></span>
|
| 264 |
+
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> gradio <span class="im">as</span> gr</span>
|
| 265 |
+
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pathlib <span class="im">as</span> pl</span>
|
| 266 |
+
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>plt <span class="op">=</span> platform.system()</span>
|
| 267 |
+
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
|
| 268 |
+
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> is_cat(x): <span class="cf">return</span> x[<span class="dv">0</span>].isupper()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 269 |
</div>
|
| 270 |
+
<div class="cell" data-execution_count="3">
|
| 271 |
+
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>im <span class="op">=</span> PILImage.create(<span class="st">'dog.jpg'</span>)</span>
|
| 272 |
+
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>im.thumbnail((<span class="dv">192</span>,<span class="dv">192</span>))</span>
|
| 273 |
+
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>im</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 274 |
+
<div class="cell-output cell-output-display" data-execution_count="3">
|
| 275 |
+
<p><img src="app_files/figure-html/cell-4-output-1.png" class="img-fluid"></p>
|
| 276 |
</div>
|
|
|
|
|
|
|
| 277 |
</div>
|
| 278 |
+
<div class="cell" data-execution_count="4">
|
| 279 |
+
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> plt <span class="op">==</span> <span class="st">'Linux'</span> : pl.WindowsPath <span class="op">=</span> pl.PosixPath</span>
|
| 280 |
+
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>learn <span class="op">=</span> load_learner(<span class="st">'model.pkl'</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
|
|
|
|
|
|
|
|
|
| 281 |
</div>
|
| 282 |
+
<div class="cell" data-execution_count="5">
|
| 283 |
+
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>learn.predict(im)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 284 |
+
<div class="cell-output cell-output-stderr">
|
| 285 |
+
<pre><code>/usr/local/lib/python3.10/dist-packages/fastai/torch_core.py:263: UserWarning: 'has_mps' is deprecated, please use 'torch.backends.mps.is_built()'
|
| 286 |
+
return getattr(torch, 'has_mps', False)</code></pre>
|
| 287 |
+
</div>
|
| 288 |
+
<div class="cell-output cell-output-display">
|
| 289 |
+
|
| 290 |
+
<style>
|
| 291 |
+
/* Turns off some styling */
|
| 292 |
+
progress {
|
| 293 |
+
/* gets rid of default border in Firefox and Opera. */
|
| 294 |
+
border: none;
|
| 295 |
+
/* Needs to be in here for Safari polyfill so background images work as expected. */
|
| 296 |
+
background-size: auto;
|
| 297 |
+
}
|
| 298 |
+
progress:not([value]), progress:not([value])::-webkit-progress-bar {
|
| 299 |
+
background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);
|
| 300 |
+
}
|
| 301 |
+
.progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {
|
| 302 |
+
background: #F44336;
|
| 303 |
+
}
|
| 304 |
+
</style>
|
| 305 |
+
</div>
|
| 306 |
+
<div class="cell-output cell-output-display">
|
| 307 |
+
|
| 308 |
+
</div>
|
| 309 |
+
<div class="cell-output cell-output-display" data-execution_count="5">
|
| 310 |
+
<pre><code>('False', tensor(0), tensor([9.9995e-01, 4.5986e-05]))</code></pre>
|
| 311 |
+
</div>
|
| 312 |
+
</div>
|
| 313 |
+
<div class="cell" data-execution_count="6">
|
| 314 |
+
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>categories <span class="op">=</span> (<span class="st">'Dog'</span>, <span class="st">'Cat'</span>)</span>
|
| 315 |
+
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a></span>
|
| 316 |
+
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> classify_image(img):</span>
|
| 317 |
+
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> pred,idx,probs <span class="op">=</span> learn.predict(img)</span>
|
| 318 |
+
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="bu">dict</span>(<span class="bu">zip</span>(categories, <span class="bu">map</span>(<span class="bu">float</span>,probs)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 319 |
+
</div>
|
| 320 |
+
<div class="cell" data-execution_count="7">
|
| 321 |
+
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>classify_image(im)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 322 |
+
<div class="cell-output cell-output-display">
|
| 323 |
+
|
| 324 |
+
<style>
|
| 325 |
+
/* Turns off some styling */
|
| 326 |
+
progress {
|
| 327 |
+
/* gets rid of default border in Firefox and Opera. */
|
| 328 |
+
border: none;
|
| 329 |
+
/* Needs to be in here for Safari polyfill so background images work as expected. */
|
| 330 |
+
background-size: auto;
|
| 331 |
+
}
|
| 332 |
+
progress:not([value]), progress:not([value])::-webkit-progress-bar {
|
| 333 |
+
background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);
|
| 334 |
+
}
|
| 335 |
+
.progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {
|
| 336 |
+
background: #F44336;
|
| 337 |
+
}
|
| 338 |
+
</style>
|
| 339 |
+
</div>
|
| 340 |
+
<div class="cell-output cell-output-display">
|
| 341 |
+
|
| 342 |
+
</div>
|
| 343 |
+
<div class="cell-output cell-output-display" data-execution_count="7">
|
| 344 |
+
<pre><code>{'Dog': 0.9999539852142334, 'Cat': 4.598570376401767e-05}</code></pre>
|
| 345 |
+
</div>
|
| 346 |
+
</div>
|
| 347 |
+
<div class="cell" data-execution_count="8">
|
| 348 |
+
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>image <span class="op">=</span> gr.Image(height<span class="op">=</span><span class="dv">192</span>, width <span class="op">=</span> <span class="dv">192</span>)</span>
|
| 349 |
+
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>label <span class="op">=</span> gr.Label()</span>
|
| 350 |
+
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a>examples <span class="op">=</span> [<span class="st">'dog.jpg'</span>, <span class="st">'cat.jpg'</span>, <span class="st">'dunno.jpg'</span>]</span>
|
| 351 |
+
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a></span>
|
| 352 |
+
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>intf <span class="op">=</span> gr.Interface(fn<span class="op">=</span>classify_image, inputs <span class="op">=</span> image, outputs<span class="op">=</span>label, examples <span class="op">=</span> examples)</span>
|
| 353 |
+
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a>intf.launch(inline<span class="op">=</span><span class="va">False</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 354 |
+
<div class="cell-output cell-output-stdout">
|
| 355 |
+
<pre><code>Running on local URL: http://127.0.0.1:7860
|
| 356 |
+
|
| 357 |
+
To create a public link, set `share=True` in `launch()`.</code></pre>
|
| 358 |
+
</div>
|
| 359 |
+
<div class="cell-output cell-output-display" data-execution_count="8">
|
| 360 |
+
<pre><code></code></pre>
|
| 361 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
</div>
|
| 363 |
<div class="cell">
|
| 364 |
+
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> jupytext</span>
|
| 365 |
+
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a>nb <span class="op">=</span> jupytext.read(<span class="st">"app.ipynb"</span>)</span>
|
| 366 |
+
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a>jupytext.write(nb, <span class="st">"app.py"</span>, fmt <span class="op">=</span> <span class="st">"qmd"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
|
| 367 |
</div>
|
| 368 |
|
| 369 |
</main>
|
app.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
CHANGED
|
@@ -1,23 +1,9 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
#
|
| 7 |
-
# format_version: '1.5'
|
| 8 |
-
# jupytext_version: 1.16.0
|
| 9 |
-
# kernelspec:
|
| 10 |
-
# display_name: Python 3 (ipykernel)
|
| 11 |
-
# language: python
|
| 12 |
-
# name: python3
|
| 13 |
-
# ---
|
| 14 |
-
|
| 15 |
-
# + tags=["hide-input"]
|
| 16 |
-
# %pip install gradio==3.50
|
| 17 |
-
# %pip install fastai
|
| 18 |
-
# %pip install ipywidgets
|
| 19 |
-
|
| 20 |
-
# +
|
| 21 |
from fastai.vision.all import *
|
| 22 |
import gradio as gr
|
| 23 |
import pathlib as pl
|
|
@@ -25,39 +11,21 @@ plt = platform.system()
|
|
| 25 |
|
| 26 |
def is_cat(x): return x[0].isupper()
|
| 27 |
|
| 28 |
-
|
| 29 |
-
# + tags=["hide-input"]
|
| 30 |
-
im = PILImage.create('dog.jpg')
|
| 31 |
-
im.thumbnail((192,192))
|
| 32 |
-
im
|
| 33 |
-
# -
|
| 34 |
-
|
| 35 |
if plt == 'Linux' : pl.WindowsPath = pl.PosixPath
|
| 36 |
learn = load_learner('model.pkl')
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
learn.predict(im)
|
| 40 |
-
|
| 41 |
-
# +
|
| 42 |
categories = ('Dog', 'Cat')
|
| 43 |
|
| 44 |
def classify_image(img):
|
| 45 |
pred,idx,probs = learn.predict(img)
|
| 46 |
return dict(zip(categories, map(float,probs)))
|
| 47 |
|
| 48 |
-
|
| 49 |
-
# + tags=["hide-input"]
|
| 50 |
-
classify_image(im)
|
| 51 |
-
|
| 52 |
-
# +
|
| 53 |
image = gr.Image(height=192, width = 192)
|
| 54 |
label = gr.Label()
|
| 55 |
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 56 |
|
| 57 |
intf = gr.Interface(fn=classify_image, inputs = image, outputs=label, examples = examples)
|
| 58 |
intf.launch(inline=False)
|
| 59 |
-
|
| 60 |
-
# + tags=["hide-input"]
|
| 61 |
-
import jupytext
|
| 62 |
-
nb = jupytext.read("app.ipynb")
|
| 63 |
-
jupytext.write(nb, "app.py", fmt = "qmd")
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['plt', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% ../app.ipynb 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from fastai.vision.all import *
|
| 8 |
import gradio as gr
|
| 9 |
import pathlib as pl
|
|
|
|
| 11 |
|
| 12 |
def is_cat(x): return x[0].isupper()
|
| 13 |
|
| 14 |
+
# %% ../app.ipynb 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
if plt == 'Linux' : pl.WindowsPath = pl.PosixPath
|
| 16 |
learn = load_learner('model.pkl')
|
| 17 |
|
| 18 |
+
# %% ../app.ipynb 6
|
|
|
|
|
|
|
|
|
|
| 19 |
categories = ('Dog', 'Cat')
|
| 20 |
|
| 21 |
def classify_image(img):
|
| 22 |
pred,idx,probs = learn.predict(img)
|
| 23 |
return dict(zip(categories, map(float,probs)))
|
| 24 |
|
| 25 |
+
# %% ../app.ipynb 8
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
image = gr.Image(height=192, width = 192)
|
| 27 |
label = gr.Label()
|
| 28 |
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 29 |
|
| 30 |
intf = gr.Interface(fn=classify_image, inputs = image, outputs=label, examples = examples)
|
| 31 |
intf.launch(inline=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|