rohanphadke commited on
Commit
4f4ac90
·
1 Parent(s): ea1c8c3

Upload 7 files

Browse files
Files changed (7) hide show
  1. app.py +55 -0
  2. model.pkl +3 -0
  3. model_extended.pkl +3 -0
  4. orchid.jpeg +0 -0
  5. requirements.txt +5 -0
  6. rose.jpeg +0 -0
  7. sunflower.jpeg +0 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner('model_extended.pkl')
5
+
6
+ # categories = 'Sunflower', 'Orchid', 'Rose'
7
+
8
+ def classify_image(img):
9
+ pred, idx, probs = learn.predict(img)
10
+ return pred
11
+
12
+ image = gr.inputs.Image(shape=(192,192))
13
+ label = gr.outputs.Label()
14
+ examples = ['sunflower.jpeg', 'orchid.jpeg', 'rose.jpeg']
15
+
16
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
17
+ intf.launch(inline=False)
18
+
19
+ # from fastai.vision.all import *
20
+ # import gradio as gr
21
+
22
+ # # Load the pre-trained model
23
+ # learn = load_learner('model.pkl')
24
+
25
+ # # Define the categories that the model can classify
26
+ # categories = ['Sunflower', 'Orchid', 'Rose']
27
+
28
+ # # Define the function to classify an image and return the predicted category label
29
+ # def classify_image(img):
30
+ # pred, idx, probs = learn.predict(img)
31
+ # return categories[idx]
32
+
33
+ # # Define the input and output types for the Gradio interface
34
+ # image_input = gr.inputs.Image(shape=(224, 224))
35
+ # label_output = gr.outputs.Label()
36
+
37
+ # # Define example images for the interface
38
+ # examples = [
39
+ # ['sunflower.jpeg'],
40
+ # ['orchid.jpeg'],
41
+ # ['rose.jpeg']
42
+ # ]
43
+
44
+ # # Create the Gradio interface
45
+ # interface = gr.Interface(
46
+ # fn=classify_image,
47
+ # inputs=image_input,
48
+ # outputs=label_output,
49
+ # examples=examples,
50
+ # title="Image Classifier",
51
+ # description="This app classifies images into three categories: Sunflower, Orchid, and Rose."
52
+ # )
53
+
54
+ # # Launch the interface
55
+ # interface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77a5e0369399e981322d28116b109679852326dc8db746aee089e7bdce19919a
3
+ size 46958481
model_extended.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:661066c7fffc09dfbcdd13fb68c6d423bb70cc2a3ab64df42cd8456088dafd6c
3
+ size 114659368
orchid.jpeg ADDED
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastai
2
+ torch
3
+ gradio
4
+ numpy
5
+ pandas
rose.jpeg ADDED
sunflower.jpeg ADDED