Frantz103 commited on
Commit
9ecc50a
1 Parent(s): e6b76a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -1,10 +1,26 @@
1
  import gradio as gr
2
- from fastai.vision.all import PILImage
3
-
4
- from fastai.learner import load_learner
5
 
6
  learn = load_learner('dog_cat_multi.pkl')
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def predict(image):
9
  # Transform the image
10
  pil_image = PILImage.create(image)
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
 
 
3
 
4
  learn = load_learner('dog_cat_multi.pkl')
5
 
6
+ cat_breeds = [
7
+ 'Abyssinian', 'Bengal', 'Birman', 'Bombay', 'British_Shorthair',
8
+ 'Egyptian_Mau', 'Main_Coon', 'Persian', 'Ragdoll', 'Russian_Blue',
9
+ 'Siamese', 'Sphynx'
10
+ ]
11
+
12
+ def get_labels(path):
13
+ regex_pattern = r'(.+)_(\d+)\.jpg$'
14
+ match = re.match(regex_pattern, str(path.name))
15
+ if match:
16
+ label = match.group(1)
17
+ pet_type = 'cat' if label in cat_breeds else 'dog'
18
+ return [pet_type, label]
19
+ else:
20
+ # Handle the case where the regex doesn't match
21
+ print(f"Could not match pattern in {path.name}")
22
+ return []
23
+
24
  def predict(image):
25
  # Transform the image
26
  pil_image = PILImage.create(image)