rtalwar commited on
Commit
7166048
·
1 Parent(s): ccb7f64

my first model deployment project

Browse files
Files changed (12) hide show
  1. app.py +29 -0
  2. barfi.webp +0 -0
  3. brocoli.jfif +0 -0
  4. dal.jpg +0 -0
  5. export.pkl +3 -0
  6. gradio_notebook.ipynb +85 -0
  7. gulabjamun.jfif +0 -0
  8. jalebi.jpg +0 -0
  9. ladoo.webp +0 -0
  10. pakora.webp +0 -0
  11. requirements.txt +1 -0
  12. samosa.webp +0 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastcore.all import *
3
+ from fastai.vision.all import *
4
+ import pathlib
5
+ temp = pathlib.PosixPath
6
+ pathlib.PosixPath = pathlib.WindowsPath
7
+ # def greet(name):
8
+ # return "Hello " + name + "!!"
9
+
10
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
11
+ # gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
12
+
13
+ # iface.launch()
14
+
15
+ learn = load_learner('export.pkl')
16
+
17
+ labels = learn.dls.vocab
18
+ def predict(img):
19
+ img = PILImage.create(img)
20
+ pred,pred_idx,probs = learn.predict(img)
21
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
22
+
23
+ title = "my little food Classifier"
24
+ description = "My first foodclassifier trained one some food I know. Made to learn using FastAI and deploying models."
25
+ examples = ['barfi.webp',"brocoli.jfif","dal.jpg","gulabjamun.jfif","jalebi.jpg","ladoo.webp","pakora.webp","samosa.webp"]
26
+ interpretation='default'
27
+ enable_queue=True
28
+
29
+ gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=5),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
barfi.webp ADDED
brocoli.jfif ADDED
Binary file (10.4 kB). View file
 
dal.jpg ADDED
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:400942e94af445f079eb2f58b59e6e44ffd921af76380c9105154a70c5b41a04
3
+ size 102903379
gradio_notebook.ipynb ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "ename": "ModuleNotFoundError",
10
+ "evalue": "No module named 'fastai'",
11
+ "output_type": "error",
12
+ "traceback": [
13
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
14
+ "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
15
+ "Cell \u001b[1;32mIn [2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mfastai\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mvision\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mall\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n",
16
+ "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'fastai'"
17
+ ]
18
+ }
19
+ ],
20
+ "source": [
21
+ "from fastai.vision.all import *\n",
22
+ "\n"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": null,
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "learn = load_learner('export.pkl')\n"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": null,
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "labels = learn.dls.vocab\n",
41
+ "def predict(img):\n",
42
+ " img = PILImage.create(img)\n",
43
+ " pred,pred_idx,probs = learn.predict(img)\n",
44
+ " return {labels[i]: float(probs[i]) for i in range(len(labels))}"
45
+ ]
46
+ },
47
+ {
48
+ "cell_type": "code",
49
+ "execution_count": null,
50
+ "metadata": {},
51
+ "outputs": [],
52
+ "source": [
53
+ "import gradio as gr\n",
54
+ "gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)"
55
+ ]
56
+ }
57
+ ],
58
+ "metadata": {
59
+ "kernelspec": {
60
+ "display_name": "Python 3.9.12 ('base')",
61
+ "language": "python",
62
+ "name": "python3"
63
+ },
64
+ "language_info": {
65
+ "codemirror_mode": {
66
+ "name": "ipython",
67
+ "version": 3
68
+ },
69
+ "file_extension": ".py",
70
+ "mimetype": "text/x-python",
71
+ "name": "python",
72
+ "nbconvert_exporter": "python",
73
+ "pygments_lexer": "ipython3",
74
+ "version": "3.9.12"
75
+ },
76
+ "orig_nbformat": 4,
77
+ "vscode": {
78
+ "interpreter": {
79
+ "hash": "b781f973879b6653a182b86dce637bbad8607b90046e75a81b5febd27741eaed"
80
+ }
81
+ }
82
+ },
83
+ "nbformat": 4,
84
+ "nbformat_minor": 2
85
+ }
gulabjamun.jfif ADDED
Binary file (151 kB). View file
 
jalebi.jpg ADDED
ladoo.webp ADDED
pakora.webp ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ #fastai
samosa.webp ADDED