baker-street commited on
Commit
61d6689
·
1 Parent(s): bd6689b

Add: app v.01

Browse files
Files changed (9) hide show
  1. LICENSE +21 -0
  2. README.md +1 -14
  3. app.py +28 -0
  4. chess_ai_notebook.ipynb +0 -0
  5. chessman_model.pkl +3 -0
  6. knight.jpg +0 -0
  7. pawn.jpg +0 -0
  8. requirements.txt +9 -0
  9. rook.jpg +0 -0
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ilia Munaev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,14 +1 @@
1
- ---
2
- title: Chess Ai Classifier
3
- emoji: 😻
4
- colorFrom: red
5
- colorTo: indigo
6
- sdk: gradio
7
- sdk_version: 5.44.1
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: A deep learning project that recognizes chess pieces.
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # chess-ai-classifier
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ try:
5
+ learn = load_learner("chessman_model.pkl")
6
+ except FileNotFoundError:
7
+ print("Model file not found. Please ensure 'chessman_model.pkl' exists.")
8
+ exit(1)
9
+
10
+ def classify_image(img):
11
+ # Gradio will pass a PIL.Image if we set type="pil"
12
+ pred_class, pred_idx, probs = learn.predict(PILImage.create(img))
13
+ # Return top-3 as a dict for gr.Label
14
+ topk = probs.topk(3)
15
+ return {learn.dls.vocab[i]: float(probs[i]) for i in topk.indices}
16
+
17
+ demo = gr.Interface(
18
+ fn=classify_image,
19
+ inputs=gr.Image(type="pil", label="Upload chess piece", height=320),
20
+ outputs=gr.Label(num_top_classes=3, label="Prediction"),
21
+ examples=['knight.jpg', 'pawn.JPG', 'rook.jpg'],
22
+ title="Chess Piece Classifier",
23
+ description="Upload an image of a chess piece to identify it!"
24
+ )
25
+
26
+ demo.launch(inline=True, debug=True)
27
+
28
+
chess_ai_notebook.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
chessman_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c62c319e42f7ac1a1efe3e3a2aed40b873548be7b0ecbc9e8886363e5722e94
3
+ size 114644470
knight.jpg ADDED
pawn.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ fastai>=2.7.0
2
+ gradio>=4.0.0
3
+ torch>=2.0.0
4
+ torchvision>=0.15.0
5
+ pillow>=9.0.0
6
+ numpy>=1.21.0
7
+ matplotlib>=3.5.0
8
+ pandas>=1.5.0
9
+ scikit-learn>=1.2.0
rook.jpg ADDED