MCPcopy Index your code
hub / github.com/geekcomputers/Python / interactive_mode

Method interactive_mode

ML/tests/test_model.py:176–235  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

174 print(f"Error loading image: {e}")
175
176 def interactive_mode(self):
177 print("\n" + "=" * 60)
178 print(" Interactive Mode")
179 print("=" * 60)
180 print("\nCommands:")
181 print(" random [N] - Test N random samples (default: 10)")
182 print(" sample <index> - Test specific sample by index")
183 print(" image <path> - Test custom image file")
184 print(" accuracy - Calculate full test set accuracy")
185 print(" help - Show this help")
186 print(" exit - Exit interactive mode")
187 print()
188
189 while True:
190 try:
191 command = input(">>> ").strip().lower()
192
193 if not command:
194 continue
195
196 if command == 'exit' or command == 'quit':
197 print("Exiting...")
198 break
199
200 elif command == 'help':
201 self.interactive_mode()
202 return
203
204 elif command.startswith('random'):
205 parts = command.split()
206 n = int(parts[1]) if len(parts) > 1 else 10
207 self.test_random_samples(n)
208
209 elif command.startswith('sample'):
210 parts = command.split()
211 if len(parts) < 2:
212 print("Usage: sample <index>")
213 else:
214 idx = int(parts[1])
215 self.test_specific_sample(idx)
216
217 elif command.startswith('image'):
218 parts = command.split(maxsplit=1)
219 if len(parts) < 2:
220 print("Usage: image <path>")
221 else:
222 self.test_custom_image(parts[1])
223
224 elif command == 'accuracy':
225 self.test_class_accuracy()
226
227 else:
228 print(f"Unknown command: {command}")
229 print("Type 'help' for available commands")
230
231 except KeyboardInterrupt:
232 print("\nExiting...")
233 break

Callers 1

mainFunction · 0.95

Calls 4

test_random_samplesMethod · 0.95
test_specific_sampleMethod · 0.95
test_custom_imageMethod · 0.95
test_class_accuracyMethod · 0.95

Tested by

no test coverage detected