TomasHalmazna commited on
Commit
5d59ce8
·
verified ·
1 Parent(s): 1775c1a

Upload 5 files

Browse files
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. app.py +23 -0
  3. model.pkl +3 -0
  4. requirements.txt +9 -0
  5. test_image1.jpg +3 -0
  6. test_image2.jpg +3 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ test_image1.jpg filter=lfs diff=lfs merge=lfs -text
37
+ test_image2.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import * # Importing the necessary fastai modules
2
+ import gradio as gr # Importing Gradio for creating the web interface
3
+ import timm # Importing timm for model management
4
+
5
+ # Load the pre-trained model
6
+ learn = load_learner('model.pkl')
7
+
8
+ # Extract categories (class labels) from the DataLoader
9
+ categories = learn.dls.vocab
10
+
11
+ # Function to classify an image
12
+ def classify_image(img):
13
+ _, _, probs = learn.predict(img)
14
+ return dict(zip(categories, map(float, probs))) # Map categories to their probabilities
15
+
16
+ # Define Gradio input and output components
17
+ image = gr.Image(width=224, height=224) # Image input
18
+ label = gr.Label() # Output label to display classification
19
+ examples = ['test_image1.jpg', 'test_image2.jpg'] # Example images for demonstration
20
+
21
+ # Create and launch the Gradio interface
22
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ intf.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3732c77d3bb1572dfcd59996fba6364286fb84d12ded55e894eec2e8220a99ea
3
+ size 46993198
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ numpy==1.26.4
2
+ scipy==1.11.4
3
+ scikit-learn==1.3.2
4
+ fastai==2.7.17
5
+ gradio==4.44.1
6
+ timm==1.0.9
7
+ torch==2.2.1
8
+ torchvision==0.17.1
9
+ setuptools
test_image1.jpg ADDED

Git LFS Details

  • SHA256: bf79f18bda67df5149be8dd2b7c37fe05e1ef75a2e2db696f82b2181ffe3dda8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.83 MB
test_image2.jpg ADDED

Git LFS Details

  • SHA256: 2c21eacad537785683fdb92ad08fe3d84cccaabe4a155f4b7af054fa76528580
  • Pointer size: 132 Bytes
  • Size of remote file: 1.68 MB