Chappiel commited on
Commit
b441892
·
1 Parent(s): b4819d8
Files changed (8) hide show
  1. 2.jpg +0 -0
  2. allheroes2.pkl +3 -0
  3. app.py +52 -0
  4. black6.jpg +0 -0
  5. fist4.jpg +0 -0
  6. groot4.jpg +0 -0
  7. requirements.text +3 -0
  8. wol2.jpg +0 -0
2.jpg ADDED
allheroes2.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da6bbcef6ec074810f8655f04feb12a965e5c1680ac5f0c7397046adc3283e67
3
+ size 87548919
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import pathlib
3
+
4
+ # Patch for non-Windows systems: use PosixPath in place of WindowsPath
5
+ if sys.platform != "win32":
6
+ pathlib.WindowsPath = pathlib.PosixPath
7
+
8
+
9
+ import fastai
10
+ print(f"FastAI Version: {fastai.__version__}")
11
+ from fastai.vision.all import *
12
+ import fastcore
13
+
14
+ # Load the model
15
+ learn = load_learner('D:/AI/projects/marvel2/allheroes2.pkl')
16
+ categories = [
17
+ 'Adam Warlock', 'Black Panther', 'Black Widow', 'Bruce Banner',
18
+ 'Captain America', 'Cloak & Dagger', 'Doctor Strange', 'Groot',
19
+ 'Hawkeye', 'Hela', 'Invisible Woman', 'Iron Fist', 'Iron Man',
20
+ 'Jeff', 'Loki', 'Luna Snow', 'Magik', 'Magneto', 'Mantis',
21
+ 'Mister Fantastic', 'Moon Knight', 'Namor', 'Peni Parker',
22
+ 'Psylocke', 'Rocket Raccoon', 'Scarlet Witch', 'Spider Man',
23
+ 'Squirrel Girl', 'Star Lord', 'Storm', 'The Hulk', 'The Punisher',
24
+ 'Thor', 'Venom', 'Winter Soldier', 'Wolverine',]
25
+
26
+ # Define the prediction function
27
+ def classify_image(img):
28
+ pred, idx, probs = learn.predict(img)
29
+ return dict(zip(categories, map(float, probs)))
30
+
31
+ # Gradio interface
32
+ import gradio as gr
33
+
34
+ # Define the input and output components
35
+ image = gr.Image(height=192, width=192) # Resize input images to 192x192
36
+ label = gr.Label()
37
+ examples = ['2.jpg', 'black6.jpg', 'fist4jpg', 'wol2.jpg','groot4']
38
+
39
+ # Create the Gradio app
40
+ demo = gr.Interface(
41
+ fn=classify_image,
42
+ inputs=image,
43
+ outputs=label,
44
+ examples=examples,
45
+ title="Marvel Rivals Hero Classifier",
46
+ description=(
47
+ "This classifier recognizes every Marvel Rivals hero, insert an image or use one of the images to try it out"
48
+ )
49
+ )
50
+
51
+ # Launch the app
52
+ demo.launch()
black6.jpg ADDED
fist4.jpg ADDED
groot4.jpg ADDED
requirements.text ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastai==2.7.18
2
+ gradio==5.12.0
3
+
wol2.jpg ADDED