Spaces:
Runtime error
Runtime error
roobsis commited on
Commit ·
3d03641
1
Parent(s): fd42824
updated to work on huggingface
Browse files
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
iface.launch()
|
|
|
|
| 1 |
+
__all__ = ['learn','classify_image','categories','image','label','examples','myinterface']
|
| 2 |
+
|
| 3 |
+
|
| 4 |
import gradio as gr
|
| 5 |
+
from fastai.vision.all import *
|
| 6 |
+
|
| 7 |
+
learn = load_learner('elf_export.pkl')
|
| 8 |
+
categories = ('dragonborne','dwarf','elf','halfling','human','tiefling')
|
| 9 |
+
|
| 10 |
+
def classify_image (img):
|
| 11 |
+
pred,idx,probs = learn.predict(img)
|
| 12 |
+
return dict(zip(categories,map(float,probs)))
|
| 13 |
+
|
| 14 |
+
image = gr.inputs.Image (shape = (192,192))
|
| 15 |
+
label = gr.outputs.Label ()
|
| 16 |
+
examples = ['tiefling.jpg']
|
| 17 |
+
|
| 18 |
+
myinterface = gr.Interface(fn = classify_image,inputs = image,outputs = label, examples = examples)
|
| 19 |
+
myinterface.launch (inline=False)
|
| 20 |
+
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
|
|
|
|
|
elf.ipynb
CHANGED
|
@@ -2,19 +2,37 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [
|
| 8 |
{
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
|
| 13 |
-
"\
|
| 14 |
-
"
|
| 15 |
-
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mgradio\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mgr\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mgreet\u001b[39m(name):\n\u001b[1;32m 4\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mHello \u001b[39m\u001b[39m\"\u001b[39m \u001b[39m+\u001b[39m name \u001b[39m+\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m!!\u001b[39m\u001b[39m\"\u001b[39m\n",
|
| 16 |
-
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'gradio'"
|
| 17 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
],
|
| 20 |
"source": [
|
|
@@ -27,6 +45,43 @@
|
|
| 27 |
"iface.launch()"
|
| 28 |
]
|
| 29 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
{
|
| 31 |
"cell_type": "markdown",
|
| 32 |
"metadata": {},
|
|
@@ -34,7 +89,7 @@
|
|
| 34 |
},
|
| 35 |
{
|
| 36 |
"cell_type": "code",
|
| 37 |
-
"execution_count":
|
| 38 |
"metadata": {},
|
| 39 |
"outputs": [],
|
| 40 |
"source": [
|
|
@@ -44,7 +99,7 @@
|
|
| 44 |
],
|
| 45 |
"metadata": {
|
| 46 |
"kernelspec": {
|
| 47 |
-
"display_name": "
|
| 48 |
"language": "python",
|
| 49 |
"name": "python3"
|
| 50 |
},
|
|
@@ -63,7 +118,7 @@
|
|
| 63 |
"orig_nbformat": 4,
|
| 64 |
"vscode": {
|
| 65 |
"interpreter": {
|
| 66 |
-
"hash": "
|
| 67 |
}
|
| 68 |
}
|
| 69 |
},
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 3,
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [
|
| 8 |
{
|
| 9 |
+
"name": "stdout",
|
| 10 |
+
"output_type": "stream",
|
| 11 |
+
"text": [
|
| 12 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
| 13 |
+
"\n",
|
| 14 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
|
|
|
|
|
|
| 15 |
]
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"data": {
|
| 19 |
+
"text/html": [
|
| 20 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 21 |
+
],
|
| 22 |
+
"text/plain": [
|
| 23 |
+
"<IPython.core.display.HTML object>"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"metadata": {},
|
| 27 |
+
"output_type": "display_data"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"data": {
|
| 31 |
+
"text/plain": []
|
| 32 |
+
},
|
| 33 |
+
"execution_count": 3,
|
| 34 |
+
"metadata": {},
|
| 35 |
+
"output_type": "execute_result"
|
| 36 |
}
|
| 37 |
],
|
| 38 |
"source": [
|
|
|
|
| 45 |
"iface.launch()"
|
| 46 |
]
|
| 47 |
},
|
| 48 |
+
{
|
| 49 |
+
"cell_type": "code",
|
| 50 |
+
"execution_count": 4,
|
| 51 |
+
"metadata": {},
|
| 52 |
+
"outputs": [
|
| 53 |
+
{
|
| 54 |
+
"data": {
|
| 55 |
+
"text/html": [],
|
| 56 |
+
"text/plain": [
|
| 57 |
+
"<IPython.core.display.HTML object>"
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
"metadata": {},
|
| 61 |
+
"output_type": "display_data"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"data": {
|
| 65 |
+
"text/plain": [
|
| 66 |
+
"('elf',\n",
|
| 67 |
+
" TensorBase(2),\n",
|
| 68 |
+
" TensorBase([2.4853e-03, 4.2622e-03, 9.9193e-01, 1.0128e-03, 2.4441e-04,\n",
|
| 69 |
+
" 6.5845e-05]))"
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
"execution_count": 4,
|
| 73 |
+
"metadata": {},
|
| 74 |
+
"output_type": "execute_result"
|
| 75 |
+
}
|
| 76 |
+
],
|
| 77 |
+
"source": [
|
| 78 |
+
"import gradio as gr\n",
|
| 79 |
+
"from fastai.vision.all import *\n",
|
| 80 |
+
"\n",
|
| 81 |
+
"learn = load_learner('elf_export.pkl')\n",
|
| 82 |
+
"learn.predict ('tiefling.jpg')"
|
| 83 |
+
]
|
| 84 |
+
},
|
| 85 |
{
|
| 86 |
"cell_type": "markdown",
|
| 87 |
"metadata": {},
|
|
|
|
| 89 |
},
|
| 90 |
{
|
| 91 |
"cell_type": "code",
|
| 92 |
+
"execution_count": 2,
|
| 93 |
"metadata": {},
|
| 94 |
"outputs": [],
|
| 95 |
"source": [
|
|
|
|
| 99 |
],
|
| 100 |
"metadata": {
|
| 101 |
"kernelspec": {
|
| 102 |
+
"display_name": ".venv",
|
| 103 |
"language": "python",
|
| 104 |
"name": "python3"
|
| 105 |
},
|
|
|
|
| 118 |
"orig_nbformat": 4,
|
| 119 |
"vscode": {
|
| 120 |
"interpreter": {
|
| 121 |
+
"hash": "25613e3f86799f8fc5e212a950c5421386eb1419de4db49b5cf413f9a619b293"
|
| 122 |
}
|
| 123 |
}
|
| 124 |
},
|
tiefling.jpg
ADDED
|