sdhaos commited on
Commit
39aeb85
·
verified ·
1 Parent(s): 10a0b23

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +179 -3
README.md CHANGED
@@ -1,3 +1,179 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # JankenTron
2
+
3
+ JankenTron is a Rock-Paper-Scissors computer vision model. It opens a webcam or accepts an uploaded image, detects hand gestures in real time-style inference, and highlights the winner when exactly two hands are visible.
4
+
5
+ Built by Amin / BreakRules.
6
+
7
+ ## What It Does
8
+
9
+ - Detects `rock`, `paper`, and `scissors` hand gestures.
10
+ - Supports one or two hands in an image.
11
+ - Applies Rock-Paper-Scissors rules when exactly two hands are detected.
12
+ - Highlights winner, loser, or tie directly on the image.
13
+ - Runs locally with Gradio and can be deployed to Hugging Face Spaces.
14
+
15
+ ## Project Structure
16
+
17
+ ```text
18
+ jankentron/
19
+ app.py # Gradio web app for Hugging Face Spaces/local UI
20
+ jankentron_model.py # YOLO loading, prediction, game rules, drawing
21
+ prepare_data.py # Downloads Kaggle dataset and converts labels to YOLO format
22
+ train.py # Trains YOLO and saves model/jankentron.pt
23
+ predict.py # CLI inference for local images
24
+ deploy.py # Optional Hugging Face upload helper
25
+ requirements.txt # Python dependencies
26
+ ```
27
+
28
+ Generated folders are intentionally ignored by Git:
29
+
30
+ ```text
31
+ dataset/
32
+ runs/
33
+ model/
34
+ photos/
35
+ ```
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ cd /Users/aminmammadov/aiwork/models/jankentron
41
+ python3 -m venv .venv
42
+ source .venv/bin/activate
43
+ pip install -r requirements.txt
44
+ ```
45
+
46
+ ## Prepare Dataset
47
+
48
+ Dataset: <https://www.kaggle.com/datasets/adilshamim8/rock-paper-scissors>
49
+
50
+ ```bash
51
+ python prepare_data.py
52
+ ```
53
+
54
+ This creates:
55
+
56
+ ```text
57
+ dataset/data.yaml
58
+ dataset/images/train
59
+ dataset/images/test
60
+ dataset/labels/train
61
+ dataset/labels/test
62
+ ```
63
+
64
+ ## Train
65
+
66
+ ```bash
67
+ python train.py --model yolo11n.pt --epochs 30 --batch 16 --imgsz 640
68
+ ```
69
+
70
+ Final local weights are saved here:
71
+
72
+ ```text
73
+ model/jankentron.pt
74
+ ```
75
+
76
+ ## Run Locally
77
+
78
+ ```bash
79
+ python app.py
80
+ ```
81
+
82
+ Then open the local Gradio URL and use webcam/upload.
83
+
84
+ ## CLI Prediction
85
+
86
+ ```bash
87
+ python predict.py path/to/image_or_folder --model model/jankentron.pt
88
+ ```
89
+
90
+ Outputs are saved to:
91
+
92
+ ```text
93
+ runs/predict
94
+ ```
95
+
96
+ ## Hugging Face Layout
97
+
98
+ Use two Hugging Face repositories:
99
+
100
+ ```text
101
+ HF Model repo: sdhaos/Jankentron
102
+ HF Space repo: sdhaos/Jankentron
103
+ ```
104
+
105
+ Model repositories and Space repositories are different repo types, so they can use the same slug.
106
+
107
+ ### Files For Hugging Face Models
108
+
109
+ Upload only the trained model artifact:
110
+
111
+ ```text
112
+ jankentron.pt
113
+ ```
114
+
115
+ Optional but useful:
116
+
117
+ ```text
118
+ README.md
119
+ ```
120
+
121
+ ### Files For Hugging Face Spaces
122
+
123
+ Upload the app code, not the dataset or training runs:
124
+
125
+ ```text
126
+ app.py
127
+ jankentron_model.py
128
+ requirements.txt
129
+ README.md
130
+ ```
131
+
132
+ The Space loads the model from the HF model repo by default: `sdhaos/Jankentron`.
133
+
134
+ To use another model repo, set this Space environment variable:
135
+
136
+ ```text
137
+ JANKENTRON_MODEL=your-username/your-model-repo
138
+ ```
139
+
140
+ ## Hugging Face Commands
141
+
142
+ Login first:
143
+
144
+ ```bash
145
+ hf auth login
146
+ ```
147
+
148
+ Create and upload the model repository:
149
+
150
+ ```bash
151
+ cd /Users/aminmammadov/aiwork/models/jankentron
152
+ hf repos create sdhaos/Jankentron --type model --exist-ok
153
+ hf upload sdhaos/Jankentron model/jankentron.pt jankentron.pt --repo-type model --commit-message "Upload JankenTron weights"
154
+ ```
155
+
156
+ Create and upload the Space:
157
+
158
+ ```bash
159
+ cd /Users/aminmammadov/aiwork/models/jankentron
160
+ hf repos create sdhaos/Jankentron --type space --space-sdk gradio --exist-ok --env JANKENTRON_MODEL=sdhaos/Jankentron
161
+ hf upload sdhaos/Jankentron app.py app.py --repo-type space --commit-message "Deploy JankenTron app"
162
+ hf upload sdhaos/Jankentron jankentron_model.py jankentron_model.py --repo-type space --commit-message "Add inference logic"
163
+ hf upload sdhaos/Jankentron requirements.txt requirements.txt --repo-type space --commit-message "Add Space dependencies"
164
+ hf upload sdhaos/Jankentron README.md README.md --repo-type space --commit-message "Add Space README"
165
+ ```
166
+
167
+ Alternative using the helper script:
168
+
169
+ ```bash
170
+ cd /Users/aminmammadov/aiwork/models/jankentron
171
+ python3 deploy.py model --repo-id sdhaos/Jankentron
172
+ python3 deploy.py space --repo-id sdhaos/Jankentron
173
+ ```
174
+
175
+ ## Notes
176
+
177
+ - Do not push `dataset/`, `runs/`, or `model/` to GitHub.
178
+ - Store large trained weights in Hugging Face Models.
179
+ - Store only app files in Hugging Face Spaces.